-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
218 lines (177 loc) · 6.82 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
# openFrameworks universal makefile
#
# make help : shows this message
# make Debug: makes the application with debug symbols
# make Release: makes the app with optimizations
# make: the same as make Release
# make CleanDebug: cleans the Debug target
# make CleanRelease: cleans the Release target
# make clean: cleans everything
#
#
# this should work with any OF app, just copy any example
# change the name of the folder and it should compile
# only .cpp support, don't use .c files
# it will look for files in any folder inside the application
# folder except that in the EXCLUDE_FROM_SOURCE variable
# but you'll need to add the include paths in USER_CFLAGS
#
# to add addons to your application, edit the addons.make file
# in this directory and add the names of the addons you want to
# include
#
# edit the following vars to customize the makefile
COMPILER_OPTIMIZATION = -march=core2 -O3
EXCLUDE_FROM_SOURCE="bin\|.xcodeproj\|obj"
USER_CFLAGS =
USER_LD_FLAGS =
USER_LIBS =
# you shouldn't modify anything below this line
SHELL = /bin/sh
CXX = g++
ARCH = $(shell uname -m)
ifeq ($(ARCH),x86_64)
LIBSPATH=linux64
else
LIBSPATH=linux
endif
NODEPS = clean
SOURCE_DIRS = $(shell find . -maxdepth 1 -mindepth 1 -type d | grep -v $(EXCLUDE_FROM_SOURCE) | sed s/.\\///)
SOURCES = $(shell find $(SOURCE_DIRS) -name "*.cpp")
OBJFILES = $(patsubst %.cpp,%.o,$(SOURCES))
APPNAME = $(shell basename `pwd`)
CORE_INCLUDES = $(shell find ../../../libs/openFrameworks/ -type d)
CORE_INCLUDE_FLAGS = $(addprefix -I,$(CORE_INCLUDES))
INCLUDES = $(shell find ../../../libs/*/include -type d)
INCLUDES_FLAGS = $(addprefix -I,$(INCLUDES))
LIB_STATIC = $(shell ls ../../../libs/*/lib/$(LIBSPATH)/*.a | grep -v openFrameworksCompiled)
LIB_SHARED = $(shell ls ../../../libs/*/lib/$(LIBSPATH)/*.so | grep -v openFrameworksCompiled)
LIB_PATHS_FLAGS = -L../../../libs/openFrameworksCompiled/lib/$(LIBSPATH)
CFLAGS = -Wall -fexceptions
CFLAGS += -I.
CFLAGS += $(INCLUDES_FLAGS)
CFLAGS += $(CORE_INCLUDE_FLAGS)
CFLAGS +=`pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --cflags`
LDFLAGS = $(LIB_PATHS_FLAGS) -s
LIBS = $(LIB_SHARED)
LIBS += $(LIB_STATIC)
LIBS +=`pkg-config gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --libs`
LIBS += -lglut -lGL -lasound
ifeq ($(findstring addons.make,$(wildcard *.make)),addons.make)
ADDONS_INCLUDES = $(shell find ../../../addons/*/src/ -type d)
ADDONS_INCLUDES += $(shell find ../../../addons/*/libs/ -type d)
ADDONSCFLAGS = $(addprefix -I,$(ADDONS_INCLUDES))
ADDONS_LIBS_STATICS = $(shell ls ../../../addons/*/libs/*/lib/$(LIBSPATH)/*.a)
ADDONS_LIBS_SHARED = $(shell ls ../../../addons/*/libs/*/lib/$(LIBSPATH)/*.so)
ADDONSLIBS = $(ADDONS_LIBS_STATICS)
ADDONSLIBS += $(ADDONS_LIBS_SHARED)
ADDONS = $(shell cat addons.make)
ADDONS_REL_DIRS = $(addsuffix /src, $(ADDONS))
ADDONS_LIBS_REL_DIRS = $(addsuffix /libs, $(ADDONS))
ADDONS_DIRS = $(addprefix ../../../addons/, $(ADDONS_REL_DIRS) )
ADDONS_LIBS_DIRS = $(addprefix ../../../addons/, $(ADDONS_LIBS_REL_DIRS) )
ADDONS_SOURCES = $(shell find $(ADDONS_DIRS) -name "*.cpp")
ADDONS_SOURCES += $(shell find $(ADDONS_LIBS_DIRS) -name "*.cpp" 2>/dev/null)
ADDONS_OBJFILES = $(subst ../../../, ,$(patsubst %.cpp,%.o,$(ADDONS_SOURCES)))
endif
ifeq ($(findstring Debug,$(MAKECMDGOALS)),Debug)
TARGET_CFLAGS = -g
TARGET_LIBS = -lopenFrameworksDebug
OBJ_OUTPUT = obj/Debug/
SED_OUTPUT = obj\\/Debug\\/
TARGET_NAME = Debug
TARGET = bin/$(APPNAME)_debug
CLEANTARGET = CleanDebug
endif
ifeq ($(findstring Release,$(MAKECMDGOALS)),Release)
TARGET_CFLAGS = $(COMPILER_OPTIMIZATION)
TARGET_LIBS = -lopenFrameworks
OBJ_OUTPUT = obj/Release/
SED_OUTPUT = obj\\/Release\\/
TARGET_NAME = Release
TARGET = bin/$(APPNAME)
CLEANTARGET = CleanRelease
endif
ifeq ($(MAKECMDGOALS),)
TARGET_CFLAGS = $(COMPILER_OPTIMIZATION)
TARGET_LIBS = -lopenFrameworks
OBJ_OUTPUT = obj/Release/
SED_OUTPUT = obj\\/Release\\/
TARGET_NAME = Release
TARGET = bin/$(APPNAME)
endif
ifeq ($(MAKECMDGOALS),clean)
TARGET = bin/$(APPNAME)_debug bin/$(APPNAME)
endif
DEPFILES = $(addprefix $(OBJ_OUTPUT),$(patsubst %.cpp,%.d,$(SOURCES)))
OBJS = $(addprefix $(OBJ_OUTPUT), $(OBJFILES))
ifeq ($(findstring addons.make,$(wildcard *.make)),addons.make)
ADDONS_OBJS = $(addprefix $(OBJ_OUTPUT), $(ADDONS_OBJFILES))
endif
.PHONY: Debug Release after
Release: $(TARGET) after
Debug: $(TARGET) after
#ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
# -include $(DEPFILES)
#endif
#This is the rule for creating the dependency files
$(DEPFILES): $(SOURCES)
echo "creating dependencies"
mkdir -p $(@D)
$(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MM -MT $@ `echo $@ | sed "s/$(SED_OUTPUT)//" | sed "s/\.d/\.cpp/"` > $@
#This rule does the compilation
$(OBJS): $(SOURCES) $(DEPFILES)
echo "compiling objects"
echo $@ | sed "s/$(SED_OUTPUT)//" | sed "s/\.o/\.cpp/"
mkdir -p $(@D)
$(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -o $@ -c `echo $@ | sed "s/$(SED_OUTPUT)//" | sed "s/\.o/\.cpp/"`
$(ADDONS_OBJS): $(ADDONS_SOURCES)
echo $@ | sed "s/$(SED_OUTPUT)//" | sed "s/\.o/\.cpp/"
mkdir -p $(@D)
$(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -o $@ -c ../../../`echo $@ | sed "s/$(SED_OUTPUT)//" | sed "s/\.o/\.cpp/"`
$(TARGET) : $(OBJS) $(ADDONS_OBJS)
echo "linking" $(TARGET)
$(CXX) -o $@ $(OBJS) $(ADDONS_OBJS) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) $(LDFLAGS) $(USER_LDFLAGS) $(TARGET_LIBS) $(LIBS) $(ADDONSLIBS) $(USER_LIBS)
.PHONY: clean CleanDebug CleanRelease
clean:
rm -Rf obj
rm -f -v $(TARGET)
rm -Rf -v bin/libs
rm -f -v bin/clickToLaunchApp*
$(CLEANTARGET):
rm -Rf -v $(OBJ_OUTPUT)
rm -f -v $(TARGET)
rm -f -v bin/clickToLaunchApp_$(TARGET_NAME).sh
after:
cp -r ../../../export/$(LIBSPATH)/libs bin/
cp ../../../export/$(LIBSPATH)/clickToLaunchApp.sh bin/clickToLaunchApp_$(TARGET_NAME).sh
sed -i s/applicationName/$(APPNAME)/g bin/clickToLaunchApp_$(TARGET_NAME).sh
#
# compiling done
# to launch the app
# cd bin
# ./clickToLaunchApp_$(TARGET_NAME).sh
#
.PHONY: help
help:
# openFrameworks universal makefile
#
# targets:
# make Debug: makes the application with debug symbols
# make Release: makes the app with optimizations
# make: the same as make Release
# make CleanDebug: cleans the Debug target
# make CleanRelease: cleans the Release target
# make clean: cleans everything
#
# this should work with any OF app, just copy any example
# change the name of the folder and it should compile
# only .cpp support, don't use .c files
# it will look for files in any folder inside the application
# folder except that in the EXCLUDE_FROM_SOURCE variable
# but you'll need to add the include paths in USER_CFLAGS
#
# to add addons to your application, edit the addons.make file
# in this directory and add the names of the addons you want to
# include
#