libsysutils

annotate Makefile @ 1:c1323f9f202d

foo
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 05 May 2015 05:51:56 +0300
parents a8277d8f687a
children
rev   line source
nuclear@1 1 PREFIX ?= /usr/local
nuclear@1 2
nuclear@0 3 src = $(wildcard src/*.c)
nuclear@0 4 obj = $(src:.c=.o)
nuclear@0 5 name = sysutils
nuclear@0 6 lib_a = lib$(name).a
nuclear@0 7
nuclear@0 8 so_major = 0
nuclear@0 9 so_minor = 1
nuclear@0 10
nuclear@0 11 sys = $(shell uname -s | sed 's/MINGW32.*/Win32/')
nuclear@0 12
nuclear@0 13 ifeq ($(sys), Darwin)
nuclear@0 14 lib_so = lib$(name).dylib
nuclear@0 15 shared = -dynamiclib
nuclear@1 16 else ifeq ($(sys), Win32)
nuclear@0 17 lib_so = $(name).dll
nuclear@0 18 # TODO shared = ?
nuclear@0 19 else # any other unix
nuclear@0 20 ldname = lib$(name).so
nuclear@0 21 soname = lib$(name).so.$(so_major)
nuclear@0 22 lib_so = lib$(name).so.$(so_major).$(so_minor)
nuclear@0 23 shared = -shared -Wl,-soname=$(soname)
nuclear@0 24 pic = -fPIC
nuclear@0 25 endif
nuclear@0 26
nuclear@1 27 inc = -Iinclude -Isrc
nuclear@1 28
nuclear@1 29 CFLAGS = -pedantic -Wall -g $(pic) $(inc)
nuclear@1 30
nuclear@0 31 .PHONY: all
nuclear@0 32 all: $(lib_so) $(lib_a)
nuclear@0 33
nuclear@0 34 $(lib_a): $(obj)
nuclear@0 35 $(AR) rcs $@ $(obj)
nuclear@0 36
nuclear@0 37 $(lib_so): $(obj)
nuclear@1 38 $(CC) -o $@ $(shared) $(obj) $(LDFLAGS)
nuclear@0 39
nuclear@0 40 .PHONY: clean
nuclear@0 41 clean:
nuclear@0 42 rm -f $(obj) $(lib_a) $(lib_so)
nuclear@0 43
nuclear@0 44 .PHONY: install
nuclear@0 45 install: all
nuclear@0 46 mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib
nuclear@0 47 @echo 'add header files'
nuclear@0 48 cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a)
nuclear@0 49 cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so)
nuclear@0 50 [ -n "$(soname)" ] && \
nuclear@0 51 cd $(DESTDIR)$(PREFIX) && \
nuclear@0 52 rm -f $(soname) $(ldname) && \
nuclear@0 53 ln -s $(lib_so) $(soname) && \
nuclear@0 54 ln -s $(soname) $(ldname) || true
nuclear@0 55
nuclear@0 56 .PHONY: uninstall
nuclear@0 57 uninstall:
nuclear@0 58 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a)
nuclear@0 59 rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so)
nuclear@0 60 [ -n "$(soname)" ] && \
nuclear@0 61 rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \
nuclear@0 62 rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \
nuclear@0 63 true