nuclear@10: PREFIX = /usr/local nuclear@10: nuclear@0: src = $(wildcard src/*.c) nuclear@0: obj = $(src:.c=.o) nuclear@0: dep = $(obj:.o=.d) nuclear@0: nuclear@13: lib_a = libdsys.a nuclear@13: soname = libdsys.so.$(somajor) nuclear@13: lib_so = $(lib_so_$(sys)) nuclear@13: nuclear@13: somajor = 0 nuclear@13: sominor = 0 nuclear@13: nuclear@13: lib_so_unix = $(soname).$(sominor) nuclear@13: lib_so_mac = libdsys.dylib nuclear@13: nuclear@13: sharedopt_unix = -shared -Wl,-soname,$(soname) nuclear@13: sharedopt_mac = -dynamiclib nuclear@13: nuclear@13: ifeq ($(shell uname -s), Darwin) nuclear@13: sys = mac nuclear@13: else nuclear@13: sys = unix nuclear@13: endif nuclear@13: nuclear@0: nuclear@0: CC = gcc nuclear@0: AR = ar nuclear@13: CFLAGS = -pedantic -Wall -g -Isrc -fPIC nuclear@2: nuclear@5: ifeq ($(shell uname -s), Darwin) nuclear@5: libgl = -framework OpenGL -framework GLUT nuclear@5: else nuclear@5: libgl = -lGL -lGLU -lglut nuclear@5: endif nuclear@5: nuclear@13: test: test.o $(lib_a) $(lib_so) nuclear@5: $(CC) $(CFLAGS) -o $@ test.o $(lib_a) $(libgl) -lm nuclear@0: nuclear@0: $(lib_a): $(obj) nuclear@0: $(AR) rcs $@ $(obj) nuclear@0: nuclear@13: $(lib_so): $(obj) nuclear@13: $(CC) $(sharedopt_$(sys)) -o $@ $(obj) $(LDFLAGS) nuclear@13: nuclear@0: -include $(dep) nuclear@0: nuclear@0: %.d: %.c nuclear@0: @$(CPP) $(CFLAGS) -MM -MT $(@:.d=.o) $< >$@ nuclear@0: nuclear@0: .PHONY: clean nuclear@0: clean: nuclear@13: rm -f $(obj) $(bin) $(lib_a) $(lib_so) nuclear@0: nuclear@0: .PHONY: cleandep nuclear@0: cleandep: nuclear@0: rm -f $(dep) nuclear@10: nuclear@10: .PHONY: install nuclear@11: install: $(lib_a) nuclear@10: mkdir -p $(PREFIX)/include $(PREFIX)/lib nuclear@10: cp $(lib_a) $(PREFIX)/lib/$(lib_a) nuclear@13: cp $(lib_so) $(PREFIX)/lib/$(lib_so) nuclear@13: cp src/dsys.h $(PREFIX)/include/dsys.h nuclear@10: nuclear@10: .PHONY: uninstall nuclear@10: uninstall: nuclear@13: rm -f $(PREFIX)/include/dsys.h $(PREFIX)/lib/$(lib_a) $(PREFIX)/lib/$(lib_so)