1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2011 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28GUI := UNX 29COM := GCC 30 31gb_MKTEMP := mktemp -t gbuild.XXXXXX 32 33gb_CC := gcc 34gb_CXX := g++ 35gb_GCCP := gcc 36gb_AR := ar 37gb_AWK := awk 38gb_CLASSPATHSEP := : 39 40# normalize setsolar and configure env. 41ifeq ($(CPU),X) 42CPUNAME := X86_64 43endif 44 45# use CC/CXX if they are nondefaults 46ifneq ($(origin CC),default) 47gb_CC := $(CC) 48gb_GCCP := $(CC) 49endif 50ifneq ($(origin CXX),default) 51gb_CXX := $(CXX) 52endif 53 54gb_OSDEFS := \ 55 -D$(OS) \ 56 -D_PTHREADS \ 57 -DUNIX \ 58 -DUNX \ 59 $(PTHREAD_CFLAGS) \ 60 61ifeq ($(GXX_INCLUDE_PATH),) 62GXX_INCLUDE_PATH=$(COMPATH)/include/c++/$(shell gcc -dumpversion) 63endif 64 65gb_COMPILERDEFS := \ 66 -D$(COM) \ 67 -DHAVE_GCC_VISIBILITY_FEATURE \ 68 -DCPPU_ENV=gcc3 \ 69 -DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \ 70 71ifeq ($(CPUNAME),X86_64) 72gb_CPUDEFS := -D$(CPUNAME) 73else 74gb_CPUDEFS := -DX86 75endif 76 77gb_CFLAGS := \ 78 -Wall \ 79 -Wendif-labels \ 80 -Wextra \ 81 -Wshadow \ 82 -fPIC \ 83 -fmessage-length=0 \ 84 -fno-common \ 85 -fno-strict-aliasing \ 86 -fvisibility=hidden \ 87 -pipe \ 88 89gb_CXXFLAGS := \ 90 -Wall \ 91 -Wendif-labels \ 92 -Wextra \ 93 -Wno-ctor-dtor-privacy \ 94 -Wno-non-virtual-dtor \ 95 -Wshadow \ 96 -fPIC \ 97 -fmessage-length=0 \ 98 -fno-common \ 99 -fno-strict-aliasing \ 100 -fno-use-cxa-atexit \ 101 -fvisibility-inlines-hidden \ 102 -fvisibility=hidden \ 103 -pipe \ 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 \ 118 -fno-enforce-eh-specs \ 119 120gb_LinkTarget_NOEXCEPTIONFLAGS := \ 121 -DEXCEPTIONS_OFF \ 122 -fno-exceptions \ 123 124gb_LinkTarget_LDFLAGS += \ 125 -Wl,-rpath-link,$(SYSBASE)/lib:$(SYSBASE)/usr/lib \ 126 -Wl,-z,combreloc \ 127 -Wl,-z,defs \ 128 $(subst -L../lib , ,$(SOLARLIB)) \ 129 130ifeq ($(HAVE_LD_HASH_STYLE),TRUE) 131gb_LinkTarget_LDFLAGS += \ 132 -Wl,--hash-style=both \ 133 134endif 135 136ifneq ($(HAVE_LD_BSYMBOLIC_FUNCTIONS),) 137gb_LinkTarget_LDFLAGS += \ 138 -Wl,--dynamic-list-cpp-new \ 139 -Wl,--dynamic-list-cpp-typeinfo \ 140 -Wl,-Bsymbolic-functions \ 141 142endif 143 144ifeq ($(gb_DEBUGLEVEL),2) 145gb_COMPILEROPTFLAGS := -O0 146else 147gb_COMPILEROPTFLAGS := -Os 148endif 149 150gb_COMPILERNOOPTFLAGS := -O0 151 152# Helper class 153 154gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 155 156# convert parametters filesystem root to native notation 157# does some real work only on windows, make sure not to 158# break the dummy implementations on unx* 159define gb_Helper_convert_native 160$(1) 161endef 162 163# CObject class 164 165define gb_CObject__command 166$(call gb_Output_announce,$(2),$(true),C ,3) 167$(call gb_Helper_abbreviate_dirs,\ 168 mkdir -p $(dir $(1)) && \ 169 mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \ 170 $(gb_CC) \ 171 $(DEFS) $(CFLAGS) \ 172 -c $(3) \ 173 -o $(1) \ 174 -MMD -MT $(call gb_CObject_get_target,$(2)) \ 175 -MF $(call gb_CObject_get_dep_target,$(2)) \ 176 -I$(dir $(3)) \ 177 $(INCLUDE)) 178endef 179 180 181# CxxObject class 182 183define gb_CxxObject__command 184$(call gb_Output_announce,$(2),$(true),CXX,3) 185$(call gb_Helper_abbreviate_dirs,\ 186 mkdir -p $(dir $(1)) && \ 187 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 188 $(gb_CXX) \ 189 $(DEFS) $(CXXFLAGS) \ 190 -c $(3) \ 191 -o $(1) \ 192 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 193 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 194 -I$(dir $(3)) \ 195 $(INCLUDE_STL) $(INCLUDE)) 196endef 197 198 199# LinkTarget class 200 201define gb_LinkTarget__get_rpath_for_layer 202$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 203endef 204 205gb_LinkTarget__RPATHS := \ 206 URELIB:\dORIGIN \ 207 UREBIN:\dORIGIN/../lib:\dORIGIN \ 208 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 209 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 210 SDKBIN:\dORIGIN/../../ure-link/lib \ 211 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 212 213gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 214gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 215 216ifeq ($(gb_DEBUGLEVEL),2) 217gb_LinkTarget_CXXFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 218gb_LinkTarget_CFLAGS += -ggdb3 -finline-limit=0 -fno-inline -fno-default-inline 219 220endif 221 222gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 223gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 224 225define gb_LinkTarget__command_dynamiclink 226$(call gb_Helper_abbreviate_dirs,\ 227 mkdir -p $(dir $(1)) && \ 228 $(gb_CXX) \ 229 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 230 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 231 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 232 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 233 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 234 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 235 -Wl$(COMMA)--start-group $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) -Wl$(COMMA)--end-group \ 236 -o $(1)) 237endef 238 239define gb_LinkTarget__command_staticlink 240$(call gb_Helper_abbreviate_dirs,\ 241 mkdir -p $(dir $(1)) && \ 242 $(gb_AR) -rsu $(1) \ 243 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 244 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 245 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 246 2> /dev/null) 247endef 248 249define gb_LinkTarget__command 250$(call gb_Output_announce,$(2),$(true),LNK,4) 251$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 252$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 253endef 254 255 256# Library class 257 258gb_Library_DEFS := 259gb_Library_TARGETTYPEFLAGS := -shared -Wl,-z,noexecstack 260gb_Library_SYSPRE := lib 261gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 262gb_Library_PLAINEXT := .so 263gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 264ifeq ($(gb_PRODUCT),$(true)) 265gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 266else 267gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 268endif 269 270ifeq ($(CPUNAME),X86_64) 271gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 272gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 273else 274gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 275gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 276endif 277 278gb_Library_PLAINLIBS_NONE += \ 279 dl \ 280 freetype \ 281 jpeg \ 282 m \ 283 pthread \ 284 X11 \ 285 Xext \ 286 SM \ 287 ICE \ 288 z \ 289 cppunit 290 291gb_Library_FILENAMES := \ 292 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 293 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 294 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 295 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 296 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 297 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 298 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 299 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 300 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 301 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 302 303 304gb_Library_LAYER := \ 305 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 306 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 307 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 308 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 309 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 310 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 311 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 312 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 313 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 314 315define gb_Library_get_rpath 316'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' \ 317'-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION)' 318endef 319 320define gb_Library_Library_platform 321$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 322 323endef 324 325 326# StaticLibrary class 327 328gb_StaticLibrary_DEFS := 329gb_StaticLibrary_SYSPRE := lib 330gb_StaticLibrary_PLAINEXT := .a 331gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 332 333gb_StaticLibrary_FILENAMES := \ 334 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 335 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 336 337gb_StaticLibrary_StaticLibrary_platform = 338 339 340# Executable class 341 342gb_Executable_EXT := 343 344gb_Executable_LAYER := \ 345 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 346 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 347 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 348 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 349 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 350 351 352define gb_Executable_get_rpath 353'-Wl,-rpath,$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' \ 354-Wl,-rpath-link,$(gb_Library_OUTDIRLOCATION) 355endef 356 357define gb_Executable_Executable_platform 358$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 359 360endef 361 362 363# CppunitTest class 364 365gb_CppunitTest_CPPTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 366gb_CppunitTest_SYSPRE := libtest_ 367gb_CppunitTest_EXT := .so 368gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 369gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 370 371define gb_CppunitTest_CppunitTest_platform 372$(call gb_LinkTarget_get_target,$(2)) : RPATH := 373 374endef 375 376# JunitTest class 377 378define gb_JunitTest_JunitTest_platform 379$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 380 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/openoffice.org3/program/soffice}" \ 381 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 382 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 383 384endef 385 386# SdiTarget class 387 388gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 389 390# SrsPartMergeTarget 391 392gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 393 394# SrsPartTarget class 395 396gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 397gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 398 399define gb_SrsPartTarget__command_dep 400$(call gb_Helper_abbreviate_dirs,\ 401 $(gb_GCCP) \ 402 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 403 $(INCLUDE) \ 404 $(DEFS) \ 405 -c -x c++-header $(2) \ 406 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 407endef 408 409 410# ComponentTarget 411 412gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 413gb_Library_COMPONENTPREFIXES := \ 414 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 415 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 416 417 418# vim: set noet sw=4 ts=4: 419