~brenns10/funlisp

funlisp/Makefile -rw-r--r-- 3.7 KiB
8947d954Stephen Brennan Release v1.2.0 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# funlisp - Makefile
#
# Stephen Brennan <stephen@brennan.io>

# Setting for CFLAGS, CC, and DESTDIR come from Makefile.conf
include Makefile.conf

OBJS=src/builtins.o src/charbuf.o src/gc.o src/hashtable.o src/iter.o \
     src/parse.o src/ringbuf.o src/types.o src/util.o src/textcache.o \
     src/module.o

# https://semver.org
VERSION=1.2.0

all: bin/libfunlisp.a bin/funlisp bin/repl bin/hello_repl bin/runfile \
 bin/call_lisp FORCE

.c.o:
	$(CC) $(CFLAGS) -DFUNLISP_VERSION=\"$(VERSION)\" -c $< -o $@

bin/libfunlisp.a: $(OBJS)
	ar rcs $@ $^

bin/repl: tools/repl.o bin/libfunlisp.a
	$(CC) $(CFLAGS) $^ -o $@

bin/hello_repl: tools/hello_repl.o bin/libfunlisp.a
	$(CC) $(CFLAGS) $^ -o $@

bin/runfile:  tools/runfile.o bin/libfunlisp.a
	$(CC) $(CFLAGS) $^ -o $@

bin/call_lisp: tools/call_lisp.o bin/libfunlisp.a
	$(CC) $(CFLAGS) $^ -o $@

bin/funlisp: tools/funlisp.o bin/libfunlisp.a
	$(CC) $(CFLAGS) -ledit $^ -o $@

bin/example_list_append: tools/example_list_append.o bin/libfunlisp.a
	$(CC) $(CFLAGS) $^ -o $@

clean: FORCE
	rm -rf bin/* {src,tools}/*.{o,gcda,gcno}

# Meant to be run after downloading the source tarball. This has an un-expressed
# dependency on `man/funlisp.3`, since the source tarball includes generated
# documentation, while the git repository does not. Leaving that dependency out
# allows the source tarball to be installed on a wide variety of POSIX compliant
# machines. Depends on the variables (set in Makefile.conf):
#   DESTDIR: specifies alternative root of installation, typically /
#   PREFIX: typically usr
# Taken together, the usual location for the binary is /usr/lib/libfunlisp.a
install: bin/libfunlisp.a
	install -d $(DESTDIR)$(PREFIX)/lib/
	install -m 644 bin/libfunlisp.a $(DESTDIR)$(PREFIX)/lib/
	install -d $(DESTDIR)$(PREFIX)/include/
	install -m 644 inc/funlisp.h $(DESTDIR)$(PREFIX)/include/
	@# Documentation installed only if it has been generated.
	if [ -f man/funlisp.3 ]; then \
	  install -d $(DESTDIR)$(PREFIX)/share/man/man3/ ; \
	  install -m 644 man/funlisp.3 $(DESTDIR)$(PREFIX)/share/man/man3/ ; \
	fi

# For uninstallation of the library. Should be kept in sync with the above
# installation files. Depends on the same variables.
uninstall: FORCE
	@echo 'Sorry to see you go!'
	rm $(DESTDIR)$(PREFIX)/lib/libfunlisp.a
	rm $(DESTDIR)$(PREFIX)/include/funlisp.h
	rm -f $(DESTDIR)$(PREFIX)/share/man/man3/funlisp.3

FORCE:
	@true

#
# Below are tools mainly meant to be run by developers, using a broader array of
# GNU utilities. They may not be strictly standard.
#
doc: FORCE
	doxygen
	sphinx-build -d doc/.doctrees -b html doc html
	sphinx-build -d doc/.doctrees -b man doc man

test: all FORCE
	rm -f cov*.html src/*.gcda
	@cd scripts && python ../test.py tests -r ../bin/funlisp
	gcovr -r src --html --html-details -o cov.html

clean_doc:
	rm -rf doc/xml man html
	make -C doc clean

# Create a distribution package, with generated manual and html included. The
# --transform argument ensures that when the tarball is extracted, all files are
# within a subdirectory.
package: FORCE clean doc
	# first, ensure that we're packaging the proper Makefile.conf
	cp Makefile.conf.dist Makefile.conf
	tar --transform='s/^/funlisp-$(VERSION)\//' -cvf funlisp-$(VERSION).tar.gz \
		LICENSE.txt README.md INSTALL.md CHANGELOG.md \
		Makefile Makefile.conf Makefile.conf.dev Makefile.dep \
		Doxyfile doc/*.rst doc/Makefile doc/conf.py doc/requirements.txt \
		html man \
		inc/*.h src/*.c src/*.h tools/*.c scripts/*.lisp bin/.gitkeep

serve_doc: doc
	cd html; python -m http.server --bind 0.0.0.0 8080

# Named differently from Makefile.dep to avoid implicit rules for inclusion.
depend: FORCE
	gcc $(CFLAGS) -MM src/*.c > Makefile.dep

tags:
	ctags src/*.c src/*.h inc/funlisp.h

include Makefile.dep