nuclear@0: src = $(wildcard src/*.c) nuclear@0: obj = $(src:.c=.o) nuclear@0: name = sysutils nuclear@0: lib_a = lib$(name).a nuclear@0: nuclear@0: so_major = 0 nuclear@0: so_minor = 1 nuclear@0: nuclear@0: sys = $(shell uname -s | sed 's/MINGW32.*/Win32/') nuclear@0: nuclear@0: ifeq ($(sys), Darwin) nuclear@0: lib_so = lib$(name).dylib nuclear@0: shared = -dynamiclib nuclear@0: else ($(sys), Win32) nuclear@0: lib_so = $(name).dll nuclear@0: # TODO shared = ? nuclear@0: else # any other unix nuclear@0: ldname = lib$(name).so nuclear@0: soname = lib$(name).so.$(so_major) nuclear@0: lib_so = lib$(name).so.$(so_major).$(so_minor) nuclear@0: shared = -shared -Wl,-soname=$(soname) nuclear@0: pic = -fPIC nuclear@0: endif nuclear@0: nuclear@0: .PHONY: all nuclear@0: all: $(lib_so) $(lib_a) nuclear@0: nuclear@0: $(lib_a): $(obj) nuclear@0: $(AR) rcs $@ $(obj) nuclear@0: nuclear@0: $(lib_so): $(obj) nuclear@0: $(CC) -o $@ $(obj) $(LDFLAGS) nuclear@0: nuclear@0: .PHONY: clean nuclear@0: clean: nuclear@0: rm -f $(obj) $(lib_a) $(lib_so) nuclear@0: nuclear@0: .PHONY: install nuclear@0: install: all nuclear@0: mkdir -p $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib nuclear@0: @echo 'add header files' nuclear@0: cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a) nuclear@0: cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) nuclear@0: [ -n "$(soname)" ] && \ nuclear@0: cd $(DESTDIR)$(PREFIX) && \ nuclear@0: rm -f $(soname) $(ldname) && \ nuclear@0: ln -s $(lib_so) $(soname) && \ nuclear@0: ln -s $(soname) $(ldname) || true nuclear@0: nuclear@0: .PHONY: uninstall nuclear@0: uninstall: nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a) nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) nuclear@0: [ -n "$(soname)" ] && \ nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || \ nuclear@0: true