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