2017-11-06 03:05:47 +00:00
|
|
|
# Copyright (c) 2017 Calvin Rose
|
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
# of this software and associated documentation files (the "Software"), to
|
|
|
|
# deal in the Software without restriction, including without limitation the
|
|
|
|
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
|
|
# sell copies of the Software, and to permit persons to whom the Software is
|
|
|
|
# furnished to do so, subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in
|
|
|
|
# all copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
# IN THE SOFTWARE.
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
################################
|
|
|
|
##### Set global variables #####
|
|
|
|
################################
|
2017-07-02 02:34:31 +00:00
|
|
|
|
2017-07-02 18:56:31 +00:00
|
|
|
PREFIX?=/usr/local
|
|
|
|
BINDIR=$(PREFIX)/bin
|
2018-01-14 04:38:58 +00:00
|
|
|
VERSION=0.0.0-beta
|
2017-07-02 02:34:31 +00:00
|
|
|
|
2018-01-14 04:38:58 +00:00
|
|
|
CFLAGS=-std=c99 -Wall -Wextra -I./include -I./libs -g -DDST_VERSION=\"$(VERSION)\"
|
|
|
|
CLIBS=-lm -ldl
|
2017-02-09 20:02:59 +00:00
|
|
|
PREFIX=/usr/local
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_TARGET=dst
|
2017-11-01 21:53:43 +00:00
|
|
|
DEBUGGER=lldb
|
2018-01-16 01:14:21 +00:00
|
|
|
DST_INTERNAL_HEADERS=$(addprefix core/,symcache.h opcodes.h compile.h gc.h sourcemap.h util.h)
|
2017-12-30 21:46:59 +00:00
|
|
|
DST_HEADERS=$(addprefix include/dst/,dst.h dstconfig.h dsttypes.h dststate.h dststl.h)
|
2018-01-14 04:38:58 +00:00
|
|
|
DST_C_LIBS=$(addprefix libs/,testlib.so)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2017-07-16 03:07:12 +00:00
|
|
|
#############################
|
|
|
|
##### Generated headers #####
|
|
|
|
#############################
|
2017-11-06 03:05:47 +00:00
|
|
|
|
2018-01-04 02:36:10 +00:00
|
|
|
DST_ALL_HEADERS=$(DST_HEADERS) $(DST_INTERNAL_HEADERS)
|
2017-07-15 16:21:06 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
all: $(DST_TARGET)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
|
|
|
###################################
|
|
|
|
##### The core vm and runtime #####
|
|
|
|
###################################
|
2017-11-06 03:05:47 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_CORE_SOURCES=$(addprefix core/,\
|
2018-01-12 15:41:27 +00:00
|
|
|
abstract.c array.c asm.c buffer.c compile.c compile_specials.c\
|
2018-01-14 14:58:35 +00:00
|
|
|
fiber.c gc.c io.c math.c native.c parse.c sourcemap.c string.c\
|
2018-01-04 02:36:10 +00:00
|
|
|
stl.c strtod.c struct.c symcache.c table.c tuple.c util.c\
|
2018-01-06 16:09:15 +00:00
|
|
|
value.c vm.c wrap.c)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2018-01-04 02:36:10 +00:00
|
|
|
DST_CLIENT_SOURCES=$(addprefix client/,\
|
|
|
|
main.c)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2018-01-04 02:36:10 +00:00
|
|
|
$(DST_TARGET): $(DST_CORE_SOURCES) $(DST_CLIENT_SOURCES) $(DST_ALL_HEADERS)
|
2018-01-12 22:42:14 +00:00
|
|
|
$(CC) $(CFLAGS) -o $(DST_TARGET) $(DST_CORE_SOURCES) $(DST_CLIENT_SOURCES) $(CLIBS)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2018-01-14 04:38:58 +00:00
|
|
|
#######################
|
|
|
|
##### C Libraries #####
|
|
|
|
#######################
|
|
|
|
|
|
|
|
%.so: %.c $(DST_HEADERS)
|
2018-01-16 01:14:21 +00:00
|
|
|
$(CC) $(CFLAGS) -DDST_LIB -shared -undefined dynamic_lookup -o $@ $<
|
2018-01-14 04:38:58 +00:00
|
|
|
|
|
|
|
|
2017-11-06 03:05:47 +00:00
|
|
|
###################
|
|
|
|
##### Testing #####
|
|
|
|
###################
|
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
run: $(DST_TARGET)
|
|
|
|
@ ./$(DST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
debug: $(DST_TARGET)
|
|
|
|
@ $(DEBUGGER) ./$(DST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
valgrind: $(DST_TARGET)
|
|
|
|
@ valgrind --leak-check=full -v ./$(DST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-11-06 03:05:47 +00:00
|
|
|
test: $(DST_TARGET)
|
2018-01-12 21:25:24 +00:00
|
|
|
@ ./$(DST_TARGET) --gcinterval=0 dsttest/suite0.dst
|
2017-11-06 03:05:47 +00:00
|
|
|
|
|
|
|
valtest: $(DST_TARGET)
|
|
|
|
valgrind --leak-check=full -v ./$(DST_TARGET) dsttests/basic.dst
|
|
|
|
|
|
|
|
#################
|
|
|
|
##### Other #####
|
|
|
|
#################
|
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
clean:
|
2017-09-09 18:39:51 +00:00
|
|
|
rm $(DST_TARGET) || true
|
2018-01-04 02:36:10 +00:00
|
|
|
rm *.o || true
|
|
|
|
rm client/*.o || true
|
|
|
|
rm core/*.o || true
|
2017-09-09 18:39:51 +00:00
|
|
|
rm $(DST_LANG_HEADERS) || true
|
2017-03-22 04:27:18 +00:00
|
|
|
rm vgcore.* || true
|
2017-11-06 03:05:47 +00:00
|
|
|
rm unittests/*.out || true
|
2017-09-09 18:39:51 +00:00
|
|
|
rm $(DST_XXD) || true
|
2017-02-09 20:56:45 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
install: $(DST_TARGET)
|
|
|
|
cp $(DST_TARGET) $(BINDIR)/dst
|
2017-07-02 18:56:31 +00:00
|
|
|
|
|
|
|
uninstall:
|
2017-09-09 18:39:51 +00:00
|
|
|
rm $(BINDIR)/dst
|
2017-07-02 18:56:31 +00:00
|
|
|
|
|
|
|
.PHONY: clean install run debug valgrind test valtest install uninstall
|