Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

added makefile to build on linux, thanks to lian

  • Loading branch information...
commit fc4be358319893c36451c552fc7a29625f5c23d5 1 parent 028c025
Francesco authored September 07, 2011
228  Makefile
... ...
@@ -0,0 +1,228 @@
  1
+# openFrameworks universal makefile
  2
+#
  3
+# make help : shows this message
  4
+# make Debug:  makes the application with debug symbols
  5
+# make Release: makes the app with optimizations
  6
+# make: the same as make Release
  7
+# make CleanDebug: cleans the Debug target
  8
+# make CleanRelease: cleans the Release target
  9
+# make clean: cleans everything
  10
+# 
  11
+#
  12
+# this should work with any OF app, just copy any example
  13
+# change the name of the folder and it should compile
  14
+# only .cpp support, don't use .c files
  15
+# it will look for files in any folder inside the application
  16
+# folder except that in the EXCLUDE_FROM_SOURCE variable
  17
+# it doesn't autodetect include paths yet
  18
+# add the include paths in the USER_CFLAGS variable
  19
+# using the gcc syntax: -Ipath
  20
+#
  21
+# to add addons to your application, edit the addons.make file
  22
+# in this directory and add the names of the addons you want to
  23
+# include
  24
+#
  25
+# edit the following  vars to customize the makefile
  26
+
  27
+
  28
+COMPILER_OPTIMIZATION = -march=native -mtune=native -O3
  29
+EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj"
  30
+USER_CFLAGS = 
  31
+USER_LD_FLAGS = 
  32
+USER_LIBS = 
  33
+
  34
+
  35
+
  36
+
  37
+# you shouldn't modify anything below this line
  38
+
  39
+
  40
+SHELL =  /bin/sh
  41
+CXX =  g++
  42
+
  43
+ARCH = $(shell uname -m)
  44
+ifeq ($(ARCH),x86_64)
  45
+	LIBSPATH=linux64
  46
+else
  47
+	LIBSPATH=linux
  48
+endif
  49
+
  50
+NODEPS = clean
  51
+SED_EXCLUDE_FROM_SRC = $(shell echo  $(EXCLUDE_FROM_SOURCE) | sed s/\,/\\\\\|/g)
  52
+SOURCE_DIRS = $(shell find . -maxdepth 1 -mindepth 1 -type d | grep -v $(SED_EXCLUDE_FROM_SRC) | sed s/.\\///)
  53
+SOURCES = $(shell find $(SOURCE_DIRS) -name "*.cpp" -or -name "*.c")
  54
+OBJFILES = $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(SOURCES)))
  55
+# APPNAME = $(shell basename `pwd`)
  56
+APPNAME = "lpmt"
  57
+CORE_INCLUDES = $(shell find ../../../libs/openFrameworks/ -type d)
  58
+CORE_INCLUDE_FLAGS = $(addprefix -I,$(CORE_INCLUDES))
  59
+INCLUDES = $(shell find ../../../libs/*/include -type d)
  60
+INCLUDES_FLAGS = $(addprefix -I,$(INCLUDES))
  61
+LIB_STATIC = $(shell ls ../../../libs/*/lib/$(LIBSPATH)/*.a | grep -v openFrameworksCompiled | sed "s/.*\\/lib\([^/]*\)\.a/-l\1/")
  62
+LIB_SHARED = $(shell ls ../../../libs/*/lib/$(LIBSPATH)/*.so | grep -v openFrameworksCompiled| sed "s/.*\\/lib\([^/]*\)\.so/-l\1/")
  63
+
  64
+#LIB_PATHS_FLAGS = -L../../../libs/openFrameworksCompiled/lib/$(LIBSPATH)
  65
+LIB_PATHS_FLAGS = $(shell ls -d ../../../libs/*/lib/$(LIBSPATH) | sed "s/\(\.*\)/-L\1/")
  66
+
  67
+CFLAGS = -Wall -fexceptions
  68
+CFLAGS += -I. 
  69
+CFLAGS += $(INCLUDES_FLAGS)
  70
+CFLAGS += $(CORE_INCLUDE_FLAGS)
  71
+CFLAGS +=`pkg-config  gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --cflags`
  72
+
  73
+LDFLAGS = $(LIB_PATHS_FLAGS) -Wl,-rpath=./libs
  74
+
  75
+LIBS = $(LIB_SHARED)
  76
+LIBS += $(LIB_STATIC)
  77
+LIBS +=`pkg-config  gstreamer-0.10 gstreamer-video-0.10 gstreamer-base-0.10 libudev --libs`
  78
+LIBS += -lglut -lGL -lGLU -lasound
  79
+
  80
+ifeq ($(findstring addons.make,$(wildcard *.make)),addons.make)
  81
+	ADDONS_INCLUDES = $(shell find ../../../addons/*/src/ -type d)
  82
+	ADDONS_INCLUDES += $(shell find ../../../addons/*/libs/ -type d)
  83
+	ADDONSCFLAGS = $(addprefix -I,$(ADDONS_INCLUDES))
  84
+	
  85
+	ADDONS_LIBS_STATICS = $(shell ls ../../../addons/*/libs/*/lib/$(LIBSPATH)/*.a)
  86
+	ADDONS_LIBS_SHARED = $(shell ls ../../../addons/*/libs/*/lib/$(LIBSPATH)/*.so)
  87
+
  88
+	ADDONSLIBS = $(ADDONS_LIBS_STATICS)
  89
+	ADDONSLIBS += $(ADDONS_LIBS_SHARED)
  90
+
  91
+	ADDONS = $(shell cat addons.make)
  92
+	ADDONS_REL_DIRS = $(addsuffix /src, $(ADDONS))
  93
+	ADDONS_LIBS_REL_DIRS = $(addsuffix /libs, $(ADDONS))
  94
+	ADDONS_DIRS = $(addprefix ../../../addons/, $(ADDONS_REL_DIRS) )
  95
+	ADDONS_LIBS_DIRS = $(addprefix ../../../addons/, $(ADDONS_LIBS_REL_DIRS) )
  96
+	ADDONS_SOURCES = $(shell find $(ADDONS_DIRS) -name "*.cpp" -or -name "*.c")
  97
+	ADDONS_SOURCES += $(shell find $(ADDONS_LIBS_DIRS) -name "*.cpp" -or -name "*.c" 2>/dev/null)
  98
+	ADDONS_OBJFILES = $(subst ../../../, ,$(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(ADDONS_SOURCES))))
  99
+endif
  100
+
  101
+
  102
+
  103
+ifeq ($(findstring Debug,$(MAKECMDGOALS)),Debug)
  104
+	TARGET_CFLAGS = -g
  105
+	TARGET_LIBS = -lopenFrameworksDebug
  106
+	TARGET_NAME = Debug
  107
+    BIN_NAME = $(APPNAME)_debug
  108
+	TARGET = bin/$(BIN_NAME)
  109
+endif
  110
+
  111
+ifeq ($(findstring Release,$(MAKECMDGOALS)),Release)
  112
+	TARGET_CFLAGS = $(COMPILER_OPTIMIZATION)
  113
+	TARGET_LIBS = -lopenFrameworks
  114
+	TARGET_NAME = Release
  115
+    BIN_NAME = $(APPNAME)
  116
+	TARGET = bin/$(BIN_NAME)
  117
+endif
  118
+
  119
+ifeq ($(MAKECMDGOALS),)
  120
+	TARGET_CFLAGS = $(COMPILER_OPTIMIZATION)
  121
+	TARGET_LIBS = -lopenFrameworks
  122
+	TARGET_NAME = Release
  123
+    BIN_NAME = $(APPNAME)
  124
+	TARGET = bin/$(BIN_NAME)
  125
+endif
  126
+
  127
+ifeq ($(MAKECMDGOALS),clean)
  128
+	TARGET = bin/$(APPNAME)_debug bin/$(APPNAME)
  129
+endif
  130
+
  131
+OBJ_OUTPUT = obj/$(TARGET_NAME)/
  132
+CLEANTARGET = Clean$(TARGET_NAME)
  133
+OBJS = $(addprefix $(OBJ_OUTPUT), $(OBJFILES))
  134
+DEPFILES = $(patsubst %.o,%.d,$(OBJS))
  135
+ifeq ($(findstring addons.make,$(wildcard *.make)),addons.make)
  136
+	ADDONS_OBJS = $(addprefix $(OBJ_OUTPUT), $(ADDONS_OBJFILES))
  137
+    DEPFILES += $(patsubst %.o,%.d,$(ADDONS_OBJS))
  138
+endif
  139
+
  140
+.PHONY: Debug Release all after
  141
+	
  142
+Release: $(TARGET) after
  143
+
  144
+Debug: $(TARGET) after
  145
+
  146
+all: 
  147
+	make Release
  148
+
  149
+
  150
+#This rule does the compilation
  151
+#$(OBJS): $(SOURCES)
  152
+$(OBJ_OUTPUT)%.o: %.cpp
  153
+	@echo "compiling object for: " $<
  154
+	mkdir -p $(@D)
  155
+	$(CXX) -c $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o$@ -c $<  
  156
+
  157
+$(OBJ_OUTPUT)%.o: %.c
  158
+	@echo "compiling object for: " $<
  159
+	mkdir -p $(@D)
  160
+	$(CC) -c $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o$@ -c $< 
  161
+
  162
+
  163
+$(OBJ_OUTPUT)%.o: ../../../%.cpp
  164
+	@echo "compiling addon object for" $<
  165
+	mkdir -p $(@D)
  166
+	$(CXX) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o $@ -c $<
  167
+
  168
+$(OBJ_OUTPUT)%.o: ../../../%.c
  169
+	@echo "compiling addon object for" $<
  170
+	mkdir -p $(@D)
  171
+	$(CC) $(TARGET_CFLAGS) $(CFLAGS) $(ADDONSCFLAGS) $(USER_CFLAGS) -MMD -MP -MF$(OBJ_OUTPUT)$*.d -MT$(OBJ_OUTPUT)$*.d -o $@ -c $<
  172
+	
  173
+$(TARGET): $(OBJS) $(ADDONS_OBJS)
  174
+	@echo "linking" $(TARGET)
  175
+	$(CXX) -o $@ $(OBJS) $(ADDONS_OBJS) $(LDFLAGS) $(USER_LDFLAGS) $(TARGET_LIBS) $(LIBS) $(ADDONSLIBS) $(USER_LIBS)
  176
+
  177
+-include $(DEPFILES)
  178
+
  179
+.PHONY: clean CleanDebug CleanRelease
  180
+clean:
  181
+	rm -Rf obj
  182
+	rm -f -v $(TARGET)
  183
+	rm -Rf -v bin/libs
  184
+	
  185
+$(CLEANTARGET):
  186
+	rm -Rf -v $(OBJ_OUTPUT)
  187
+	rm -f -v $(TARGET)
  188
+
  189
+
  190
+after:
  191
+	cp -r ../../../export/$(LIBSPATH)/libs bin/
  192
+	@echo
  193
+	@echo "     compiling done"
  194
+	@echo "     to launch the application"	
  195
+	@echo
  196
+	@echo "     cd bin"
  197
+	@echo "     ./$(BIN_NAME)"
  198
+	@echo
  199
+    
  200
+
  201
+.PHONY: help
  202
+help:
  203
+	@echo 
  204
+	@echo openFrameworks universal makefile
  205
+	@echo
  206
+	@echo targets:
  207
+	@echo "make Debug:		builds the application with debug symbols"
  208
+	@echo "make Release:		builds the app with optimizations"
  209
+	@echo "make:			= make Release"
  210
+	@echo "make all:		= make Release"
  211
+	@echo "make CleanDebug:	cleans the Debug target"
  212
+	@echo "make CleanRelease:	cleans the Release target"
  213
+	@echo "make clean:		cleans everything"
  214
+	@echo
  215
+	@echo this should work with any OF app, just copy any example
  216
+	@echo change the name of the folder and it should compile
  217
+	@echo "only .cpp support, don't use .c files"
  218
+	@echo it will look for files in any folder inside the application
  219
+	@echo folder except that in the EXCLUDE_FROM_SOURCE variable.
  220
+	@echo "it doesn't autodetect include paths yet"
  221
+	@echo "add the include paths editing the var USER_CFLAGS"	
  222
+	@echo at the beginning of the makefile using the gcc syntax:
  223
+	@echo -Ipath
  224
+	@echo
  225
+	@echo to add addons to your application, edit the addons.make file
  226
+	@echo in this directory and add the names of the addons you want to
  227
+	@echo include
  228
+	@echo
3  addons.make
... ...
@@ -0,0 +1,3 @@
  1
+ofxXmlSettings
  2
+ofxMSAInteractiveObject
  3
+ofxSimpleGuiToo
BIN  bin/lpmt
Binary file not shown
34  config.make
... ...
@@ -0,0 +1,34 @@
  1
+# add custom variables to this file
  2
+
  3
+# OF_ROOT allows to move projects outside apps/* just set this variable to the
  4
+# absoulte path to the OF root folder
  5
+
  6
+OF_ROOT = ../../..
  7
+
  8
+
  9
+# USER_CFLAGS allows to pass custom flags to the compiler
  10
+# for example search paths like:
  11
+# USER_CFLAGS = -I src/objects
  12
+
  13
+USER_CFLAGS = 
  14
+
  15
+
  16
+# USER_LDFLAGS allows to pass custom flags to the linker
  17
+# for example libraries like:
  18
+# USER_LD_FLAGS = libs/libawesomelib.a
  19
+
  20
+USER_LDFLAGS = 
  21
+
  22
+
  23
+# use this to add system libraries for example:
  24
+# USER_LIBS = -lpango
  25
+ 
  26
+USER_LIBS =
  27
+
  28
+
  29
+# change this to add different compiler optimizations to your project
  30
+
  31
+USER_COMPILER_OPTIMIZATION = -march=native -mtune=native -Os
  32
+
  33
+
  34
+EXCLUDE_FROM_SOURCE="bin,.xcodeproj,obj"
2  projection_mapping_linux.cbp
@@ -2,7 +2,7 @@
2 2
 <CodeBlocks_project_file>
3 3
 	<FileVersion major="1" minor="6" />
4 4
 	<Project>
5  
-		<Option title="projection_mapping" />
  5
+		<Option title="lpmt" />
6 6
 		<Option pch_mode="2" />
7 7
 		<Option compiler="gcc" />
8 8
 		<Option virtualFolders="addons/;src/;addons/ofxMSAInteractiveObject/src/;addons/ofxSimpleGuiToo/src/Controls/;addons/ofxSimpleGuiToo/src/;addons/ofxXmlSettings/libs/;addons/ofxXmlSettings/src/;" />
2  projection_mapping_linux64.cbp
@@ -2,7 +2,7 @@
2 2
 <CodeBlocks_project_file>
3 3
 	<FileVersion major="1" minor="6" />
4 4
 	<Project>
5  
-		<Option title="projection_mapping" />
  5
+		<Option title="lpmt" />
6 6
 		<Option pch_mode="2" />
7 7
 		<Option compiler="gcc" />
8 8
 		<Option virtualFolders="addons/;src/;addons/ofxMSAInteractiveObject/src/;addons/ofxSimpleGuiToo/src/Controls/;addons/ofxSimpleGuiToo/src/;addons/ofxXmlSettings/libs/;addons/ofxXmlSettings/src/;" />
2  src/testApp.h
@@ -4,7 +4,7 @@
4 4
 
5 5
 
6 6
 #include "ofMain.h"
7  
-#include "ofAddons.h"
  7
+
8 8
 #include "ball.h"
9 9
 #include "quad.h"
10 10
 #include "ofxXmlSettings.h"

0 notes on commit fc4be35

Please sign in to comment.
Something went wrong with that request. Please try again.