Source

arana-main / Makefile

Full commit
SRC = \
	arana/main.c \
	arana/object.c \
	arana/primitives.c \
	arana/string.c \
	arana/tuple.c \
	arana/list.c \
	arana/float.c \
	arana/range.c \
	arana/file.c \
	arana/stringmap.c \
	arana/interpreter.c \
	arana/parse_args.c \
	arana/error.c \
	arana/ast.c \
	arana/eval.c \
	arana/compile.c \
	arana/lexnparse.c \
	arana/grammar.c \
	arana/repl.c \
	arana/utils/stringbuilder.c

HEADERS = \
	arana/_opmap.h \
	arana/_opcode_targets.h \
	arana/_astmap.h \
	arana/_version.h \
	arana/arana.h \
	arana/object.h \
	arana/primitives.h \
	arana/string.h \
	arana/tuple.h \
	arana/list.h \
	arana/float.h \
	arana/range.h \
	arana/file.h \
	arana/stringmap.h \
	arana/parse_args.h \
	arana/error.h \
	arana/ast.h \
	arana/eval.h \
	arana/compile.h \
	arana/lexnparse.h \
	arana/grammar.h \
	arana/repl.h \
	arana/utils/stringbuilder.h

# path to the boehm installation
BOEHM_PATH = ./gc

# defaults
EXECUTABLE = bin/arana
OBJ = ${SRC:.c=.o}
CC = gcc
CFLAGS = -Wall -std=c99 -I ${BOEHM_PATH}/include -g
LIBS =
INCS =
ECHO = echo
PYTHON = python
RAGEL = ragel

all: arana

test: all
	@${ECHO} "     RUN " ${EXECUTABLE}
	@./bin/arana; if [ $$? -eq 139 ]; then gdb -x .gdbcmd ./bin/arana; fi

rltest: all tools/librlfgets.so
	@${ECHO} "   RLRUN " ${EXECUTABLE}
	@FGETS_PROMPT="ar> " LD_PRELOAD=`pwd`/tools/librlfgets.so ./bin/arana

arana/_astmap.h: arana/ast.h
	@${ECHO} "  PYTHON " tools/gen-astmap.py
	@${PYTHON} tools/gen-astmap.py

arana/_opmap.h: arana/compile.h
	@${ECHO} "  PYTHON " tools/gen-opmap.py
	@${PYTHON} tools/gen-opmap.py

arana/_version.h:
	@${ECHO} "      SH " tools/gen-version.sh
	@./tools/gen-version.sh

arana/lexnparse.c: arana/lexnparse.rl
	@${ECHO} "   RAGEL " arana/lexnparse.rl
	@${RAGEL} arana/lexnparse.rl

arana/grammar.h: arana/grammar.c

arana/grammar.c: tools/lemon arana/grammar.y
	@${ECHO} "   LEMON " arana/grammar.y
	@./tools/lemon arana/grammar.y

tools/lemon: tools/lempar.c
	@${ECHO} "    MAKE " $@
	@${CC} ${CFLAGS} tools/lemon.c -o tools/lemon

tools/librlfgets.so: tools/librlfgets.c
	@${ECHO} "    MAKE " $@
	@${CC} -fPIC -shared -o tools/librlfgets.so -ldl -lreadline tools/librlfgets.c

${OBJ}: ${HEADERS}

${EXECUTABLE}: ${OBJ}
	@${ECHO} "    LINK " ${EXECUTABLE}
	@${CC} ${CFLAGS} ${OBJ} ${BOEHM_PATH}/lib/libgc.a -lm -lpthread ${LIBS} -o ${EXECUTABLE}

%.o: %.c
	@${ECHO} "      CC " $<
	@${CC} -c ${CFLAGS} ${INCS} -o $@ $<

.c.o:
	@${ECHO} "      CC " $<
	@${CC} -c ${CFLAGS} ${INCS} -o $@ $<

arana: ${EXECUTABLE} ${HEADERS}

clean:
	@${ECHO} "Cleaning... "
	@rm -f ${OBJ}
	@rm -f ${EXECUTABLE}
	@rm -f arana/_opmap.h arana/_astmap.h arana/_opcode_targets.h arana/_version.h
	@rm -f arana/grammar.c arana/grammar.h arana/grammar.out arana/lexnparse.c
	@${ECHO} "done."

.PHONY: all clean test