1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2011 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28GUI := UNX 29COM := GCC 30 31gb_MKTEMP := gmktemp -t gbuild.XXXXXX 32 33gb_CC := cc 34gb_CXX := c++ 35gb_GCCP := cc 36gb_AR := ar 37gb_AWK := awk 38gb_CLASSPATHSEP := : 39 40# normalize setsolar and configure env. 41ifeq ($(CPU),X) 42CPUNAME := X86_64 43endif 44 45# use CC/CXX if they are nondefaults 46ifneq ($(origin CC),default) 47gb_CC := $(CC) 48gb_GCCP := $(CC) 49endif 50ifneq ($(origin CXX),default) 51gb_CXX := $(CXX) 52endif 53 54gb_OSDEFS := \ 55 -D$(OS) \ 56 -D_PTHREADS \ 57 -DUNIX \ 58 -DUNX \ 59 $(PTHREAD_CFLAGS) \ 60 61ifeq ($(GXX_INCLUDE_PATH),) 62GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion) 63endif 64 65gb_COMPILERDEFS := \ 66 -D$(COM) \ 67 -DHAVE_GCC_VISIBILITY_FEATURE \ 68 -DCPPU_ENV=gcc3 \ 69 -DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \ 70 71ifeq ($(CPUNAME),X86_64) 72gb_CPUDEFS := -D$(CPUNAME) 73else 74gb_CPUDEFS := -DX86 75endif 76 77gb_CFLAGS := \ 78 -Wall \ 79 -Wendif-labels \ 80 -Wextra \ 81 -Wshadow \ 82 -fPIC \ 83 -fmessage-length=0 \ 84 -fno-common \ 85 -fno-strict-aliasing \ 86 -fvisibility=hidden \ 87 -pipe \ 88 89gb_CXXFLAGS := \ 90 -Wall \ 91 -Wendif-labels \ 92 -Wextra \ 93 -Wno-ctor-dtor-privacy \ 94 -Wno-non-virtual-dtor \ 95 -Wshadow \ 96 -fPIC \ 97 -fmessage-length=0 \ 98 -fno-common \ 99 -fno-strict-aliasing \ 100 -fno-use-cxa-atexit \ 101 -fvisibility-inlines-hidden \ 102 -fvisibility=hidden \ 103 -pipe \ 104 105ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE) 106gb_CFLAGS_WERROR := -Werror 107gb_CXXFLAGS_WERROR := -Werror 108endif 109 110ifneq ($(strip $(SYSBASE)),) 111#gb_CXXFLAGS += --sysroot=$(SYSBASE) 112#gb_CFLAGS += --sysroot=$(SYSBASE) 113endif 114gb_LinkTarget_EXCEPTIONFLAGS := \ 115 -DEXCEPTIONS_ON \ 116 -fexceptions \ 117 -fno-enforce-eh-specs \ 118 119gb_LinkTarget_NOEXCEPTIONFLAGS := \ 120 -DEXCEPTIONS_OFF \ 121 -fno-exceptions \ 122 123gb_LinkTarget_LDFLAGS := \ 124 -Wl,-rpath-link=$(SOLARLIBDIR):$(SYSBASE)/lib:$(SYSBASE)/usr/lib:$(SYSBASE)/usr/local/lib \ 125 -Wl,-z,combreloc \ 126 -Wl,-z,defs \ 127 $(subst -L../lib , ,$(SOLARLIB)) \ 128 129ifeq ($(HAVE_LD_HASH_STYLE),TRUE) 130gb_LinkTarget_LDFLAGS += \ 131 -Wl,--hash-style=both \ 132 133endif 134 135ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) 136gb_LinkTarget_LDFLAGS += \ 137 -Wl,--dynamic-list-cpp-new \ 138 -Wl,--dynamic-list-cpp-typeinfo \ 139 -Wl,-Bsymbolic-functions \ 140 141endif 142 143ifeq ($(gb_DEBUGLEVEL),2) 144gb_COMPILEROPTFLAGS := -O0 145else 146gb_COMPILEROPTFLAGS := -Os 147endif 148 149gb_COMPILERNOOPTFLAGS := -O0 150 151# Helper class 152 153gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 154 155 156# CObject class 157 158define gb_CObject__command 159$(call gb_Output_announce,$(2),$(true),C ,3) 160$(call gb_Helper_abbreviate_dirs,\ 161 mkdir -p $(dir $(1)) && \ 162 mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \ 163 $(gb_CC) \ 164 $(DEFS) $(CFLAGS) \ 165 -c $(3) \ 166 -o $(1) \ 167 -MMD -MT $(call gb_CObject_get_target,$(2)) \ 168 -MF $(call gb_CObject_get_dep_target,$(2)) \ 169 -I$(dir $(3)) \ 170 $(INCLUDE)) 171endef 172 173 174# CxxObject class 175 176define gb_CxxObject__command 177$(call gb_Output_announce,$(2),$(true),CXX,3) 178$(call gb_Helper_abbreviate_dirs,\ 179 mkdir -p $(dir $(1)) && \ 180 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 181 $(gb_CXX) \ 182 $(DEFS) $(CXXFLAGS) \ 183 -c $(3) \ 184 -o $(1) \ 185 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 186 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 187 -I$(dir $(3)) \ 188 $(INCLUDE_STL) $(INCLUDE)) 189endef 190 191 192# LinkTarget class 193 194define gb_LinkTarget__get_rpath_for_layer 195$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 196endef 197 198gb_LinkTarget__RPATHS := \ 199 URELIB:\dORIGIN \ 200 UREBIN:\dORIGIN/../lib:\dORIGIN \ 201 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 202 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 203 SDKBIN:\dORIGIN/../../ure-link/lib \ 204 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 205 206gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 207gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 208 209ifeq ($(gb_DEBUGLEVEL),2) 210gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 211gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 212 213endif 214 215gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 216gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 217 218define gb_LinkTarget__command_dynamiclink 219$(call gb_Helper_abbreviate_dirs,\ 220 mkdir -p $(dir $(1)) && \ 221 $(gb_CXX) \ 222 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 223 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 224 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 225 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 226 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 227 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 228 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 229 -o $(1)) 230endef 231 232define gb_LinkTarget__command_staticlink 233$(call gb_Helper_abbreviate_dirs,\ 234 mkdir -p $(dir $(1)) && \ 235 $(gb_AR) -rsu $(1) \ 236 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 237 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 238 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 239 2> /dev/null) 240endef 241 242define gb_LinkTarget__command 243$(call gb_Output_announce,$(2),$(true),LNK,4) 244$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 245$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 246endef 247 248 249# Library class 250 251gb_Library_DEFS := 252gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 253gb_Library_SYSPRE := lib 254gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 255gb_Library_PLAINEXT := .so 256gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 257ifeq ($(gb_PRODUCT),$(true)) 258gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 259else 260gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 261endif 262 263ifeq ($(CPUNAME),X86_64) 264gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 265gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 266else 267gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 268gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 269endif 270 271gb_Library_PLAINLIBS_NONE += \ 272 dl \ 273 freetype \ 274 jpeg \ 275 m \ 276 pthread \ 277 X11 \ 278 Xext \ 279 SM \ 280 ICE \ 281 z 282 283gb_Library_FILENAMES := \ 284 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 285 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 286 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 287 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 288 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 289 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 290 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 291 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 292 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 293 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 294 295 296gb_Library_LAYER := \ 297 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 298 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 299 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 300 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 301 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 302 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 303 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 304 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 305 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 306 307define gb_Library_get_rpath 308-Wl,-z,origin -Wl,-rpath,'$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 309-Wl,-rpath-link,'$(gb_Library_OUTDIRLOCATION)' 310endef 311 312define gb_Library_Library_platform 313$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 314 315endef 316 317 318# StaticLibrary class 319 320gb_StaticLibrary_DEFS := 321gb_StaticLibrary_SYSPRE := lib 322gb_StaticLibrary_PLAINEXT := .a 323gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 324 325gb_StaticLibrary_FILENAMES := \ 326 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 327 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 328 329gb_StaticLibrary_StaticLibrary_platform = 330 331 332# Executable class 333 334gb_Executable_EXT := 335 336gb_Executable_LAYER := \ 337 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 338 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 339 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 340 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 341 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 342 343 344define gb_Executable_get_rpath 345'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 346-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 347endef 348 349define gb_Executable_Executable_platform 350$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 351 352endef 353 354 355# CppunitTest class 356 357gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 358gb_CppunitTest_SYSPRE := libtest_ 359gb_CppunitTest_EXT := .so 360gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 361gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 362 363define gb_CppunitTest_CppunitTest_platform 364$(call gb_LinkTarget_get_target,$(2)) : RPATH := 365 366endef 367 368# JunitTest class 369 370define gb_JunitTest_JunitTest_platform 371$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 372 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 373 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 374 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 375 376endef 377 378# SdiTarget class 379 380gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 381 382# SrsPartMergeTarget 383 384gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 385 386# SrsPartTarget class 387 388gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 389gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 390 391define gb_SrsPartTarget__command_dep 392$(call gb_Helper_abbreviate_dirs,\ 393 $(gb_GCCP) \ 394 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 395 $(INCLUDE) \ 396 $(DEFS) \ 397 -c -x c++-header $(2) \ 398 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 399endef 400 401 402# ComponentTarget 403 404gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 405gb_Library_COMPONENTPREFIXES := \ 406 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 407 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 408 409 410# vim: set noet sw=4 ts=4: 411