tinywebd

view libtinyweb/Makefile @ 13:a9ed0b2260ee

reworded the readme slightly
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 19 Apr 2015 00:10:13 +0300
parents
children 4a25751fe61d
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 ln -s $(solib) $(soname) && \
34 ln -s $(soname) $(ldname) || true
36 $(alib): $(obj)
37 $(AR) rcs $@ $(obj)
39 -include $(dep)
41 %.d: %.c
42 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
44 .PHONY: clean
45 clean:
46 rm -f $(obj) $(alib) $(solib)
48 .PHONY: cleandep
49 cleandep:
50 rm -f $(dep)
52 .PHONY: install
53 install: $(alib) $(solib)
54 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
55 cp src/tinyweb.h $(DESTDIR)$(PREFIX)/include/tinyweb.h
56 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
57 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
58 [ -n "$(soname)" ] && \
59 cd $(DESTDIR)$(PREFIX)/lib && \
60 ln -s $(solib) $(soname) && \
61 ln -s $(soname) $(ldname) || \
62 true
64 .PHONY: uninstall
65 uninstall:
66 rm -f $(DESTDIR)$(PREFIX)/include/tinyweb.h
67 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
68 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
69 [ -n "$(soname)" ] && \
70 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
71 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
72 true