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 25gb_MKTEMP := gmktemp -t gbuild.XXXXXX 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 39# use CC/CXX if they are nondefaults 40ifneq ($(origin CC),default) 41gb_CC := $(CC) 42gb_GCCP := $(CC) 43endif 44ifneq ($(origin CXX),default) 45gb_CXX := $(CXX) 46endif 47 48gb_OSDEFS := \ 49 -D$(OS) \ 50 -D_PTHREADS \ 51 -DUNIX \ 52 -DUNX \ 53 $(PTHREAD_CFLAGS) \ 54 55ifeq ($(GXX_INCLUDE_PATH),) 56GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion) 57endif 58 59gb_COMPILERDEFS := \ 60 -D$(COM) \ 61 -DHAVE_GCC_VISIBILITY_FEATURE \ 62 -DCPPU_ENV=gcc3 \ 63 -DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \ 64 65ifeq ($(CPUNAME),X86_64) 66gb_CPUDEFS := -D$(CPUNAME) 67else 68gb_CPUDEFS := -DX86 69endif 70 71gb_CFLAGS := \ 72 -Wall \ 73 -Wendif-labels \ 74 -Wextra \ 75 -Wshadow \ 76 -fPIC \ 77 -fmessage-length=0 \ 78 -fno-common \ 79 -fno-strict-aliasing \ 80 -fvisibility=hidden \ 81 -pipe \ 82 83gb_CXXFLAGS := \ 84 -Wall \ 85 -Wendif-labels \ 86 -Wextra \ 87 -Wno-ctor-dtor-privacy \ 88 -Wno-non-virtual-dtor \ 89 -Wshadow \ 90 -fPIC \ 91 -fmessage-length=0 \ 92 -fno-common \ 93 -fno-strict-aliasing \ 94 -fno-use-cxa-atexit \ 95 -fvisibility-inlines-hidden \ 96 -fvisibility=hidden \ 97 -pipe \ 98 99ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE) 100gb_CFLAGS_WERROR := -Werror 101gb_CXXFLAGS_WERROR := -Werror 102endif 103 104ifneq ($(strip $(SYSBASE)),) 105gb_CXXFLAGS += --sysroot=$(SYSBASE) 106gb_CFLAGS += --sysroot=$(SYSBASE) 107gb_LinkTarget_LDFLAGS := -Wl,--sysroot=$(SYSBASE) 108endif 109gb_LinkTarget_EXCEPTIONFLAGS := \ 110 -DEXCEPTIONS_ON \ 111 -fexceptions \ 112 -fno-enforce-eh-specs \ 113 114gb_LinkTarget_NOEXCEPTIONFLAGS := \ 115 -DEXCEPTIONS_OFF \ 116 -fno-exceptions \ 117 118gb_LinkTarget_LDFLAGS += \ 119 -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \ 120 -Wl,-z,combreloc \ 121 -Wl,-z,defs \ 122 $(subst -L../lib , ,$(SOLARLIB)) \ 123 124ifeq ($(HAVE_LD_HASH_STYLE),TRUE) 125gb_LinkTarget_LDFLAGS += \ 126 -Wl,--hash-style=both \ 127 128endif 129 130ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) 131gb_LinkTarget_LDFLAGS += \ 132 -Wl,--dynamic-list-cpp-new \ 133 -Wl,--dynamic-list-cpp-typeinfo \ 134 -Wl,-Bsymbolic-functions \ 135 136endif 137 138ifeq ($(gb_DEBUGLEVEL),2) 139gb_COMPILEROPTFLAGS := -O0 140else 141gb_COMPILEROPTFLAGS := -Os 142endif 143 144gb_COMPILERNOOPTFLAGS := -O0 145 146# Helper class 147 148gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 149 150# convert parametters filesystem root to native notation 151# does some real work only on windows, make sure not to 152# break the dummy implementations on unx* 153define gb_Helper_convert_native 154$(1) 155endef 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 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 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 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 231 -o $(1)) 232endef 233 234define gb_LinkTarget__command_staticlink 235$(call gb_Helper_abbreviate_dirs,\ 236 mkdir -p $(dir $(1)) && \ 237 $(gb_AR) -rsu $(1) \ 238 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 239 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 240 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 241 2> /dev/null) 242endef 243 244define gb_LinkTarget__command 245$(call gb_Output_announce,$(2),$(true),LNK,4) 246$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 247$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 248endef 249 250 251# Library class 252 253gb_Library_DEFS := 254gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 255gb_Library_SYSPRE := lib 256gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 257gb_Library_PLAINEXT := .so 258gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 259ifeq ($(gb_PRODUCT),$(true)) 260gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 261else 262gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 263endif 264 265ifeq ($(CPUNAME),X86_64) 266gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 267gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 268else 269gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 270gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 271endif 272 273gb_Library_PLAINLIBS_NONE += \ 274 dl \ 275 freetype \ 276 jpeg \ 277 m \ 278 pthread \ 279 X11 \ 280 Xext \ 281 SM \ 282 ICE \ 283 z \ 284 cppunit 285 286gb_Library_FILENAMES := \ 287 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 288 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 289 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 290 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 291 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 292 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 293 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 294 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 295 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 296 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 297 298 299gb_Library_LAYER := \ 300 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 301 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 302 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 303 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 304 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 305 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 306 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 307 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 308 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 309 310define gb_Library_get_rpath 311'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 312'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)' 313endef 314 315define gb_Library_Library_platform 316$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 317 318endef 319 320 321# StaticLibrary class 322 323gb_StaticLibrary_DEFS := 324gb_StaticLibrary_SYSPRE := lib 325gb_StaticLibrary_PLAINEXT := .a 326gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 327 328gb_StaticLibrary_FILENAMES := \ 329 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 330 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 331 332gb_StaticLibrary_StaticLibrary_platform = 333 334 335# Executable class 336 337gb_Executable_EXT := 338 339gb_Executable_LAYER := \ 340 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 341 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 342 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 343 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 344 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 345 346 347define gb_Executable_get_rpath 348'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 349-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 350endef 351 352define gb_Executable_Executable_platform 353$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 354 355endef 356 357 358# CppunitTest class 359 360gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 361gb_CppunitTest_SYSPRE := libtest_ 362gb_CppunitTest_EXT := .so 363gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 364gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 365 366define gb_CppunitTest_CppunitTest_platform 367$(call gb_LinkTarget_get_target,$(2)) : RPATH := 368 369endef 370 371# JunitTest class 372 373define gb_JunitTest_JunitTest_platform 374$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 375 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 376 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 377 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 378 379endef 380 381# SdiTarget class 382 383gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 384 385# SrsPartMergeTarget 386 387gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 388 389# SrsPartTarget class 390 391gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 392gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 393 394define gb_SrsPartTarget__command_dep 395$(call gb_Helper_abbreviate_dirs,\ 396 $(gb_GCCP) \ 397 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 398 $(INCLUDE) \ 399 $(DEFS) \ 400 -c -x c++-header $(2) \ 401 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 402endef 403 404 405# ComponentTarget 406 407gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 408gb_Library_COMPONENTPREFIXES := \ 409 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 410 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 411 412 413# vim: set noet sw=4 ts=4: 414