| |
1 # |
| |
2 # libtu Makefile |
| |
3 # |
| |
4 |
| |
5 # Where to install? ($PREFIX/lib/libtu.a, $PREFIX/include/libtu/) |
| |
6 # |
| |
7 PREFIX=/usr/local |
| |
8 |
| |
9 # Any extra defines needed |
| |
10 # |
| |
11 #DEFINES= |
| |
12 |
| |
13 # Any extra include paths needed |
| |
14 # |
| |
15 #INCLUDES= |
| |
16 |
| |
17 ###################################### |
| |
18 |
| |
19 WARN= -W -Wimplicit -Wreturn-type -Wswitch -Wcomment \ |
| |
20 -Wtrigraphs -Wformat -Wchar-subscripts -Wuninitialized \ |
| |
21 -Wparentheses -pedantic-errors |
| |
22 |
| |
23 CC_FLAGS=-g -O2 -ansi $(DEFINES) $(INCLUDES) $(WARN) |
| |
24 CC=gcc |
| |
25 AR=ar |
| |
26 AR_FLAGS=crs |
| |
27 |
| |
28 INSTALL=install |
| |
29 MODE=644 |
| |
30 |
| |
31 ###################################### |
| |
32 |
| |
33 OBJS= misc.o output.o util.o optparser.o parser.o tokenizer.o |
| |
34 |
| |
35 DEPEND= .depend |
| |
36 |
| |
37 LIBDIR=$(PREFIX)/lib |
| |
38 INCDIR=$(PREFIX)/include/libtu |
| |
39 |
| |
40 TARGETS=libtu.a |
| |
41 TESTERS=tester tester2 tester3 |
| |
42 |
| |
43 ###################################### |
| |
44 |
| |
45 all: $(TARGETS) |
| |
46 |
| |
47 testers: $(TESTERS) |
| |
48 |
| |
49 libtu.a: $(OBJS) |
| |
50 $(AR) $(AR_FLAGS) $@ $+ |
| |
51 |
| |
52 %: %.c |
| |
53 $(CC) $(CC_FLAGS) $+ -L. -ltu -lm -o $@ |
| |
54 |
| |
55 %.o: %.c |
| |
56 $(CC) $(CC_FLAGS) -c $< -o $@ |
| |
57 |
| |
58 clean: |
| |
59 rm -f $(OBJS) $(DEPEND) |
| |
60 |
| |
61 realclean: clean |
| |
62 rm -f $(TARGETS) |
| |
63 |
| |
64 depend: |
| |
65 $(CC) -M $(CC_FLAGS) *.c > $(DEPEND) |
| |
66 |
| |
67 install: |
| |
68 $(INSTALL) -d $(LIBDIR) |
| |
69 $(INSTALL) -d $(INCDIR) |
| |
70 $(INSTALL) -m $(MODE) libtu.a $(LIBDIR) |
| |
71 $(INSTALL) -m $(MODE) include/* $(INCDIR) |
| |
72 |
| |
73 ifeq ($(DEPEND),$(wildcard $(DEPEND))) |
| |
74 include $(DEPEND) |
| |
75 endif |