nuclear@1: # installation prefix, change it to install elsewhere nuclear@1: PREFIX = /usr/local nuclear@1: # ----------------------------- nuclear@1: nuclear@0: src = $(wildcard src/*.c) nuclear@0: obj = $(src:.c=.o) nuclear@0: name = optcfg nuclear@0: nuclear@0: so_major = 0 nuclear@0: so_minor = 1 nuclear@0: nuclear@0: alib = lib$(name).a nuclear@0: nuclear@5: sodir = lib nuclear@5: nuclear@0: CFLAGS = -pedantic -Wall -g nuclear@0: nuclear@5: sys := $(shell uname -s | sed 's/MINGW.*/mingw/') nuclear@0: ifeq ($(sys), Darwin) nuclear@0: solib = lib$(name).dylib nuclear@0: shared = -dynamiclib nuclear@5: else ifeq ($(sys), mingw) nuclear@5: solib = lib$(name).dll nuclear@5: shared = -shared nuclear@5: sodir = bin nuclear@0: else nuclear@0: ldname = lib$(name).so nuclear@0: soname = lib$(name).so.$(so_major) nuclear@0: solib = lib$(name).so.$(so_major).$(so_minor) nuclear@0: shared = -shared -Wl,-soname=$(soname) nuclear@0: CFLAGS += -fPIC nuclear@0: endif nuclear@0: nuclear@0: .PHONY: all nuclear@0: all: $(solib) $(alib) nuclear@0: nuclear@0: $(solib): $(obj) nuclear@0: $(CC) -o $@ $(shared) $(obj) $(LDFLAGS) nuclear@0: nuclear@0: $(alib): $(obj) nuclear@0: $(AR) rcs $@ $(obj) nuclear@0: nuclear@0: .PHONY: clean nuclear@0: clean: nuclear@0: rm -f $(obj) $(alib) $(solib) nuclear@0: nuclear@0: .PHONY: install nuclear@0: install: nuclear@5: mkdir -p $(DESTDIR)$(PREFIX)/bin $(DESTDIR)$(PREFIX)/include $(DESTDIR)$(PREFIX)/lib nuclear@0: cp src/optcfg.h $(DESTDIR)$(PREFIX)/include/optcfg.h nuclear@0: cp $(alib) $(DESTDIR)$(PREFIX)/lib/$(alib) nuclear@5: cp $(solib) $(DESTDIR)$(PREFIX)/$(sodir)/$(solib) nuclear@5: [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/$(sodir) && \ nuclear@1: rm -f $(soname) $(ldname) && \ nuclear@0: ln -s $(solib) $(soname) && \ nuclear@0: ln -s $(soname) $(ldname) || true nuclear@0: nuclear@0: .PHONY: uninstall nuclear@0: uninstall: nuclear@0: rm -f $(DESTDIR)$(PREFIX)/include/optcfg.h nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(alib) nuclear@5: rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(solib) nuclear@0: [ -n "$(soname)" ] && \ nuclear@5: rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(soname) && \ nuclear@5: rm -f $(DESTDIR)$(PREFIX)/$(sodir)/$(ldname) || true