-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
107 lines (86 loc) · 2.74 KB
/
Makefile
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
# tisp - tiny lisp
# See LICENSE file for copyright and license details.
include config.mk
ifeq ($(DEBUG), 1)
CFLAGS += -g -Og
LDFLAGS += -g -Og
endif
EXE = tisp
SRC = tisp.c main.c
TIB = tib/math.c tib/io.c tib/os.c tib/string.c
OBJ = $(SRC:.c=.o) $(TIB:.c=.o)
LIB = $(TIB:.c=.so)
TSP = tib/core.tsp tib/doc.tsp tib/io.tsp tib/math.tsp tib/os.tsp
DOC = doc/tisp.1.md doc/tisp.7.md
MAN = $(DOC:.md=)
all: options $(EXE)
options:
@echo $(EXE) build options:
@echo "CFLAGS = $(CFLAGS)"
@echo "LDFLAGS = $(LDFLAGS)"
tibs.tsp.h: $(TSP)
@echo xxd $@
@echo "char tibs[] = { 0x28, " > $@
@cat $^ | xxd -i - >> $@
@echo ", 0x29, 0x00};" >> $@
.o:
@echo $(LD) $@
@$(LD) -o $@ $< $(LDFLAGS)
.c.o:
@echo $(CC) $<
@$(CC) -c -o $@ $< $(CFLAGS)
$(OBJ): config.mk
main.o: tibs.tsp.h
test.o: config.mk tibs.tsp.h
$(LIB): $(TIB)
@echo $(CC) -o $@
@$(CC) -shared -o $@ $(OBJ)
$(EXE): $(OBJ) $(LIB)
@echo $(CC) -o $@
@$(CC) -o $@ $(OBJ) $(LDFLAGS)
clean:
@echo cleaning
@rm -f $(OBJ) $(LIB) $(EXE) test test.o tibs.tsp.h
dist: tibs.tsp.h
@echo creating dist tarball
@mkdir -p tisp-$(VERSION)
@cp -R tisp.c tisp.h $(TIB) tibs.tsp.h tisp-$(VERSION)
@tar -cf tisp-$(VERSION).tar tisp-$(VERSION)
@gzip tisp-$(VERSION).tar
@rm -rf tisp-$(VERSION)
# TODO don't cp some if not in dynamic mode
install: all
@echo installing $(EXE) to $(DESTDIR)$(PREFIX)/bin
@mkdir -p $(DESTDIR)$(PREFIX)/bin
@cp -f $(EXE) $(DESTDIR)$(PREFIX)/bin
@chmod 755 $(DESTDIR)$(PREFIX)/bin/$(EXE)
@echo installing tsp to $(DESTDIR)$(PREFIX)/bin
@sed -e "s@\./@@g" < tsp > $(DESTDIR)$(PREFIX)/bin/tsp
@chmod 755 $(DESTDIR)$(PREFIX)/bin/tsp
@echo installing manual page to $(DESTDIR)$(MANPREFIX)/man1
@mkdir -p $(DESTDIR)$(MANPREFIX)/man1
@cp -f doc/$(EXE).1 $(DESTDIR)$(MANPREFIX)/man1/
@chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(EXE).1
@echo installing tibs to $(DESTDIR)$(PREFIX)/lib/tisp/pkgs/std
@mkdir -p $(DESTDIR)$(PREFIX)/lib/tisp/pkgs/std
@cp -f $(TSP) $(LIB) $(DESTDIR)$(PREFIX)/lib/tisp/pkgs/std
uninstall:
@echo removing $(EXE) from $(DESTDIR)$(PREFIX)/bin
@rm -f $(DESTDIR)$(PREFIX)/bin/$(EXE)
@echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1
@rm -f $(DESTDIR)$(MANPREFIX)/man1/$(EXE).1
@echo removing shared libraries from $(DESTDIR)$(PREFIX)/lib/tisp
@rm -rf $(DESTDIR)$(PREFIX)/lib/tisp/
@echo removing tisp libraries from $(DESTDIR)$(PREFIX)/share/tisp
@rm -rf $(DESTDIR)$(PREFIX)/share/tisp/
test: $(OBJ) $(LIB) test.o
@echo running tests
@echo $(CC) -o test
@$(CC) -o test tisp.o $(TIB:.c=.o) test.o $(LDFLAGS)
@./test
man: $(MAN)
$(MAN): $(DOC) $(EXE)
@echo updating man page $@
@markman -nCD -t TISP -V "$(EXE) $(VERSION)" -d "`date '+%B %Y'`" \
-s "`./$(EXE) -h 2>&1 | cut -d' ' -f2-`" [email protected] > $@
.PHONY: all options clean dist install uninstall test man