tisp

tiny lisp
git clone git://edryd.org/tisp
Log | Files | Refs | README | LICENSE

Makefile (2961B)


      1 # tisp - tiny lisp
      2 # See LICENSE file for copyright and license details.
      3 
      4 include config.mk
      5 
      6 ifeq ($(DEBUG), 1)
      7 CFLAGS += -g -Og
      8 LDFLAGS += -g -Og
      9 endif
     10 
     11 EXE = tisp
     12 SRC = tisp.c main.c
     13 TIB = tib/math.c tib/io.c tib/os.c tib/string.c
     14 OBJ = $(SRC:.c=.o) $(TIB:.c=.o)
     15 LIB = tib/libtibmath.so tib/libtibio.so
     16 TSP = tib/core.tsp tib/doc.tsp tib/io.tsp tib/math.tsp tib/os.tsp
     17 DOC = doc/tisp.1.md doc/tisp.7.md
     18 MAN = $(DOC:.md=)
     19 
     20 all: options $(EXE)
     21 
     22 options:
     23 	@echo $(EXE) build options:
     24 	@echo "CFLAGS  = $(CFLAGS)"
     25 	@echo "LDFLAGS = $(LDFLAGS)"
     26 
     27 tibs.tsp.h: $(TSP)
     28 	@echo xxd $@
     29 	@echo "char tibs[] = { 0x28, " > $@
     30 	@cat $^ | xxd -i - >> $@
     31 	@echo ", 0x29, 0x00};" >> $@
     32 
     33 .o:
     34 	@echo $(LD) $@
     35 	@$(LD) -o $@ $< $(LDFLAGS)
     36 
     37 .c.o:
     38 	@echo $(CC) $<
     39 	@$(CC) -c -o $@ $< $(CFLAGS)
     40 
     41 $(OBJ): config.mk
     42 
     43 main.o: tibs.tsp.h
     44 
     45 test.o: config.mk tibs.tsp.h
     46 
     47 $(LIB): $(TIB)
     48 	@echo $(CC) -o $@
     49 	@$(CC) -shared -o $@ $(OBJ)
     50 
     51 $(EXE): $(OBJ) $(LIB)
     52 	@echo $(CC) -o $@
     53 	@$(CC) -o $@ $(OBJ) $(LDFLAGS)
     54 
     55 clean:
     56 	@echo cleaning
     57 	@rm -f $(OBJ) $(LIB) $(EXE) test test.o tibs.tsp.h
     58 
     59 dist: tibs.tsp.h
     60 	@echo creating dist tarball
     61 	@mkdir -p tisp-$(VERSION)
     62 	@cp -R tisp.c tisp.h $(TIB) tibs.tsp.h tisp-$(VERSION)
     63 	@tar -cf tisp-$(VERSION).tar tisp-$(VERSION)
     64 	@gzip tisp-$(VERSION).tar
     65 	@rm -rf tisp-$(VERSION)
     66 
     67 # TODO don't cp some if not in dynamic mode
     68 install: all
     69 	@echo installing $(EXE) to $(DESTDIR)$(PREFIX)/bin
     70 	@mkdir -p $(DESTDIR)$(PREFIX)/bin
     71 	@cp -f $(EXE) $(DESTDIR)$(PREFIX)/bin
     72 	@chmod 755 $(DESTDIR)$(PREFIX)/bin/$(EXE)
     73 	@echo installing tsp to $(DESTDIR)$(PREFIX)/bin
     74 	@sed -e "s@\./@@g" < tsp > $(DESTDIR)$(PREFIX)/bin/tsp
     75 	@chmod 755 $(DESTDIR)$(PREFIX)/bin/tsp
     76 	@echo installing manual page to $(DESTDIR)$(MANPREFIX)/man1
     77 	@mkdir -p $(DESTDIR)$(MANPREFIX)/man1
     78 	@cp -f doc/$(EXE).1 $(DESTDIR)$(MANPREFIX)/man1/
     79 	@chmod 644 $(DESTDIR)$(MANPREFIX)/man1/$(EXE).1
     80 	@echo installing shared libraries to $(DESTDIR)$(PREFIX)/lib/tisp
     81 	@mkdir -p $(DESTDIR)$(PREFIX)/lib/tisp
     82 	@cp -f $(LIB) $(DESTDIR)$(PREFIX)/lib/tisp
     83 	@echo installing tisp libraries to $(DESTDIR)$(PREFIX)/share/tisp
     84 	@mkdir -p $(DESTDIR)$(PREFIX)/share/tisp
     85 	@cp -f $(TSP) $(DESTDIR)$(PREFIX)/share/tisp
     86 
     87 uninstall:
     88 	@echo removing $(EXE) from $(DESTDIR)$(PREFIX)/bin
     89 	@rm -f $(DESTDIR)$(PREFIX)/bin/$(EXE)
     90 	@echo removing manual page from $(DESTDIR)$(MANPREFIX)/man1
     91 	@rm -f $(DESTDIR)$(MANPREFIX)/man1/$(EXE).1
     92 	@echo removing shared libraries from $(DESTDIR)$(PREFIX)/lib/tisp
     93 	@rm -rf $(DESTDIR)$(PREFIX)/lib/tisp/
     94 	@echo removing tisp libraries from $(DESTDIR)$(PREFIX)/share/tisp
     95 	@rm -rf $(DESTDIR)$(PREFIX)/share/tisp/
     96 
     97 test: $(OBJ) $(LIB) test.o
     98 	@echo running tests
     99 	@echo $(CC) -o test
    100 	@$(CC) -o test tisp.o $(TIB:.c=.o) test.o $(LDFLAGS)
    101 	@./test
    102 
    103 man: $(MAN)
    104 
    105 $(MAN): $(DOC) $(EXE)
    106 	@echo updating man page $@
    107 	@markman -nCD -t TISP -V "$(EXE) $(VERSION)" -d "`date '+%B %Y'`" \
    108 		-s "`./$(EXE) -h 2>&1 | cut -d' ' -f2-`" $@.md > $@
    109 
    110 .PHONY: all options clean dist install uninstall test man