shithub: femtolisp

ref: 534e73b59d204c56a3b3cfa358909b3f7f89ad66
dir: /Makefile/

View raw version
DESTDIR?=
PREFIX?=/usr/local
BIN=${DESTDIR}${PREFIX}/bin

TARG=flisp
CFLAGS?=-O2 -g
CFLAGS+=-Wall -Wextra -Wno-parentheses -std=c99 -I3rd -Iposix
LDFLAGS?=

OBJS=\
	flmain.o\
	flisp.o\
	builtins.o\
	string.o\
	equalhash.o\
	table.o\
	iostream.o\
	operators.o\
	cvalues.o\
	read.o\
	print.o\
	equal.o\
	types.o\
	bitvector-ops.o\
	bitvector.o\
	dump.o\
	hashing.o\
	htable.o\
	ios.o\
	llt.o\
	ptrhash.o\
	random.o\
	timefuncs.o\
	utf8.o\
	3rd/mp/mpadd.o\
	3rd/mp/mpaux.o\
	3rd/mp/mpcmp.o\
	3rd/mp/mpdigdiv.o\
	3rd/mp/mpdiv.o\
	3rd/mp/mpfmt.o\
	3rd/mp/mpleft.o\
	3rd/mp/mplogic.o\
	3rd/mp/mpmul.o\
	3rd/mp/mpright.o\
	3rd/mp/mpsub.o\
	3rd/mp/mptobe.o\
	3rd/mp/mptober.o\
	3rd/mp/mptod.o\
	3rd/mp/mptoi.o\
	3rd/mp/mptoui.o\
	3rd/mp/mptouv.o\
	3rd/mp/mptov.o\
	3rd/mp/mpvecadd.o\
	3rd/mp/mpveccmp.o\
	3rd/mp/mpvecdigmuladd.o\
	3rd/mp/mpvecsub.o\
	3rd/mp/mpvectscmp.o\
	3rd/mp/strtomp.o\
	3rd/mp/u16.o\
	3rd/mp/u32.o\
	3rd/mp/u64.o\
	3rd/mt19937-64.o\

.PHONY: all default test bootstrap clean

all: default

default: ${TARG}

test: ${TARG}
	cd test && ../$(TARG) unittest.lsp

${TARG}: ${OBJS}
	${CC} -o $@ ${OBJS} ${LDFLAGS} -lm

.SUFFIXES: .c .o
.c.o:
	${CC} -o $@ -c $< ${CFLAGS}

flisp.o: flisp.c flisp.h operators.h cvalues.h maxstack.inc opcodes.h builtin_fns.h
flmain.o: flmain.c boot.h flisp.h cvalues.h builtin_fns.h

boot.h: flisp.boot
	sed 's,\\,\\\\,g;s,",\\",g;s,^,",g;s,$$,\\n",g' flisp.boot >$@

builtin_fns.h: *.c
	sed -nE 's/^BUILTIN[_]?(\(".*)/BUILTIN_FN\1/gp' *.c >$@

bootstrap: ${TARG} builtin_fns.h mkboot0.lsp mkboot1.lsp
	cp flisp.boot flisp.boot.bak
	./${TARG} gen.lsp
	./${TARG} mkboot0.lsp instructions.lsp builtins.lsp system.lsp compiler.lsp >flisp.boot
	${MAKE} clean
	${MAKE} ${TARG}
	./${TARG} mkboot1.lsp
	${MAKE} test

clean:
	rm -f ${OBJS} ${TARG}