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