tinywebd

annotate 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
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@15 33 rm -f $(soname) $(ldname) && \
nuclear@10 34 ln -s $(solib) $(soname) && \
nuclear@10 35 ln -s $(soname) $(ldname) || true
nuclear@10 36
nuclear@10 37 $(alib): $(obj)
nuclear@10 38 $(AR) rcs $@ $(obj)
nuclear@10 39
nuclear@10 40 -include $(dep)
nuclear@10 41
nuclear@10 42 %.d: %.c
nuclear@10 43 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
nuclear@10 44
nuclear@10 45 .PHONY: clean
nuclear@10 46 clean:
nuclear@10 47 rm -f $(obj) $(alib) $(solib)
nuclear@10 48
nuclear@10 49 .PHONY: cleandep
nuclear@10 50 cleandep:
nuclear@10 51 rm -f $(dep)
nuclear@10 52
nuclear@10 53 .PHONY: install
nuclear@10 54 install: $(alib) $(solib)
nuclear@10 55 mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
nuclear@10 56 cp src/tinyweb.h $(DESTDIR)$(PREFIX)/include/tinyweb.h
nuclear@10 57 cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
nuclear@10 58 cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
nuclear@10 59 [ -n "$(soname)" ] && \
nuclear@10 60 cd $(DESTDIR)$(PREFIX)/lib && \
nuclear@15 61 rm -f $(soname) $(ldname) && \
nuclear@10 62 ln -s $(solib) $(soname) && \
nuclear@10 63 ln -s $(soname) $(ldname) || \
nuclear@10 64 true
nuclear@10 65
nuclear@10 66 .PHONY: uninstall
nuclear@10 67 uninstall:
nuclear@10 68 rm -f $(DESTDIR)$(PREFIX)/include/tinyweb.h
nuclear@10 69 rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
nuclear@10 70 rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
nuclear@10 71 [ -n "$(soname)" ] && \
nuclear@10 72 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
nuclear@10 73 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
nuclear@10 74 true
nuclear@10 75