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@0: CFLAGS = -pedantic -Wall -g nuclear@0: nuclear@0: sys := $(shell uname -s) nuclear@0: ifeq ($(sys), Darwin) nuclear@0: solib = lib$(name).dylib nuclear@0: shared = -dynamiclib 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@0: mkdir -p $(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@0: cp $(solib) $(DESTDIR)$(PREFIX)/lib/$(solib) nuclear@0: [ -n "$(soname)" ] && cd $(DESTDIR)$(PREFIX)/lib && \ 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@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(solib) nuclear@0: [ -n "$(soname)" ] && \ nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ nuclear@0: rm -f $(DESTDIR)$(PREFIX)/lib/$(ldname) || true