goat3d

view goatview/Makefile @ 92:ae6c5941faac

[goatview] makefile rules to create app bundle and dmg archive [goatview] creating multisampling context
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 18 May 2014 01:19:10 +0300
parents f92da4fa9a6d
children b43d33f3ba69
line source
1 PREFIX = /usr/local
3 src = $(wildcard src/*.cc)
4 csrc = $(wildcard src/*.c)
5 mochdr = src/goatview.h src/scenemodel.h
6 mocsrc = $(patsubst src/%.h,src/moc_%.cc,$(mochdr))
7 obj = $(sort $(csrc:.c=.o) $(src:.cc=.o) $(mocsrc:.cc=.o))
8 dep = $(obj:.o=.d)
9 bin = goatview
11 goat_root = ..
13 warn = -Wall
15 CFLAGS = $(warn) -g $(pic) -I$(goat_root)/src $(qtinc)
16 CXXFLAGS = -std=c++11 $(CFLAGS)
17 LDFLAGS = $(libgoat) $(libgl) $(qtlib) -lvmath -lanim
18 MOC = moc
20 qtinc = `pkg-config --cflags Qt5Gui Qt5Core Qt5OpenGL`
21 qtlib = `pkg-config --libs Qt5Gui Qt5Core Qt5OpenGL`
23 ifeq ($(shell uname -s), Darwin)
24 libgl = -framework OpenGL -framework GLUT -lGLEW
25 libgoat = $(goat_root)/libgoat3d.dylib
26 warn += -Wno-deprecated-declarations
27 bundle = $(bin).app
28 dmg = $(bin).dmg
29 else
30 pic = -fPIC
31 libgl = -lGL -lGLU -lglut -lGLEW
32 libgoat = $(goat_root)/libgoat3d.so.0.1
33 endif
35 ifeq ($(CC), gcc)
36 warn += -Wno-cpp
37 endif
38 ifneq ($(shell $(CC) --version | grep LLVM),)
39 CXXFLAGS += -stdlib=libc++
40 warn += '-Wno-\#warnings'
41 endif
43 $(bin): $(obj) $(libgoat)
44 $(CXX) -o $@ $(obj) $(LDFLAGS)
46 # rule for running moc on ui header files
47 moc_%.cc: %.h
48 $(MOC) -o $@ $<
50 -include $(dep)
52 %.d: %.c
53 @$(CPP) $(CFLAGS) $< -MM -MT $(@:.d=.o) >$@
55 %.d: %.cc
56 @$(CPP) $(CXXFLAGS) $< -MM -MT $(@:.d=.o) >$@
58 .PHONY: clean
59 clean:
60 rm -f $(obj) $(bin)
61 [ -n "$(bundle)" ] && rm -rf $(bundle) || true
62 [ -n "$(dmg)" ] && rm -rf $(dmg) || true
64 .PHONY: cleandep
65 cleandep:
66 rm -f $(dep)
68 .PHONY: install
69 install: $(bin)
70 cp $(bin) $(DESTDIR)$(PREFIX)/bin/$(bin)
72 .PHONY: uninstall
73 uninstall:
74 rm -f $(DESTDIR)$(PREFIX)/bin/$(bin)
76 .PHONY: echo
77 echo:
78 @echo $(var)=\"$($(var))\"
80 .PHONY: bundle
81 bundle: $(bundle)
83 .PHONY: dmg
84 dmg: $(dmg)
86 $(bundle): $(bin) $(libgoat)
87 rm -rf $(bundle)
88 mkdir -p $(bundle)/Contents/MacOS
89 mkdir -p $(bundle)/Contents/Frameworks
90 cp $(bin) $(bundle)/Contents/MacOS/$(bin)
91 macdeployqt $(bundle)
92 cp $(libgoat) $(bundle)/Contents/Frameworks
93 cp /usr/local/lib/libvmath.dylib $(bundle)/Contents/Frameworks
94 cp /usr/local/lib/libanim.dylib $(bundle)/Contents/Frameworks
96 $(dmg): $(bundle)
97 rm -f $@
98 hdiutil create -format UDBZ -quiet -srcfolder $< $@
100 .PHONY: run
101 ifeq ($(shell uname -s), Darwin)
102 run: $(bundle)
103 ./$(bundle)/Contents/MacOS/$(bin)
104 else
105 run: $(bin)
106 ./$(bin)
107 endif