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