picrin/Makefile

117 lines
3.2 KiB
Makefile
Raw Normal View History

2015-05-29 07:42:26 -04:00
PICRIN_SRCS = \
src/main.c\
2017-04-15 02:45:28 -04:00
src/init_lib.c\
src/lib.c\
2015-05-29 07:42:26 -04:00
src/load_piclib.c\
src/init_contrib.c
PICRIN_OBJS = \
$(PICRIN_SRCS:.c=.o)
CONTRIB_SRCS =
CONTRIB_OBJS = $(CONTRIB_SRCS:.c=.o)
CONTRIB_LIBS =
CONTRIB_INITS =
CONTRIB_TESTS =
CONTRIB_DOCS = $(wildcard contrib/*/docs/*.rst)
2015-10-02 01:50:43 -04:00
PICRIN_ISSUE_TESTS = $(wildcard t/issue/*.scm)
REPL_ISSUE_TESTS = $(wildcard t/issue/*.sh)
2015-05-29 07:42:26 -04:00
2017-03-22 10:59:22 -04:00
TEST_RUNNER = picrin
2017-04-15 02:45:28 -04:00
CFLAGS += -I./lib/include -I./include -Wall -Wextra
LDFLAGS += -lm
2015-05-29 07:42:26 -04:00
prefix ?= /usr/local
2015-05-29 07:42:26 -04:00
2017-04-09 05:12:13 -04:00
all: CFLAGS += -O2 -g -DNDEBUG=1
2017-04-15 02:45:28 -04:00
all: bootstrap picrin
2015-05-29 07:42:26 -04:00
2015-07-12 20:54:16 -04:00
debug: CFLAGS += -O0 -g
2017-04-15 02:45:28 -04:00
debug: bootstrap picrin
2015-05-29 07:42:26 -04:00
include $(sort $(wildcard contrib/*/nitro.mk))
2017-04-15 02:45:28 -04:00
bootstrap: bin/picrin-bootstrap
2017-04-03 09:09:19 -04:00
2017-04-15 02:45:28 -04:00
bin/picrin-bootstrap:
test -f bin/picrin-bootstrap || { $(MAKE) -C lib mini-picrin && cp lib/mini-picrin bin/picrin-bootstrap; }
2017-04-15 02:45:28 -04:00
2017-04-15 05:47:49 -04:00
lib/mini-picrin: FORCE
2017-04-15 02:45:28 -04:00
$(MAKE) -C lib mini-picrin
2017-04-15 05:47:49 -04:00
lib/libpicrin.a: FORCE
2017-04-15 02:45:28 -04:00
$(MAKE) -C lib libpicrin.a
ext: lib/ext/eval.c lib/ext/error.c
2017-04-15 02:45:28 -04:00
lib/ext/eval.c: piclib/eval.scm
2017-04-22 20:44:22 -04:00
bin/picrin-bootstrap -c eval_rom piclib/eval.scm | bin/picrin-bootstrap tools/mkeval.scm > lib/ext/eval.c
2017-04-15 02:45:28 -04:00
lib/ext/error.c: piclib/error.scm
bin/picrin-bootstrap -c error_rom piclib/error.scm | bin/picrin-bootstrap tools/mkerror.scm > lib/ext/error.c
2017-04-15 02:45:28 -04:00
picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) ext lib/libpicrin.a
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) lib/libpicrin.a $(LDFLAGS)
src/init_lib.c: piclib/library.scm
2017-04-25 09:51:55 -04:00
bin/picrin-bootstrap -c lib_rom piclib/library.scm | bin/picrin-bootstrap tools/mklib.scm > src/init_lib.c
2015-05-29 07:42:26 -04:00
2015-07-08 15:07:12 -04:00
src/load_piclib.c: $(CONTRIB_LIBS)
2017-03-23 09:47:55 -04:00
perl tools/mkloader.pl $(CONTRIB_LIBS) > $@
2015-05-29 07:42:26 -04:00
src/init_contrib.c:
2017-03-23 09:47:55 -04:00
perl tools/mkinit.pl $(CONTRIB_INITS) > $@
2015-05-29 07:42:26 -04:00
2017-04-15 02:45:28 -04:00
$(PICRIN_OBJS) $(CONTRIB_OBJS): lib/include/*.h lib/include/picrin/*.h lib/*.h include/picrin/*.h
2015-05-29 07:42:26 -04:00
doc: docs/*.rst docs/contrib.rst
$(MAKE) -C docs html
mkdir -p doc
cp -uR docs/_build/* -t doc/
docs/contrib.rst: $(CONTRIB_DOCS)
echo "Contrib Libraries \\\(a.k.a nitros\\\)" > $@
echo "================================" >> $@
echo "" >> $@
cat $(CONTRIB_DOCS) >> $@
2015-10-02 01:50:43 -04:00
test: test-contribs test-nostdlib test-issue
2015-05-29 07:42:26 -04:00
2017-03-22 10:59:22 -04:00
test-contribs: picrin $(CONTRIB_TESTS)
2015-05-29 07:42:26 -04:00
2017-04-15 02:45:28 -04:00
test-nostdlib: ext
$(CC) -I./lib/include -Os -DPIC_USE_LIBC=0 -DPIC_USE_CALLCC=0 -DPIC_USE_FILE=0 -DPIC_USE_READ=0 -DPIC_USE_WRITE=0 -DPIC_USE_EVAL=0 -nostdlib -ffreestanding -fno-stack-protector -shared -pedantic -std=c89 -Wall -Wextra -Werror -o libpicrin-tiny.so $(wildcard lib/*.c)
2017-03-22 11:40:33 -04:00
strip libpicrin-tiny.so
ls -lh libpicrin-tiny.so
rm -f libpicrin-tiny.so
2015-05-30 06:57:12 -04:00
2015-10-02 01:50:43 -04:00
test-issue: test-picrin-issue test-repl-issue
test-picrin-issue: $(TEST_RUNNER) $(PICRIN_ISSUE_TESTS)
for test in $(PICRIN_ISSUE_TESTS); do \
2017-03-22 10:59:22 -04:00
./$(TEST_RUNNER) "$$test"; \
done
2015-10-02 01:50:43 -04:00
test-repl-issue: $(REPL_ISSUE_TESTS)
$(REPL_ISSUE_TESTS):
2017-03-22 10:59:22 -04:00
PICRIN=./$(TEST_RUNNER) ./$@
2015-10-02 01:50:43 -04:00
2017-03-22 12:32:07 -04:00
push:
git subtree push --prefix=lib git@github.com:picrin-scheme/libpicrin.git master
2015-05-29 07:42:26 -04:00
install: all
2017-03-22 10:59:22 -04:00
install -c picrin $(prefix)/bin/picrin
2015-05-29 07:42:26 -04:00
clean:
2017-04-15 02:45:28 -04:00
$(MAKE) -C lib clean
2017-03-28 08:51:24 -04:00
$(RM) picrin
2017-04-15 02:45:28 -04:00
$(RM) src/load_piclib.c src/init_contrib.c src/init_lib.c
$(RM) libpicrin-tiny.so
2017-03-28 08:51:24 -04:00
$(RM) $(PICRIN_OBJS)
$(RM) $(CONTRIB_OBJS)
2015-05-29 07:42:26 -04:00
2017-04-15 05:47:49 -04:00
FORCE:
2017-04-15 02:45:28 -04:00
.PHONY: all bootstrap ext install clean push test test-r7rs test-contribs test-issue test-picrin-issue test-repl-issue doc $(CONTRIB_TESTS) $(REPL_ISSUE_TESTS)