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 23COM := GCC 24 25# BSD mktemp -t expects a prefix, not a pattern 26gb_MKTEMP ?= /usr/bin/mktemp -t gbuild. 27 28gb_CC := cc 29gb_CXX := c++ 30gb_GCCP := cc 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 -fno-use-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 \ 113 -fno-enforce-eh-specs \ 114 115gb_LinkTarget_NOEXCEPTIONFLAGS := \ 116 -DEXCEPTIONS_OFF \ 117 -fno-exceptions \ 118 119gb_LinkTarget_LDFLAGS += \ 120 -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \ 121 -Wl,-z,combreloc \ 122 -Wl,-z,defs \ 123 $(subst -L../lib , ,$(SOLARLIB)) \ 124 \ 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# convert parametters filesystem root to native notation 177# does some real work only on windows, make sure not to 178# break the dummy implementations on unx* 179define gb_Helper_convert_native 180$(1) 181endef 182 183# CxxObject class 184 185define gb_CxxObject__command 186$(call gb_Output_announce,$(2),$(true),CXX,3) 187$(call gb_Helper_abbreviate_dirs,\ 188 mkdir -p $(dir $(1)) && \ 189 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 190 $(gb_CXX) \ 191 $(DEFS) $(CXXFLAGS) \ 192 -c $(3) \ 193 -o $(1) \ 194 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 195 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 196 -I$(dir $(3)) \ 197 $(INCLUDE_STL) $(INCLUDE)) 198endef 199 200 201# LinkTarget class 202 203define gb_LinkTarget__get_rpath_for_layer 204$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 205endef 206 207gb_LinkTarget__RPATHS := \ 208 URELIB:\dORIGIN \ 209 UREBIN:\dORIGIN/../lib:\dORIGIN \ 210 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 211 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 212 SDKBIN:\dORIGIN/../../ure-link/lib \ 213 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 214 215gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 216gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 217 218ifeq ($(gb_DEBUGLEVEL),0) 219gb_LinkTarget_LDFLAGS += -Wl,-O1 220endif 221 222gb_DEBUG_CFLAGS := -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 223 224ifeq ($(gb_DEBUGLEVEL),2) 225gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 226gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 227 228endif 229 230gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 231gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 232 233define gb_LinkTarget__command_dynamiclink 234$(call gb_Helper_abbreviate_dirs,\ 235 mkdir -p $(dir $(1)) && \ 236 $(gb_CXX) \ 237 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 238 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 239 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 240 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 241 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 242 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 243 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 244 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 245 -o $(1)) 246endef 247 248define gb_LinkTarget__command_staticlink 249$(call gb_Helper_abbreviate_dirs,\ 250 mkdir -p $(dir $(1)) && \ 251 $(gb_AR) -rsu $(1) \ 252 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 253 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 254 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 255 2> /dev/null) 256endef 257 258define gb_LinkTarget__command 259$(call gb_Output_announce,$(2),$(true),LNK,4) 260$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 261$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 262endef 263 264 265# Library class 266 267gb_Library_DEFS := 268gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 269gb_Library_SYSPRE := lib 270gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 271gb_Library_PLAINEXT := .so 272gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 273ifeq ($(gb_PRODUCT),$(true)) 274gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 275else 276gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 277endif 278 279ifeq ($(CPUNAME),X86_64) 280gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 281gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 282else 283gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 284gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 285endif 286 287gb_Library_PLAINLIBS_NONE += \ 288 dl \ 289 freetype \ 290 jpeg \ 291 m \ 292 pthread \ 293 X11 \ 294 Xext \ 295 SM \ 296 ICE \ 297 z \ 298 cppunit 299 300gb_Library_FILENAMES := \ 301 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 302 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 303 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 304 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 305 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 306 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 307 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 308 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 309 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 310 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 311 312 313gb_Library_LAYER := \ 314 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 315 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 316 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 317 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 318 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 319 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 320 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 321 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 322 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 323 324define gb_Library_get_rpath 325-Wl,-z,origin '-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 326'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)' 327endef 328 329define gb_Library_Library_platform 330$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 331 332endef 333 334 335# StaticLibrary class 336 337gb_StaticLibrary_DEFS := 338gb_StaticLibrary_SYSPRE := lib 339gb_StaticLibrary_PLAINEXT := .a 340gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 341 342gb_StaticLibrary_FILENAMES := \ 343 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 344 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 345 346gb_StaticLibrary_StaticLibrary_platform = 347 348 349# Executable class 350 351gb_Executable_EXT := 352 353gb_Executable_LAYER := \ 354 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 355 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 356 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 357 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 358 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 359 360 361define gb_Executable_get_rpath 362'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 363-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 364endef 365 366define gb_Executable_Executable_platform 367$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 368 369endef 370 371 372# CppunitTest class 373 374gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 375gb_CppunitTest_SYSPRE := libtest_ 376gb_CppunitTest_EXT := .so 377gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 378gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 379 380define gb_CppunitTest_CppunitTest_platform 381$(call gb_LinkTarget_get_target,$(2)) : RPATH := 382 383endef 384 385# JunitTest class 386 387define gb_JunitTest_JunitTest_platform 388$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 389 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 390 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 391 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 392 393endef 394 395# SdiTarget class 396 397gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 398 399# SrsPartMergeTarget 400 401gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 402 403# SrsPartTarget class 404 405gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 406gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 407 408define gb_SrsPartTarget__command_dep 409$(call gb_Helper_abbreviate_dirs,\ 410 $(gb_GCCP) \ 411 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 412 $(INCLUDE) \ 413 $(DEFS) \ 414 -c -x c++-header $(2) \ 415 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 416endef 417 418 419# ComponentTarget 420 421gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 422gb_Library_COMPONENTPREFIXES := \ 423 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 424 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 425 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 426 427# UnoApiTarget 428 429gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc 430gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 431gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge 432gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 433gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare 434gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 435gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker 436gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 437gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview 438gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 439 440# vim: set noet sw=4 ts=4: 441