smflite

diff Makefile @ 0:4264abea8b06

smf-lite initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 26 Jan 2012 11:25:11 +0200
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Thu Jan 26 11:25:11 2012 +0200
     1.3 @@ -0,0 +1,61 @@
     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 +
    1.10 +name = smflite
    1.11 +lib_a = lib$(name).a
    1.12 +
    1.13 +ifeq ($(shell uname -s), Darwin)
    1.14 +	lib_so = $(name).dylib
    1.15 +	shared = -dynamiclib
    1.16 +else
    1.17 +	abi = 0
    1.18 +	rev = 0
    1.19 +	devlink = lib$(name).so
    1.20 +	soname = $(devlink).$(abi)
    1.21 +	lib_so = $(soname).$(rev)
    1.22 +	shared = -shared -Wl,-soname=$(soname)
    1.23 +	pic = -fPIC
    1.24 +endif
    1.25 +
    1.26 +CFLAGS = -pedantic -Wall -g $(pic)
    1.27 +
    1.28 +.PHONY: all
    1.29 +all: $(lib_a) $(lib_so)
    1.30 +
    1.31 +$(lib_so): $(obj)
    1.32 +	$(CC) $(shared) -o $@ $(obj) $(LDFLAGS)
    1.33 +
    1.34 +$(lib_a): $(obj)
    1.35 +	$(AR) rcs $@ $(obj)
    1.36 +
    1.37 +-include $(dep)
    1.38 +
    1.39 +%.d: %.c
    1.40 +	@$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
    1.41 +
    1.42 +.PHONY: clean
    1.43 +clean:
    1.44 +	rm -f $(obj) $(lib_so) $(lib_a)
    1.45 +
    1.46 +.PHONY: install
    1.47 +install: $(lib_so) $(lib_a)
    1.48 +	mkdir -p $(INSTDIR)$(PREFIX)/include $(INSTDIR)$(PREFIX)/lib
    1.49 +	cp src/smf.h $(INSTDIR)$(PREFIX)/include/smf.h
    1.50 +	cp $(lib_a) $(INSTDIR)$(PREFIX)/lib/$(lib_a)
    1.51 +	cp $(lib_so) $(INSTDIR)$(PREFIX)/lib/$(lib_so)
    1.52 +	[ -n "$(soname)" ] && \
    1.53 +		cd $(INSTDIR)$(PREFIX)/lib && \
    1.54 +		ln -s $(lib_so) $(soname) && \
    1.55 +		ln -s $(soname) $(devlink) || true
    1.56 +
    1.57 +.PHONY: uninstall
    1.58 +uninstall:
    1.59 +	rm -f $(INSTDIR)$(PREFIX)/include/smf.h
    1.60 +	rm -f $(INSTDIR)$(PREFIX)/lib/$(lib_a)
    1.61 +	rm -f $(INSTDIR)$(PREFIX)/lib/$(lib_so)
    1.62 +	[ -n "$(soname)" ] && \
    1.63 +		rm -f $(INSTDIR)$(PREFIX)/lib/$(soname) && \
    1.64 +		rm -f $(INSTDIR)$(PREFIX)/lib/$(devlink) || true