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)),) 111gb_CXXFLAGS += --sysroot=$(SYSBASE) 112gb_CFLAGS += --sysroot=$(SYSBASE) 113gb_LinkTarget_LDFLAGS := -Wl,--sysroot=$(SYSBASE) 114endif 115gb_LinkTarget_EXCEPTIONFLAGS := \ 116 -DEXCEPTIONS_ON \ 117 -fexceptions \ 118 -fno-enforce-eh-specs \ 119 120gb_LinkTarget_NOEXCEPTIONFLAGS := \ 121 -DEXCEPTIONS_OFF \ 122 -fno-exceptions \ 123 124gb_LinkTarget_LDFLAGS += \ 125 -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \ 126 -Wl,-z,combreloc \ 127 -Wl,-z,defs \ 128 $(subst -L../lib , ,$(SOLARLIB)) \ 129 130ifeq ($(HAVE_LD_HASH_STYLE),TRUE) 131gb_LinkTarget_LDFLAGS += \ 132 -Wl,--hash-style=both \ 133 134endif 135 136ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) 137gb_LinkTarget_LDFLAGS += \ 138 -Wl,--dynamic-list-cpp-new \ 139 -Wl,--dynamic-list-cpp-typeinfo \ 140 -Wl,-Bsymbolic-functions \ 141 142endif 143 144ifeq ($(gb_DEBUGLEVEL),2) 145gb_COMPILEROPTFLAGS := -O0 146else 147gb_COMPILEROPTFLAGS := -Os 148endif 149 150gb_COMPILERNOOPTFLAGS := -O0 151 152# Helper class 153 154gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 155 156 157# CObject class 158 159define gb_CObject__command 160$(call gb_Output_announce,$(2),$(true),C ,3) 161$(call gb_Helper_abbreviate_dirs,\ 162 mkdir -p $(dir $(1)) && \ 163 mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \ 164 $(gb_CC) \ 165 $(DEFS) $(CFLAGS) \ 166 -c $(3) \ 167 -o $(1) \ 168 -MMD -MT $(call gb_CObject_get_target,$(2)) \ 169 -MF $(call gb_CObject_get_dep_target,$(2)) \ 170 -I$(dir $(3)) \ 171 $(INCLUDE)) 172endef 173 174 175# CxxObject class 176 177define gb_CxxObject__command 178$(call gb_Output_announce,$(2),$(true),CXX,3) 179$(call gb_Helper_abbreviate_dirs,\ 180 mkdir -p $(dir $(1)) && \ 181 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 182 $(gb_CXX) \ 183 $(DEFS) $(CXXFLAGS) \ 184 -c $(3) \ 185 -o $(1) \ 186 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 187 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 188 -I$(dir $(3)) \ 189 $(INCLUDE_STL) $(INCLUDE)) 190endef 191 192 193# LinkTarget class 194 195define gb_LinkTarget__get_rpath_for_layer 196$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 197endef 198 199gb_LinkTarget__RPATHS := \ 200 URELIB:\dORIGIN \ 201 UREBIN:\dORIGIN/../lib:\dORIGIN \ 202 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 203 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 204 SDKBIN:\dORIGIN/../../ure-link/lib \ 205 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 206 207gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 208gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 209 210ifeq ($(gb_DEBUGLEVEL),2) 211gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 212gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 213 214endif 215 216gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 217gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 218 219define gb_LinkTarget__command_dynamiclink 220$(call gb_Helper_abbreviate_dirs,\ 221 mkdir -p $(dir $(1)) && \ 222 $(gb_CXX) \ 223 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 224 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 225 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 226 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 227 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 228 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 229 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 230 -o $(1)) 231endef 232 233define gb_LinkTarget__command_staticlink 234$(call gb_Helper_abbreviate_dirs,\ 235 mkdir -p $(dir $(1)) && \ 236 $(gb_AR) -rsu $(1) \ 237 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 238 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 239 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 240 2> /dev/null) 241endef 242 243define gb_LinkTarget__command 244$(call gb_Output_announce,$(2),$(true),LNK,4) 245$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 246$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 247endef 248 249 250# Library class 251 252gb_Library_DEFS := 253gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 254gb_Library_SYSPRE := lib 255gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 256gb_Library_PLAINEXT := .so 257gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 258ifeq ($(gb_PRODUCT),$(true)) 259gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 260else 261gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 262endif 263 264ifeq ($(CPUNAME),X86_64) 265gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 266gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 267else 268gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 269gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 270endif 271 272gb_Library_PLAINLIBS_NONE += \ 273 dl \ 274 freetype \ 275 jpeg \ 276 m \ 277 pthread \ 278 X11 \ 279 Xext \ 280 SM \ 281 ICE \ 282 z \ 283 cppunit 284 285gb_Library_FILENAMES := \ 286 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 287 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 288 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 289 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 290 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 291 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 292 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 293 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 294 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 295 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 296 297 298gb_Library_LAYER := \ 299 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 300 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 301 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 302 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 303 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 304 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 305 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 306 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 307 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 308 309define gb_Library_get_rpath 310'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 311'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)' 312endef 313 314define gb_Library_Library_platform 315$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 316 317endef 318 319 320# StaticLibrary class 321 322gb_StaticLibrary_DEFS := 323gb_StaticLibrary_SYSPRE := lib 324gb_StaticLibrary_PLAINEXT := .a 325gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 326 327gb_StaticLibrary_FILENAMES := \ 328 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 329 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 330 331gb_StaticLibrary_StaticLibrary_platform = 332 333 334# Executable class 335 336gb_Executable_EXT := 337 338gb_Executable_LAYER := \ 339 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 340 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 341 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 342 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 343 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 344 345 346define gb_Executable_get_rpath 347'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 348-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 349endef 350 351define gb_Executable_Executable_platform 352$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 353 354endef 355 356 357# CppunitTest class 358 359gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 360gb_CppunitTest_SYSPRE := libtest_ 361gb_CppunitTest_EXT := .so 362gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 363gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 364 365define gb_CppunitTest_CppunitTest_platform 366$(call gb_LinkTarget_get_target,$(2)) : RPATH := 367 368endef 369 370# JunitTest class 371 372define gb_JunitTest_JunitTest_platform 373$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 374 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 375 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 376 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 377 378endef 379 380# SdiTarget class 381 382gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 383 384# SrsPartMergeTarget 385 386gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 387 388# SrsPartTarget class 389 390gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 391gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 392 393define gb_SrsPartTarget__command_dep 394$(call gb_Helper_abbreviate_dirs,\ 395 $(gb_GCCP) \ 396 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 397 $(INCLUDE) \ 398 $(DEFS) \ 399 -c -x c++-header $(2) \ 400 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 401endef 402 403 404# ComponentTarget 405 406gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 407gb_Library_COMPONENTPREFIXES := \ 408 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 409 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 410 411 412# vim: set noet sw=4 ts=4: 413