picrin/Makefile

133 lines
3.4 KiB
Makefile
Raw Normal View History

2017-03-28 08:51:24 -04:00
LIBPICRIN_SRCS = \
lib/blob.c\
lib/bool.c\
lib/char.c\
lib/cont.c\
lib/data.c\
lib/debug.c\
lib/dict.c\
lib/error.c\
lib/gc.c\
lib/number.c\
lib/pair.c\
lib/port.c\
lib/proc.c\
lib/record.c\
lib/state.c\
lib/string.c\
lib/symbol.c\
lib/var.c\
lib/vector.c\
lib/weak.c\
2017-03-31 02:59:22 -04:00
lib/ext/boot.c\
2017-03-28 10:09:40 -04:00
lib/ext/eval.c\
lib/ext/lib.c\
lib/ext/load.c\
lib/ext/read.c\
lib/ext/write.c
2017-03-22 10:41:38 -04:00
LIBPICRIN_OBJS = $(LIBPICRIN_SRCS:.c=.o)
2015-05-29 07:42:26 -04:00
PICRIN_SRCS = \
src/main.c\
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_DEFS =
2015-05-29 07:42:26 -04:00
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-03 00:32:47 -04:00
CFLAGS += -I./lib/include -Wall -Wextra
LDFLAGS += -lm
2015-05-29 07:42:26 -04:00
prefix ?= /usr/local
2015-05-29 07:42:26 -04:00
2016-03-03 05:59:37 -05:00
all: CFLAGS += -O2 -DNDEBUG=1
2017-03-22 10:59:22 -04:00
all: picrin
2015-05-29 07:42:26 -04:00
2015-07-12 20:54:16 -04:00
debug: CFLAGS += -O0 -g
2017-03-22 10:59:22 -04:00
debug: picrin
2015-05-29 07:42:26 -04:00
2017-04-03 09:09:19 -04:00
tiny-picrin: CFLAGS += -O0 -g -DPIC_USE_LIBRARY=0
tiny-picrin: $(LIBPICRIN_OBJS) src/tiny-main.o
$(CC) $(CFLAGS) -o $@ $(LIBPICRIN_OBJS) src/tiny-main.o $(LDFLAGS)
include $(sort $(wildcard contrib/*/nitro.mk))
2017-03-22 10:59:22 -04:00
picrin: CFLAGS += $(CONTRIB_DEFS)
picrin: $(PICRIN_OBJS) $(CONTRIB_OBJS) $(LIBPICRIN_OBJS)
2017-03-22 10:41:38 -04:00
$(CC) $(CFLAGS) -o $@ $(PICRIN_OBJS) $(CONTRIB_OBJS) $(LIBPICRIN_OBJS) $(LDFLAGS)
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-03-22 11:40:33 -04:00
# FIXME: Undefined symbols error for _emyg_atod and _emyg_dtoa
# libpicrin.so: $(LIBPICRIN_OBJS)
# $(CC) -shared $(CFLAGS) -o $@ $(LIBPICRIN_OBJS) $(LDFLAGS)
2015-05-29 07:42:26 -04:00
lib/ext/boot.c: piclib/boot.scm piclib/library.scm
2017-04-03 11:02:00 -04:00
cat piclib/boot.scm piclib/library.scm | bin/picrin-bootstrap tools/mkboot.scm > lib/ext/boot.c
2015-06-13 00:05:28 -04:00
$(LIBPICRIN_OBJS) $(PICRIN_OBJS) $(CONTRIB_OBJS): lib/include/picrin.h lib/include/picrin/*.h lib/khash.h lib/object.h lib/state.h lib/vm.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-03-31 02:59:22 -04:00
test-nostdlib: lib/ext/boot.c
2017-03-28 10:09:40 -04:00
$(CC) -I./lib -I./lib/include -D'PIC_USE_LIBC=0' -D'PIC_USE_STDIO=0' -D'PIC_USE_WRITE=0' -ffreestanding -nostdlib -Os -fPIC -shared -std=c89 -pedantic -Wall -Wextra -Werror -o libpicrin-tiny.so $(LIBPICRIN_SRCS) etc/libc_polyfill.c -fno-stack-protector
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-03-28 08:51:24 -04:00
$(RM) picrin
2017-03-31 02:59:22 -04:00
$(RM) src/load_piclib.c src/init_contrib.c lib/ext/boot.c
2017-03-28 08:51:24 -04:00
$(RM) libpicrin.so libpicrin-tiny.so
$(RM) $(LIBPICRIN_OBJS)
$(RM) $(PICRIN_OBJS)
$(RM) $(CONTRIB_OBJS)
2015-05-29 07:42:26 -04:00
2017-03-23 09:47:55 -04:00
.PHONY: all install clean push test test-r7rs test-contribs test-issue test-picrin-issue test-repl-issue doc $(CONTRIB_TESTS) $(REPL_ISSUE_TESTS)