libsysutils

diff Makefile @ 0:a8277d8f687a

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 19 Feb 2015 01:33:54 +0200
parents
children c1323f9f202d
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Makefile	Thu Feb 19 01:33:54 2015 +0200
     1.3 @@ -0,0 +1,57 @@
     1.4 +src = $(wildcard src/*.c)
     1.5 +obj = $(src:.c=.o)
     1.6 +name = sysutils
     1.7 +lib_a = lib$(name).a
     1.8 +
     1.9 +so_major = 0
    1.10 +so_minor = 1
    1.11 +
    1.12 +sys = $(shell uname -s | sed 's/MINGW32.*/Win32/')
    1.13 +
    1.14 +ifeq ($(sys), Darwin)
    1.15 +	lib_so = lib$(name).dylib
    1.16 +	shared = -dynamiclib
    1.17 +else ($(sys), Win32)
    1.18 +	lib_so = $(name).dll
    1.19 +	# TODO shared = ?
    1.20 +else # any other unix
    1.21 +	ldname = lib$(name).so
    1.22 +	soname = lib$(name).so.$(so_major)
    1.23 +	lib_so = lib$(name).so.$(so_major).$(so_minor)
    1.24 +	shared = -shared -Wl,-soname=$(soname)
    1.25 +	pic = -fPIC
    1.26 +endif
    1.27 +
    1.28 +.PHONY: all
    1.29 +all: $(lib_so) $(lib_a)
    1.30 +
    1.31 +$(lib_a): $(obj)
    1.32 +	$(AR) rcs $@ $(obj)
    1.33 +
    1.34 +$(lib_so): $(obj)
    1.35 +	$(CC) -o $@ $(obj) $(LDFLAGS)
    1.36 +
    1.37 +.PHONY: clean
    1.38 +clean:
    1.39 +	rm -f $(obj) $(lib_a) $(lib_so)
    1.40 +
    1.41 +.PHONY: install
    1.42 +install: all
    1.43 +	mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
    1.44 +	@echo 'add header files'
    1.45 +	cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
    1.46 +	cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
    1.47 +	[ -n "$(soname)" ] && \
    1.48 +		cd $(DESTDIR)$(PREFIX) && \
    1.49 +		rm -f $(soname) $(ldname) && \
    1.50 +		ln -s $(lib_so) $(soname) && \
    1.51 +		ln -s $(soname) $(ldname) || true
    1.52 +
    1.53 +.PHONY: uninstall
    1.54 +uninstall:
    1.55 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
    1.56 +	rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
    1.57 +	[ -n "$(soname)" ] && \
    1.58 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
    1.59 +		rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
    1.60 +		true