liboptcfg

diff Makefile @ 0:10b89befcaa9

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 13 Nov 2015 23:48:31 +0200
parents
children 8fd2858c6a29
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Fri Nov 13 23:48:31 2015 +0200
     1.3 @@ -0,0 +1,54 @@
     1.4 +src = $(wildcard src/*.c)
     1.5 +obj = $(src:.c=.o)
     1.6 +name = optcfg
     1.7 +
     1.8 +so_major = 0
     1.9 +so_minor = 1
    1.10 +
    1.11 +alib = lib$(name).a
    1.12 +
    1.13 +CFLAGS = -pedantic -Wall -g
    1.14 +
    1.15 +sys := $(shell uname -s)
    1.16 +ifeq ($(sys), Darwin)
    1.17 +	solib = lib$(name).dylib
    1.18 +	shared = -dynamiclib
    1.19 +else
    1.20 +	ldname = lib$(name).so
    1.21 +	soname = lib$(name).so.$(so_major)
    1.22 +	solib = lib$(name).so.$(so_major).$(so_minor)
    1.23 +	shared = -shared -Wl,-soname=$(soname)
    1.24 +	CFLAGS += -fPIC
    1.25 +endif
    1.26 +
    1.27 +.PHONY: all
    1.28 +all: $(solib) $(alib)
    1.29 +
    1.30 +$(solib): $(obj)
    1.31 +	$(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
    1.32 +
    1.33 +$(alib): $(obj)
    1.34 +	$(AR) rcs $@ $(obj)
    1.35 +
    1.36 +.PHONY: clean
    1.37 +clean:
    1.38 +	rm -f $(obj) $(alib) $(solib)
    1.39 +
    1.40 +.PHONY: install
    1.41 +install:
    1.42 +	mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
    1.43 +	cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h
    1.44 +	cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib)
    1.45 +	cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib)
    1.46 +	[ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/lib && \
    1.47 +		ln -s $(solib) $(soname) && \
    1.48 +		ln -s $(soname) $(ldname) || true
    1.49 +
    1.50 +.PHONY: uninstall
    1.51 +uninstall:
    1.52 +	rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h
    1.53 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(alib)
    1.54 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(solib)
    1.55 +	[ -n "$(soname)" ] && \
    1.56 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
    1.57 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || true