tinywebd

annotate libtinyweb/Makefile @ 10:0dd50a23f3dd

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