2017-03-16 00:56:37 +00:00
|
|
|
# GST
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
######################################################
|
|
|
|
##### Set global variables for all gst Makefiles #####
|
|
|
|
######################################################
|
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-07-16 03:07:12 +00:00
|
|
|
CFLAGS=-std=c99 -Wall -Wextra -I./include -I./libs -g -DGST_VERSION=$(VERSION)
|
2017-02-09 20:02:59 +00:00
|
|
|
PREFIX=/usr/local
|
2017-07-02 18:42:30 +00:00
|
|
|
GST_TARGET=gst
|
2017-07-16 03:07:12 +00:00
|
|
|
GST_XXD=xxd
|
|
|
|
# Use gdb. On mac use lldb
|
|
|
|
DEBUGGER=gdb
|
2017-04-15 20:05:59 +00:00
|
|
|
GST_INTERNAL_HEADERS=$(addprefix core/, cache.h)
|
2017-06-24 18:27:29 +00:00
|
|
|
GST_HEADERS=$(addprefix include/gst/, gst.h)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
2017-07-16 03:07:12 +00:00
|
|
|
#############################
|
|
|
|
##### Generated headers #####
|
|
|
|
#############################
|
|
|
|
GST_LANG_SOURCES=$(addprefix libs/, bootstrap.gst)
|
|
|
|
GST_LANG_HEADERS=$(patsubst %.gst,%.gen.h,$(GST_LANG_SOURCES))
|
2017-07-15 16:21:06 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
all: $(GST_TARGET)
|
|
|
|
|
2017-07-16 03:07:12 +00:00
|
|
|
#######################
|
|
|
|
##### Build tools #####
|
|
|
|
#######################
|
|
|
|
$(GST_XXD): libs/xxd.c
|
|
|
|
$(CC) -o $(GST_XXD) libs/xxd.c
|
|
|
|
|
|
|
|
%.gen.h : %.gst $(GST_XXD)
|
|
|
|
./$(GST_XXD) $< $@ $(basename $(notdir $<))
|
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
###################################
|
|
|
|
##### The core vm and runtime #####
|
|
|
|
###################################
|
|
|
|
GST_CORE_SOURCES=$(addprefix core/,\
|
2017-07-12 18:47:09 +00:00
|
|
|
compile.c parse.c stl.c ids.c util.c env.c module.c\
|
2017-07-03 17:44:58 +00:00
|
|
|
value.c vm.c ds.c gc.c thread.c serialize.c\
|
|
|
|
string.c)
|
2017-03-16 00:56:37 +00:00
|
|
|
GST_CORE_OBJECTS=$(patsubst %.c,%.o,$(GST_CORE_SOURCES))
|
|
|
|
|
2017-06-20 03:01:34 +00:00
|
|
|
######################
|
|
|
|
##### The client #####
|
|
|
|
######################
|
2017-03-16 00:56:37 +00:00
|
|
|
GST_CLIENT_SOURCES=client/main.c
|
|
|
|
GST_CLIENT_OBJECTS=$(patsubst %.c,%.o,$(GST_CLIENT_SOURCES))
|
2017-07-16 03:07:12 +00:00
|
|
|
$(GST_TARGET): $(GST_CLIENT_OBJECTS) $(GST_CORE_OBJECTS) $(GST_LANG_HEADERS)
|
2017-05-06 21:46:28 +00:00
|
|
|
$(CC) $(CFLAGS) -o $(GST_TARGET) $(GST_CLIENT_OBJECTS) $(GST_CORE_OBJECTS)
|
2017-03-16 00:56:37 +00:00
|
|
|
|
|
|
|
# Compile all .c to .o
|
2017-07-16 03:07:12 +00:00
|
|
|
%.o : %.c $(GST_HEADERS) $(GST_INTERNAL_HEADERS) $(GST_LANG_HEADERS)
|
2017-02-09 20:02:59 +00:00
|
|
|
$(CC) $(CFLAGS) -o $@ -c $<
|
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
run: $(GST_TARGET)
|
2017-07-03 15:21:10 +00:00
|
|
|
@ ./$(GST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
debug: $(GST_TARGET)
|
2017-07-15 16:21:06 +00:00
|
|
|
@ $(DEBUGGER) ./$(GST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
valgrind: $(GST_TARGET)
|
2017-07-03 15:21:10 +00:00
|
|
|
@ valgrind --leak-check=full -v ./$(GST_TARGET)
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-03-16 00:56:37 +00:00
|
|
|
clean:
|
|
|
|
rm $(GST_TARGET) || true
|
|
|
|
rm $(GST_CORE_OBJECTS) || true
|
|
|
|
rm $(GST_CLIENT_OBJECTS) || true
|
2017-07-16 03:07:12 +00:00
|
|
|
rm $(GST_LANG_HEADERS) || true
|
2017-03-22 04:27:18 +00:00
|
|
|
rm vgcore.* || true
|
2017-07-16 03:07:12 +00:00
|
|
|
rm $(GST_XXD) || true
|
2017-02-09 20:56:45 +00:00
|
|
|
|
2017-06-20 03:01:34 +00:00
|
|
|
test: $(GST_TARGET)
|
2017-07-03 15:21:10 +00:00
|
|
|
@ ./$(GST_TARGET) gsttests/basic.gst
|
2017-06-20 03:01:34 +00:00
|
|
|
|
2017-06-30 01:57:09 +00:00
|
|
|
valtest: $(GST_TARGET)
|
|
|
|
valgrind --leak-check=full -v ./$(GST_TARGET) gsttests/basic.gst
|
|
|
|
|
2017-07-02 18:56:31 +00:00
|
|
|
install: $(GST_TARGET)
|
|
|
|
cp $(GST_TARGET) $(BINDIR)/gst
|
|
|
|
|
|
|
|
uninstall:
|
|
|
|
rm $(BINDIR)/gst
|
|
|
|
|
|
|
|
.PHONY: clean install run debug valgrind test valtest install uninstall
|