libresman

diff Makefile @ 0:61d7ff6da54b

initial commit: figuring out the API
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 29 Jan 2014 08:17:31 +0200
parents
children bd9b4ff19c93
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Wed Jan 29 08:17:31 2014 +0200
     1.3 @@ -0,0 +1,62 @@
     1.4 +# change this if you want to install elsewhere
     1.5 +PREFIX = /usr/local
     1.6 +
     1.7 +src = $(wildcard src/*.c)
     1.8 +obj = $(src:.c=.o)
     1.9 +dep = $(obj:.o=.d)
    1.10 +
    1.11 +name = resman
    1.12 +lib_a = lib$(name).a
    1.13 +
    1.14 +api_major = 0
    1.15 +api_minor = 1
    1.16 +
    1.17 +CFLAGS = -pedantic -Wall -g
    1.18 +
    1.19 +ifeq ($(shell uname -s), Darwin)
    1.20 +	lib_so = lib$(name).dylib
    1.21 +	shared = -dynamiclib
    1.22 +else
    1.23 +	devlink = lib$(name).so
    1.24 +	soname = lib$(name).so.$(api_major)
    1.25 +	lib_so = lib$(name).so.$(api_major).$(api_minor)
    1.26 +	shared = -shared -Wl,-soname,$(soname)
    1.27 +	pic = -fPIC
    1.28 +endif
    1.29 +
    1.30 +.PHONY: all
    1.31 +all: $(lib_so) $(lib_a)
    1.32 +
    1.33 +$(lib_so): $(obj)
    1.34 +	$(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
    1.35 +
    1.36 +$(lib_a): $(obj)
    1.37 +	$(AR) rcs $@ $(obj)
    1.38 +
    1.39 +-include $(dep)
    1.40 +
    1.41 +%.d: %.c
    1.42 +	@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
    1.43 +
    1.44 +.PHONY: clean
    1.45 +clean:
    1.46 +	rm -f $(obj) $(lib_so) $(lib_a)
    1.47 +
    1.48 +.PHONY: install
    1.49 +install: $(lib_a) $(lib_so)
    1.50 +	mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include
    1.51 +	cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
    1.52 +	cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
    1.53 +	[ -n "$(devlink)" ] \
    1.54 +		&& cd $(DESTDIR)$(PREFIX)/lib \
    1.55 +		&& rm -f $(soname) $(devlink) \
    1.56 +		&& ln -s $(lib_so) $(soname) \
    1.57 +		&& ln -s $(soname) $(devlink) \
    1.58 +		|| true
    1.59 +	cp src/resman.h $(DESTDIR)$(PREFIX)/include/resman.h
    1.60 +
    1.61 +.PHONY: uninstall
    1.62 +uninstall:
    1.63 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
    1.64 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
    1.65 +	rm -f $(DESTDIR)$(PREFIX)/include/resman.h