goat3dgfx
diff Makefile @ 0:1873dfd13f2d
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 14 Nov 2013 05:27:09 +0200 |
parents | |
children | 98f87a1dbb2f |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/Makefile Thu Nov 14 05:27:09 2013 +0200 1.3 @@ -0,0 +1,80 @@ 1.4 +PREFIX = /usr/local 1.5 + 1.6 +csrc = $(wildcard src/*.c) 1.7 +ccsrc = $(wildcard src/*.cc) 1.8 +obj = $(csrc:.c=.o) $(ccsrc:.cc=.o) 1.9 +dep = $(obj:.o=.d) 1.10 +name = goat3dgfx 1.11 +lib_a = lib$(name).a 1.12 + 1.13 +so_major = 0 1.14 +so_minor = 1 1.15 + 1.16 +ifeq ($(shell uname -r), Darwin) 1.17 + libgl = -framework OpenGL -framework GLUT -lGLEW 1.18 + 1.19 + lib_so = lib$(name).dylib 1.20 + shared = -dynamiclib 1.21 +else 1.22 + libgl = -lGL -lGLU -lglut -lGLEW 1.23 + 1.24 + lib_so = lib$(name).so.$(so_major).$(so_minor) 1.25 + soname = lib$(name).so.$(so_major) 1.26 + devlink = lib$(name).so 1.27 + shared = -shared -Wl,-soname=$(soname) 1.28 + pic = -fPIC 1.29 +endif 1.30 + 1.31 + 1.32 +CFLAGS = -pedantic $(warn) $(dbg) $(pic) $(opt) $(inc) $(libs_cflags) 1.33 +CXXFLAGS = $(CFLAGS) 1.34 +LDFLAGS = $(libgl) $(libs_ldflags) 1.35 + 1.36 +.PHONY: all 1.37 +all: $(lib_so) $(lib_a) 1.38 + 1.39 +$(lib_a): $(obj) 1.40 + $(AR) rcs $@ $(obj) 1.41 + 1.42 +$(lib_so): $(obj) 1.43 + $(CXX) $(shared) -o $@ $(obj) $(LDFLAGS) 1.44 + 1.45 +-include $(dep) 1.46 + 1.47 +%.d: %.c 1.48 + @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@ 1.49 + 1.50 +%.d: %.cc 1.51 + @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@ 1.52 + 1.53 +.PHONY: clean 1.54 +clean: 1.55 + rm -f $(obj) $(lib_a) $(lib_so) 1.56 + 1.57 +.PHONY: cleandep 1.58 +cleandep: 1.59 + rm -f $(dep) 1.60 + 1.61 +.PHONY: install 1.62 +install: $(lib_so) $(lib_a) 1.63 + mkdir -p $(DESTDIR)$(PREFIX)/lib $(DESTDIR)$(PREFIX)/include/goat3dgfx 1.64 + cp src/*.h src/*.inl $(DESTDIR)$(PREFIX)/include/goat3dgfx/ 1.65 + cp $(lib_a) $(DESTDIR)$(PREFIX)/lib/$(lib_a) 1.66 + cp $(lib_so) $(DESTDIR)$(PREFIX)/lib/$(lib_so) 1.67 + [ -n "$(devlink)" ] && \ 1.68 + cd $(DESTDIR)$(PREFIX)/lib && \ 1.69 + rm -f $(soname) $(devlink) && \ 1.70 + ln -s $(lib_so) $(soname) && \ 1.71 + ln -s $(soname) $(devlink) || \ 1.72 + true 1.73 + 1.74 +.PHONY: uninstall 1.75 +uninstall: 1.76 + rm -f $(DESTDIR)$(PREFIX)/include/goat3dgfx/* 1.77 + rmdir $(DESTDIR)$(PREFIX)/include/goat3dgfx 1.78 + rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_so) 1.79 + rm -f $(DESTDIR)$(PREFIX)/lib/$(lib_a) 1.80 + [ -n "$(devlink)" ] && \ 1.81 + rm -f $(DESTDIR)$(PREFIX)/lib/$(soname) && \ 1.82 + rm -f $(DESTDIR)$(PREFIX)/lib/$(devlink) || \ 1.83 + true