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 151# CObject class 152 153define gb_CObject__command 154$(call gb_Output_announce,$(2),$(true),C ,3) 155$(call gb_Helper_abbreviate_dirs,\ 156 mkdir -p $(dir $(1)) && \ 157 mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \ 158 $(gb_CC) \ 159 $(DEFS) $(CFLAGS) \ 160 -c $(3) \ 161 -o $(1) \ 162 -MMD -MT $(call gb_CObject_get_target,$(2)) \ 163 -MF $(call gb_CObject_get_dep_target,$(2)) \ 164 -I$(dir $(3)) \ 165 $(INCLUDE)) 166endef 167 168 169# CxxObject class 170 171define gb_CxxObject__command 172$(call gb_Output_announce,$(2),$(true),CXX,3) 173$(call gb_Helper_abbreviate_dirs,\ 174 mkdir -p $(dir $(1)) && \ 175 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 176 $(gb_CXX) \ 177 $(DEFS) $(CXXFLAGS) \ 178 -c $(3) \ 179 -o $(1) \ 180 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 181 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 182 -I$(dir $(3)) \ 183 $(INCLUDE_STL) $(INCLUDE)) 184endef 185 186 187# LinkTarget class 188 189define gb_LinkTarget__get_rpath_for_layer 190$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 191endef 192 193gb_LinkTarget__RPATHS := \ 194 URELIB:\dORIGIN \ 195 UREBIN:\dORIGIN/../lib:\dORIGIN \ 196 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 197 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 198 SDKBIN:\dORIGIN/../../ure-link/lib \ 199 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 200 201gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 202gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 203 204ifeq ($(gb_DEBUGLEVEL),2) 205gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 206gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 207 208endif 209 210gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 211gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 212 213define gb_LinkTarget__command_dynamiclink 214$(call gb_Helper_abbreviate_dirs,\ 215 mkdir -p $(dir $(1)) && \ 216 $(gb_CXX) \ 217 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 218 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 219 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 220 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 221 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 222 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 223 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 224 -o $(1)) 225endef 226 227define gb_LinkTarget__command_staticlink 228$(call gb_Helper_abbreviate_dirs,\ 229 mkdir -p $(dir $(1)) && \ 230 $(gb_AR) -rsu $(1) \ 231 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 232 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 233 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 234 2> /dev/null) 235endef 236 237define gb_LinkTarget__command 238$(call gb_Output_announce,$(2),$(true),LNK,4) 239$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 240$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 241endef 242 243 244# Library class 245 246gb_Library_DEFS := 247gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 248gb_Library_SYSPRE := lib 249gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 250gb_Library_PLAINEXT := .so 251gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 252ifeq ($(gb_PRODUCT),$(true)) 253gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 254else 255gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 256endif 257 258ifeq ($(CPUNAME),X86_64) 259gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 260gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 261else 262gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 263gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 264endif 265 266gb_Library_PLAINLIBS_NONE += \ 267 dl \ 268 freetype \ 269 jpeg \ 270 m \ 271 pthread \ 272 X11 \ 273 Xext \ 274 SM \ 275 ICE \ 276 z \ 277 cppunit 278 279gb_Library_FILENAMES := \ 280 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 281 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 282 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 283 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 284 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 285 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 286 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 287 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 288 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 289 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 290 291 292gb_Library_LAYER := \ 293 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 294 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 295 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 296 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 297 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 298 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 299 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 300 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 301 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 302 303define gb_Library_get_rpath 304'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 305'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)' 306endef 307 308define gb_Library_Library_platform 309$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 310 311endef 312 313 314# StaticLibrary class 315 316gb_StaticLibrary_DEFS := 317gb_StaticLibrary_SYSPRE := lib 318gb_StaticLibrary_PLAINEXT := .a 319gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 320 321gb_StaticLibrary_FILENAMES := \ 322 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 323 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 324 325gb_StaticLibrary_StaticLibrary_platform = 326 327 328# Executable class 329 330gb_Executable_EXT := 331 332gb_Executable_LAYER := \ 333 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 334 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 335 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 336 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 337 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 338 339 340define gb_Executable_get_rpath 341'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 342-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 343endef 344 345define gb_Executable_Executable_platform 346$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 347 348endef 349 350 351# CppunitTest class 352 353gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 354gb_CppunitTest_SYSPRE := libtest_ 355gb_CppunitTest_EXT := .so 356gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 357gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 358 359define gb_CppunitTest_CppunitTest_platform 360$(call gb_LinkTarget_get_target,$(2)) : RPATH := 361 362endef 363 364# JunitTest class 365 366define gb_JunitTest_JunitTest_platform 367$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 368 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 369 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 370 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 371 372endef 373 374# SdiTarget class 375 376gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 377 378# SrsPartMergeTarget 379 380gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 381 382# SrsPartTarget class 383 384gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 385gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 386 387define gb_SrsPartTarget__command_dep 388$(call gb_Helper_abbreviate_dirs,\ 389 $(gb_GCCP) \ 390 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 391 $(INCLUDE) \ 392 $(DEFS) \ 393 -c -x c++-header $(2) \ 394 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 395endef 396 397 398# ComponentTarget 399 400gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 401gb_Library_COMPONENTPREFIXES := \ 402 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 403 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 404 405 406# vim: set noet sw=4 ts=4: 407