update credits
[librepilot.git] / make / 3rdparty / osgearth / osgearth.mk
blobf28ba339a9e245d0ada00d2184167014eb69b8f1
1 ################################
2 # Targets to build osg and osgearth
4 ################################
6 # $ make all_osg
8 # This will:
9 # - clone the git repositories into the ./3rdparty directory
10 # - build osg in the build/3rdparty directory
11 # - intall osg in the build/3rdparty/install directory
12 # - create distribution files (tar.gz and md5) in the build/3rdparty/install directory
13 # - [TODO] upload distribution files to the librepilot tools repository
15 ################################
17 ################################
19 # common stuff
21 ################################
23 OSG_BUILD_CONF := Release
25 OSG_NAME_PREFIX :=
26 OSG_NAME_SUFIX :=
28 ################################
30 # osg
32 ################################
34 OSG_VERSION := 3.5.5
35 OSG_GIT_TAG := OpenSceneGraph-$(OSG_VERSION)
37 OSG_BASE_NAME := osg-$(OSG_VERSION)
39 ifeq ($(UNAME), Linux)
40 ifeq ($(ARCH), x86_64)
41 OSG_NAME := $(OSG_BASE_NAME)-linux-x64
42 else
43 OSG_NAME := $(OSG_BASE_NAME)-linux-x86
44 endif
45 OSG_CMAKE_GENERATOR := "Unix Makefiles"
46 OSG_CMAKE_MAKE_PROGRAM := make
47 OSG_WINDOWING_SYSTEM := "X11"
48 else ifeq ($(UNAME), Darwin)
49 OSG_NAME := $(OSG_BASE_NAME)-clang_64
50 OSG_CMAKE_GENERATOR := "Unix Makefiles"
51 OSG_CMAKE_MAKE_PROGRAM := make
52 OSG_WINDOWING_SYSTEM := "Cocoa"
53 else ifeq ($(UNAME), Windows)
54 OSG_NAME := $(OSG_BASE_NAME)-$(QT_SDK_ARCH)
55 OSG_CMAKE_GENERATOR := "MinGW Makefiles"
56 endif
58 OSG_NAME := $(OSG_NAME_PREFIX)$(OSG_NAME)$(OSG_NAME_SUFIX)
59 OSG_SRC_DIR := $(ROOT_DIR)/3rdparty/osg
60 OSG_BUILD_DIR := $(BUILD_DIR)/3rdparty/$(OSG_NAME)
61 OSG_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSG_NAME)
63 .PHONY: osg
64 osg:
65 @$(ECHO) "Building osg $(call toprel, $(OSG_SRC_DIR)) into $(call toprel, $(OSG_BUILD_DIR))"
66 $(V1) $(MKDIR) -p $(OSG_BUILD_DIR)
67 $(V1) ( $(CD) $(OSG_BUILD_DIR) && \
68 if [ -n "$(OSG_BUILD_PATH)" ]; then \
69 PATH=$(OSG_BUILD_PATH) ; \
70 fi ; \
71 $(CMAKE) -G $(OSG_CMAKE_GENERATOR) -DCMAKE_BUILD_TYPE=$(OSG_BUILD_CONF) \
72 -DCMAKE_MAKE_PROGRAM=$(MAKE) \
73 -DBUILD_OSG_APPLICATIONS=ON \
74 -DBUILD_OSG_EXAMPLES=OFF \
75 -DOSG_GL3_AVAILABLE=OFF \
76 -DOSG_PLUGIN_SEARCH_INSTALL_DIR_FOR_PLUGINS=OFF \
77 -DCMAKE_OSX_ARCHITECTURES="x86_64" \
78 -DOSG_WINDOWING_SYSTEM=$(OSG_WINDOWING_SYSTEM) \
79 -DCMAKE_INSTALL_NAME_DIR=@executable_path/../Plugins \
80 -DCMAKE_INSTALL_PREFIX=$(OSG_INSTALL_DIR) $(OSG_SRC_DIR) && \
81 $(MAKE) -j3 && \
82 $(MAKE) install ; \
85 .PHONY: package_osg
86 package_osg:
87 @$(ECHO) "Packaging $(call toprel, $(OSG_INSTALL_DIR)) into $(notdir $(OSG_INSTALL_DIR)).tar"
88 #$(V1) $(CP) $(ROOT_DIR)/make/3rdparty/osgearth/LibrePilotReadme.txt $(OSG_INSTALL_DIR)/
89 $(V1) ( \
90 $(CD) $(OSG_INSTALL_DIR)/.. && \
91 $(TAR) cf $(notdir $(OSG_INSTALL_DIR)).tar $(notdir $(OSG_INSTALL_DIR)) && \
92 $(ZIP) -f $(notdir $(OSG_INSTALL_DIR)).tar && \
93 $(call MD5_GEN_TEMPLATE,$(notdir $(OSG_INSTALL_DIR)).tar.gz) ; \
96 .NOTPARALLEL:
97 .PHONY: prepare_osg
98 prepare_osg: clone_osg
100 .PHONY: clone_osg
101 clone_osg:
102 $(V1) if [ -d "$(OSG_SRC_DIR)" ]; then \
103 $(ECHO) "Deleting osg clone..." ; \
104 $(RM) -rf $(OSG_SRC_DIR) ; \
106 @$(ECHO) "Cloning osg..."
107 $(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSG_GIT_TAG) git://github.com/openscenegraph/osg.git $(OSG_SRC_DIR)
108 @$(ECHO) "Checkout osg $(OSG_GIT_TAG)"
109 $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) checkout --force tags/$(OSG_GIT_TAG) ; )
110 $(V1) ( $(CD) $(OSG_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osg-fix-3ds-plugin.patch ; )
112 .PHONY: clean_osg
113 clean_osg:
114 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSG_BUILD_DIR))
115 $(V1) [ ! -d "$(OSG_BUILD_DIR)" ] || $(RM) -r "$(OSG_BUILD_DIR)"
116 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSG_INSTALL_DIR))
117 $(V1) [ ! -d "$(OSG_INSTALL_DIR)" ] || $(RM) -r "$(OSG_INSTALL_DIR)"
119 .PHONY: clean_all_osg
120 clean_all_osg: clean_osg
121 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSG_SRC_DIR))
122 $(V1) [ ! -d "$(OSG_SRC_DIR)" ] || $(RM) -r "$(OSG_SRC_DIR)"
125 ################################
127 # osgearth
129 ################################
130 # TODO
131 # fix Debug build
132 # add option to not build the applications (in Debug mode in particular)
134 OSGEARTH_VERSION := 2.8
135 OSGEARTH_GIT_TAG := osgearth-$(OSGEARTH_VERSION)
137 OSGEARTH_BASE_NAME := osgearth-$(OSGEARTH_VERSION)
138 OSGEARTH_BUILD_CONF := $(OSG_BUILD_CONF)
140 # osgearth cmake script calls the osgversion executable to find the osg version
141 # this makes it necessary to have osg in the path (bin and lib) to make sure the correct one is found
142 ifeq ($(UNAME), Linux)
143 ifeq ($(ARCH), x86_64)
144 OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-linux-x64
145 else
146 OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-linux-x86
147 endif
148 OSGEARTH_CMAKE_GENERATOR := "Unix Makefiles"
149 OSGEARTH_CMAKE_MAKE_PROGRAM := make
150 OSGEARTH_BUILD_PATH := $(OSG_INSTALL_DIR)/bin:$(PATH)
151 ifeq ($(ARCH), x86_64)
152 OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib64
153 else
154 OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib
155 endif
156 else ifeq ($(UNAME), Darwin)
157 OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-clang_64
158 OSGEARTH_CMAKE_GENERATOR := "Unix Makefiles"
159 OSGEARTH_CMAKE_MAKE_PROGRAM := make
160 OSGEARTH_BUILD_PATH := $(OSG_INSTALL_DIR)/bin:$(PATH)
161 OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib
162 else ifeq ($(UNAME), Windows)
163 OSGEARTH_NAME := $(OSGEARTH_BASE_NAME)-$(QT_SDK_ARCH)
164 OSGEARTH_CMAKE_GENERATOR := "MinGW Makefiles"
165 OSGEARTH_LIB_PATH := $(OSG_INSTALL_DIR)/lib
166 endif
168 OSGEARTH_NAME := $(OSG_NAME_PREFIX)$(OSGEARTH_NAME)$(OSG_NAME_SUFIX)
169 OSGEARTH_SRC_DIR := $(ROOT_DIR)/3rdparty/osgearth
170 OSGEARTH_BUILD_DIR := $(BUILD_DIR)/3rdparty/$(OSGEARTH_NAME)
171 OSGEARTH_INSTALL_DIR := $(BUILD_DIR)/3rdparty/install/$(OSGEARTH_NAME)
173 .PHONY: osgearth
174 osgearth:
175 @$(ECHO) "Building osgEarth $(call toprel, $(OSGEARTH_SRC_DIR)) into $(call toprel, $(OSGEARTH_BUILD_DIR))"
176 $(V1) $(MKDIR) -p $(OSGEARTH_BUILD_DIR)
177 $(V1) ( $(CD) $(OSGEARTH_BUILD_DIR) && \
178 if [ -n "$(OSGEARTH_BUILD_PATH)" ]; then \
179 PATH=$(OSGEARTH_BUILD_PATH) ; \
180 fi ; \
181 LD_LIBRARY_PATH=$(OSGEARTH_LIB_PATH) && \
182 export DYLD_LIBRARY_PATH=$(OSGEARTH_LIB_PATH) && \
183 unset OSG_NOTIFY_LEVEL && \
184 $(CMAKE) -G $(OSGEARTH_CMAKE_GENERATOR) -DCMAKE_BUILD_TYPE=$(OSGEARTH_BUILD_CONF) \
185 -DCMAKE_MAKE_PROGRAM=$(MAKE) \
186 -DOSGEARTH_USE_QT=OFF \
187 -DINSTALL_TO_OSG_DIR=OFF \
188 -DOSG_DIR=$(OSG_INSTALL_DIR) \
189 -DCMAKE_INCLUDE_PATH=$(OSG_INSTALL_DIR)/include \
190 -DCMAKE_LIBRARY_PATH=$(OSGEARTH_LIB_PATH) \
191 -DCMAKE_PREFIX_PATH=$(OSGEARTH_LIB_PATH) \
192 -DCMAKE_OSX_ARCHITECTURES="x86_64" \
193 -DCMAKE_INSTALL_NAME_DIR=@executable_path/../Plugins \
194 -DCMAKE_INSTALL_PREFIX=$(OSGEARTH_INSTALL_DIR) $(OSGEARTH_SRC_DIR) && \
195 $(MAKE) -j3 && \
196 $(MAKE) install ; \
199 .PHONY: package_osgearth
200 package_osgearth:
201 @$(ECHO) "Packaging $(call toprel, $(OSGEARTH_INSTALL_DIR)) into $(notdir $(OSGEARTH_INSTALL_DIR)).tar"
202 $(V1) ( \
203 $(CD) $(OSGEARTH_INSTALL_DIR)/.. && \
204 $(TAR) cf $(notdir $(OSGEARTH_INSTALL_DIR)).tar $(notdir $(OSGEARTH_INSTALL_DIR)) && \
205 $(ZIP) -f $(notdir $(OSGEARTH_INSTALL_DIR)).tar && \
206 $(call MD5_GEN_TEMPLATE,$(notdir $(OSGEARTH_INSTALL_DIR)).tar.gz) ; \
209 .NOTPARALLEL:
210 .PHONY: prepare_osgearth
211 prepare_osgearth: clone_osgearth
213 .PHONY: clone_osgearth
214 clone_osgearth:
215 $(V1) if [ -d "$(OSGEARTH_SRC_DIR)" ]; then \
216 $(ECHO) "Deleting osgearth clone..." ; \
217 $(RM) -rf $(OSGEARTH_SRC_DIR) ; \
219 @$(ECHO) "Cloning osgearth..."
220 $(V1) $(GIT) clone --depth 1 --no-checkout -b $(OSGEARTH_GIT_TAG) git://github.com/gwaldron/osgearth.git $(OSGEARTH_SRC_DIR)
221 @$(ECHO) "Checkout osgearth $(OSGEARTH_GIT_TAG)"
222 $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) checkout --force tags/$(OSGEARTH_GIT_TAG) ; )
223 $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-remove-deprecated-call.patch ; )
224 $(V1) ( $(CD) $(OSGEARTH_SRC_DIR) && $(GIT) apply $(ROOT_DIR)/make/3rdparty/osgearth/osgearth-geos-3_6_1-support.patch ; )
226 .PHONY: clean_osgearth
227 clean_osgearth:
228 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSGEARTH_BUILD_DIR))
229 $(V1) [ ! -d "$(OSGEARTH_BUILD_DIR)" ] || $(RM) -r "$(OSGEARTH_BUILD_DIR)"
230 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSGEARTH_INSTALL_DIR))
231 $(V1) [ ! -d "$(OSGEARTH_INSTALL_DIR)" ] || $(RM) -r "$(OSGEARTH_INSTALL_DIR)"
233 .PHONY: clean_all_osgearth
234 clean_all_osgearth: clean_osgearth
235 @$(ECHO) $(MSG_CLEANING) $(call toprel, $(OSGEARTH_SRC_DIR))
236 $(V1) [ ! -d "$(OSGEARTH_SRC_DIR)" ] || $(RM) -r "$(OSGEARTH_SRC_DIR)"
238 ################################
240 # all
242 ################################
244 .NOTPARALLEL:
245 .PHONY: all_osg
246 all_osg: prepare_osg prepare_osgearth osg osgearth package_osg package_osgearth