tinywebd

diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/libtinyweb/Makefile	Sat Apr 18 22:47:57 2015 +0300
     1.3 @@ -0,0 +1,73 @@
     1.4 +PREFIX ?= /usr/local
     1.5 +
     1.6 +src = $(wildcard src/*.c)
     1.7 +obj = $(src:.c=.o)
     1.8 +dep = $(obj:.o=.d)
     1.9 +name = tinyweb
    1.10 +
    1.11 +CFLAGS = -pedantic -Wall -g $(pic)
    1.12 +
    1.13 +sys = $(shell uname -s)
    1.14 +
    1.15 +so_major = 0
    1.16 +so_minor = 1
    1.17 +alib = lib$(name).a
    1.18 +
    1.19 +ifeq ($(sys), Darwin)
    1.20 +	solib = lib$(name).dylib
    1.21 +	shared = -dynamiclib
    1.22 +else
    1.23 +	ldname = lib$(name).so
    1.24 +	soname = lib$(name).so.$(so_major)
    1.25 +	solib = lib$(name).so.$(so_major).$(so_minor)
    1.26 +	shared = -shared -Wl,-soname=$(soname)
    1.27 +	pic = -fPIC
    1.28 +endif
    1.29 +
    1.30 +.PHONY: all
    1.31 +all: $(alib) $(solib)
    1.32 +
    1.33 +$(solib): $(obj)
    1.34 +	$(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
    1.35 +	[ -n "$(soname)" ] && \
    1.36 +		ln -s $(solib) $(soname) && \
    1.37 +		ln -s $(soname) $(ldname) || true
    1.38 +
    1.39 +$(alib): $(obj)
    1.40 +	$(AR) rcs $@ $(obj)
    1.41 +
    1.42 +-include $(dep)
    1.43 +
    1.44 +%.d: %.c
    1.45 +	@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
    1.46 +
    1.47 +.PHONY: clean
    1.48 +clean:
    1.49 +	rm -f $(obj) $(alib) $(solib)
    1.50 +
    1.51 +.PHONY: cleandep
    1.52 +cleandep:
    1.53 +	rm -f $(dep)
    1.54 +
    1.55 +.PHONY: install
    1.56 +install: $(alib) $(solib)
    1.57 +	mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
    1.58 +	cp src/tinyweb.h $(DESTDIR)$(PREFIX)/include/tinyweb.h
    1.59 +	cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
    1.60 +	cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
    1.61 +	[ -n "$(soname)" ] && \
    1.62 +		cd $(DESTDIR)$(PREFIX)/lib && \
    1.63 +		ln -s $(solib) $(soname) && \
    1.64 +		ln -s $(soname) $(ldname) || \
    1.65 +		true
    1.66 +
    1.67 +.PHONY: uninstall
    1.68 +uninstall:
    1.69 +	rm -f $(DESTDIR)$(PREFIX)/include/tinyweb.h
    1.70 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
    1.71 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
    1.72 +	[ -n "$(soname)" ] && \
    1.73 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
    1.74 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
    1.75 +		true
    1.76 +