2017-09-09 18:39:51 +00:00
|
|
|
# DST
|
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
|
2017-07-02 02:34:31 +00:00
|
|
|
VERSION=\"0.0.0-beta\"
|
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
CFLAGS=-std=c99 -Wall -Wextra -I./include -I./libs -g -DDST_VERSION=$(VERSION)
|
2017-02-09 20:02:59 +00:00
|
|
|
PREFIX=/usr/local
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_TARGET=dst
|
|
|
|
DST_XXD=xxd
|
2017-07-16 03:07:12 +00:00
|
|
|
# Use gdb. On mac use lldb
|
2017-11-01 21:53:43 +00:00
|
|
|
DEBUGGER=lldb
|
|
|
|
DST_INTERNAL_HEADERS=$(addprefix core/, internal.h bootstrap.h cache.h)
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_HEADERS=$(addprefix include/dst/, dst.h)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2017-07-16 03:07:12 +00:00
|
|
|
#############################
|
|
|
|
##### Generated headers #####
|
|
|
|
#############################
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_LANG_SOURCES=$(addprefix libs/, bootstrap.dst)
|
|
|
|
DST_LANG_HEADERS=$(patsubst %.dst,%.gen.h,$(DST_LANG_SOURCES))
|
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
|
|
|
|
2017-07-16 03:07:12 +00:00
|
|
|
#######################
|
|
|
|
##### Build tools #####
|
|
|
|
#######################
|
2017-09-09 18:39:51 +00:00
|
|
|
$(DST_XXD): libs/xxd.c
|
|
|
|
$(CC) -o $(DST_XXD) libs/xxd.c
|
2017-07-16 03:07:12 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
%.gen.h: %.dst $(DST_XXD)
|
|
|
|
./$(DST_XXD) $< $@ $(basename $(notdir $<))
|
2017-07-16 03:07:12 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
###################################
|
|
|
|
##### The core vm and runtime #####
|
|
|
|
###################################
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_CORE_SOURCES=$(addprefix core/,\
|
2017-11-01 21:53:43 +00:00
|
|
|
util.c wrap.c buffer.c array.c table.c userdata.c func.c\
|
|
|
|
value.c vm.c ds.c gc.c thread.c serialize.c tuple.c\
|
|
|
|
string.c bootstrap_parse.c client.c cache.c struct.c)
|
2017-09-09 18:39:51 +00:00
|
|
|
DST_CORE_OBJECTS=$(patsubst %.c,%.o,$(DST_CORE_SOURCES))
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
$(DST_TARGET): $(DST_CORE_OBJECTS) $(DST_LANG_HEADERS)
|
|
|
|
$(CC) $(CFLAGS) -o $(DST_TARGET) $(DST_CORE_OBJECTS)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
|
|
|
# Compile all .c to .o
|
2017-09-09 18:39:51 +00:00
|
|
|
%.o: %.c $(DST_HEADERS) $(DST_INTERNAL_HEADERS) $(DST_LANG_HEADERS)
|
2017-02-09 20:02:59 +00:00
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
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-03-16 00:56:37 +00:00
|
|
|
clean:
|
2017-09-09 18:39:51 +00:00
|
|
|
rm $(DST_TARGET) || true
|
|
|
|
rm $(DST_CORE_OBJECTS) || true
|
|
|
|
rm $(DST_LANG_HEADERS) || true
|
2017-03-22 04:27:18 +00:00
|
|
|
rm vgcore.* || 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
|
|
|
test: $(DST_TARGET)
|
|
|
|
@ ./$(DST_TARGET) dsttests/basic.dst
|
2017-06-20 03:01:34 +00:00
|
|
|
|
2017-09-09 18:39:51 +00:00
|
|
|
valtest: $(DST_TARGET)
|
|
|
|
valgrind --leak-check=full -v ./$(DST_TARGET) dsttests/basic.dst
|
2017-06-30 01:57:09 +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
|