tinywebd
view libtinyweb/Makefile @ 15:4a25751fe61d
fixed the makefiles
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 19 Apr 2015 04:18:08 +0300 |
parents | 0dd50a23f3dd |
children |
line source
1 PREFIX ?= /usr/local
3 src = $(wildcard src/*.c)
4 obj = $(src:.c=.o)
5 dep = $(obj:.o=.d)
6 name = tinyweb
8 CFLAGS = -pedantic -Wall -g $(pic)
10 sys = $(shell uname -s)
12 so_major = 0
13 so_minor = 1
14 alib = lib$(name).a
16 ifeq ($(sys), Darwin)
17 solib = lib$(name).dylib
18 shared = -dynamiclib
19 else
20 ldname = lib$(name).so
21 soname = lib$(name).so.$(so_major)
22 solib = lib$(name).so.$(so_major).$(so_minor)
23 shared = -shared -Wl,-soname=$(soname)
24 pic = -fPIC
25 endif
27 .PHONY: all
28 all: $(alib) $(solib)
30 $(solib): $(obj)
31 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
32 [ -n "$(soname)" ] && \
33 rm -f $(soname) $(ldname) && \
34 ln -s $(solib) $(soname) && \
35 ln -s $(soname) $(ldname) || true
37 $(alib): $(obj)
38 $(AR) rcs $@ $(obj)
40 -include $(dep)
42 %.d: %.c
43 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
45 .PHONY: clean
46 clean:
47 rm -f $(obj) $(alib) $(solib)
49 .PHONY: cleandep
50 cleandep:
51 rm -f $(dep)
53 .PHONY: install
54 install: $(alib) $(solib)
55 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
56 cp src/tinyweb.h $(DESTDIR)$(PREFIX)/include/tinyweb.h
57 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
58 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
59 [ -n "$(soname)" ] && \
60 cd $(DESTDIR)$(PREFIX)/lib && \
61 rm -f $(soname) $(ldname) && \
62 ln -s $(solib) $(soname) && \
63 ln -s $(soname) $(ldname) || \
64 true
66 .PHONY: uninstall
67 uninstall:
68 rm -f $(DESTDIR)$(PREFIX)/include/tinyweb.h
69 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
70 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
71 [ -n "$(soname)" ] && \
72 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
73 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
74 true