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 22 23 24GUI := UNX 25COM := S5ABI 26COMID := s5abi 27#COM := S5ABI 28#COMID := s5abi 29 30# Darwin mktemp -t expects a prefix, not a pattern 31gb_MKTEMP ?= /usr/bin/mktemp -t gbuild. 32 33gb_CC := cc 34gb_CXX := g++ 35gb_GCCP := gcc 36gb_AR := ar 37gb_AWK := awk 38gb_CLASSPATHSEP := : 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 -D_REENTRANT \ 55 -DNO_PTHREAD_PRIORITY \ 56 -DQUARTZ \ 57 $(EXTRA_CDEFS) \ 58 59gb_COMPILERDEFS := \ 60 -D$(COM) \ 61 -DHAVE_GCC_VISIBILITY_FEATURE \ 62 -DCPPU_ENV=$(COMID) \ 63 -DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \ 64 65ifeq ($(CPUNAME),POWERPC) 66gb_CPUDEFS := -DPOWERPC -DPPC 67else ifeq ($(CPUNAME),INTEL) 68gb_CPUDEFS := -DX86 69else ifeq ($(CPUNAME),X86_64) 70gb_CPUDEFS := -DX86_64 71endif 72 73ifeq ($(strip $(SYSBASE)),) 74 gb_SDKDIR := $(MACOSX_SDK_PATH) 75else 76 gb_SDKDIR := $(SYSBASE)/MacOSX$(MACOSX_DEPLOYMENT_TARGET).sdk 77endif 78 79 80gb_CFLAGS := \ 81 -isysroot $(gb_SDKDIR) \ 82 -Wall \ 83 -Wendif-labels \ 84 -Wextra \ 85 -Wshadow \ 86 -fPIC \ 87 -fmessage-length=0 \ 88 -fno-common \ 89 -fno-strict-aliasing \ 90 -pipe \ 91 92gb_CXXFLAGS := \ 93 -isysroot $(gb_SDKDIR) \ 94 -Wall \ 95 -Wendif-labels \ 96 -Wextra \ 97 -Wno-ctor-dtor-privacy \ 98 -Wno-non-virtual-dtor \ 99 -fPIC \ 100 -fmessage-length=0 \ 101 -fno-common \ 102 -fno-strict-aliasing \ 103 -fsigned-char \ 104 -pipe 105 106ifneq ($(COM),GCC) 107 gb_CXXFLAGS += -DHAVE_STL_INCLUDE_PATH -I../v1/ 108endif 109 110ifeq ($(MACOSX_DEPLOYMENT_TARGET),$(filter $(MACOSX_DEPLOYMENT_TARGET), 10.7 10.8)) 111 gb_CXXFLAGS += -std=c++11 -stdlib=libc++ 112 gb_macos_LDFLAGS := -std=c++11 -stdlib=libc++ 113endif 114 115# these are to get g++ to switch to Objective-C++ mode 116# (see toolkit module for a case where it is necessary to do it this way) 117gb_OBJCXXFLAGS := -x objective-c++ -fobjc-exceptions 118 119ifneq ($(MACOSX_DEPLOYMENT_TARGET),) 120 gb_CXXFLAGS += -DMAC_OS_X_VERSION_MAX_ALLOWED=MAC_OS_X_VERSION_$(subst .,_,$(MACOSX_DEPLOYMENT_TARGET)) 121endif 122 123ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE) 124gb_CFLAGS_WERROR := -Werror -Wno-error=deprecated 125gb_CXXFLAGS_WERROR := -Werror -Wno-error=deprecated 126endif 127 128gb_LinkTarget_EXCEPTIONFLAGS := \ 129 -DEXCEPTIONS_ON \ 130 -fexceptions 131 132ifeq ($(COM),GCC) 133 gb_LinkTarget_EXCEPTIONFLAGS += -fno-enforce-eh-specs 134endif 135 136gb_LinkTarget_NOEXCEPTIONFLAGS := \ 137 -DEXCEPTIONS_OFF \ 138 -fno-exceptions 139 140gb_LinkTarget_LDFLAGS := \ 141 -Wl,-syslibroot,$(gb_SDKDIR) \ 142 $(subst -L../lib , ,$(SOLARLIB)) \ 143#man ld says: obsolete -Wl,-multiply_defined,suppress \ 144 145ifeq ($(ENABLE_SYMBOLS),SMALL) 146gb_DEBUG_CFLAGS := -g1 147else 148gb_DEBUG_CFLAGS := -g3 149endif 150 151ifeq ($(gb_DEBUGLEVEL),2) 152gb_COMPILEROPTFLAGS := -O0 153else 154gb_COMPILEROPTFLAGS := -O2 155endif 156 157gb_COMPILERNOOPTFLAGS := -O0 158 159# Helper class 160 161gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 162 163# convert parametters filesystem root to native notation 164# does some real work only on windows, make sure not to 165# break the dummy implementations on unx* 166define gb_Helper_convert_native 167$(1) 168endef 169 170# convert parametters filesystem root to native notation 171# does some real work only on windows, make sure not to 172# break the dummy implementations on unx* 173define gb_Helper_convert_native 174$(1) 175endef 176 177 178# CObject class 179 180define gb_CObject__command 181$(call gb_Output_announce,$(2),$(true),C ,3) 182$(call gb_Helper_abbreviate_dirs,\ 183 mkdir -p $(dir $(1)) $(dir $(4)) && \ 184 $(gb_CC) \ 185 $(DEFS) \ 186 $(T_CFLAGS) \ 187 -c $(3) \ 188 -o $(1) \ 189 -MMD -MT $(1) \ 190 -MF $(4) \ 191 -I$(dir $(3)) \ 192 $(INCLUDE)) 193endef 194 195 196# CxxObject class 197 198# N.B: $(CXXFLAGS) may contain -x objective-c++, which must come before -c 199define gb_CxxObject__command 200$(call gb_Output_announce,$(2),$(true),CXX,3) 201$(call gb_Helper_abbreviate_dirs,\ 202 mkdir -p $(dir $(1)) $(dir $(4)) && \ 203 $(gb_CXX) \ 204 $(DEFS) \ 205 $(T_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# ObjCxxObject class 216 217define gb_ObjCxxObject__command 218$(call gb_Output_announce,$(2),$(true),OCX,3) 219$(call gb_Helper_abbreviate_dirs,\ 220 mkdir -p $(dir $(1)) $(dir $(4)) && \ 221 $(gb_CXX) \ 222 $(DEFS) \ 223 $(T_OBJCXXFLAGS) \ 224 -c $(3) \ 225 -o $(1) \ 226 -MMD -MT $(1) \ 227 -MF $(4) \ 228 -I$(dir $(3)) \ 229 $(INCLUDE_STL) $(INCLUDE)) 230endef 231 232 233# LinkTarget class 234 235define gb_LinkTarget__get_rpath_for_layer 236$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 237endef 238 239gb_LinkTarget__RPATHS := \ 240 URELIB:@__________________________________________________URELIB/ \ 241 UREBIN: \ 242 OOO:@__________________________________________________OOO/ \ 243 BRAND: \ 244 SDKBIN: \ 245 NONEBIN: \ 246 247define gb_LinkTarget__get_installname 248$(if $(2),-install_name '$(2)$(1)',) 249endef 250 251gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) 252gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 253gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) $(gb_OBJCXXFLAGS) 254 255gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 256gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 257 258# FIXME framework handling very hackish 259define gb_LinkTarget__get_liblinkflags 260$(patsubst lib%.dylib,-l%,$(foreach lib,$(filter-out $(gb_Library__FRAMEWORKS),$(1)),$(call gb_Library_get_filename,$(lib)))) \ 261$(addprefix -framework ,$(filter $(gb_Library__FRAMEWORKS),$(1))) 262endef 263 264define gb_LinkTarget__get_layer 265$(if $(filter Executable,$(1)),\ 266 $$(call gb_Executable_get_layer,$(2)),\ 267 $$(call gb_Library_get_layer,$(2))) 268endef 269 270# FIXME the DYLIB_FILE mess is only necessary because 271# solver layout is different from installation layout 272define gb_LinkTarget__command_dynamiclink 273$(call gb_Helper_abbreviate_dirs,\ 274 mkdir -p $(dir $(1)) && \ 275 DYLIB_FILE=`$(gb_MKTEMP)` && \ 276 $(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \ 277 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ 278 $(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 279 $(subst \d,$$,$(RPATH)) \ 280 $(T_LDFLAGS) \ 281 $(patsubst lib%.dylib,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 282 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 283 > $${DYLIB_FILE} && \ 284 $(gb_CXX) \ 285 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ 286 $(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 287 $(subst \d,$$,$(RPATH)) \ 288 $(T_LDFLAGS) $(gb_macos_LDFLAGS) \ 289 $(if $(VERSIONMAP),$(gb_Library_VERSIONMAPFLAG) $(VERSIONMAP)) \ 290 $(call gb_LinkTarget__get_liblinkflags,$(LINKED_LIBS)) \ 291 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 292 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 293 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \ 294 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 295 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \ 296 $(LIBS) \ 297 -o $(1) \ 298 `cat $${DYLIB_FILE}` && \ 299 $(if $(filter Library,$(TARGETTYPE)),\ 300 $(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl Library $(LAYER) $(1) && \ 301 ln -sf $(1) $(patsubst %.dylib,%.jnilib,$(1)) &&) \ 302 rm -f $${DYLIB_FILE}) 303endef 304 305# parameters: 1-linktarget 2-cobjects 3-cxxobjects 306define gb_LinkTarget__command_staticlink 307$(call gb_Helper_abbreviate_dirs,\ 308 mkdir -p $(dir $(1)) && \ 309 $(gb_AR) -rsu $(1) \ 310 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 311 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 312 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \ 313 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 314 2> /dev/null) 315endef 316 317define gb_LinkTarget__command 318$(call gb_Output_announce,$(2),$(true),LNK,4) 319$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2))) 320$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 321endef 322 323 324# Library class 325 326gb_Library_DEFS := 327gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module 328gb_Library_VERSIONMAPFLAG := -Wl,-exported_symbols_list 329gb_Library_SYSPRE := lib 330gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 331gb_Library_PLAINEXT := .dylib 332gb_Library_RTEXT := $(COMID)$(gb_Library_PLAINEXT) 333 334gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 335gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 336 337gb_Library__FRAMEWORKS := \ 338 Cocoa \ 339 340gb_Library_PLAINLIBS_NONE += \ 341 Cocoa \ 342 objc \ 343 m \ 344 pthread 345 346gb_Library_FILENAMES := \ 347 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 348 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 349 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 350 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 351 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 352 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 353 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 354 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 355 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 356 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 357 358 359gb_Library_LAYER := \ 360 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 361 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 362 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 363 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 364 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 365 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 366 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 367 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 368 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 369 370define gb_Library_get_rpath 371$(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))) 372endef 373 374define gb_Library_Library_platform 375$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 376$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1)) 377 378endef 379 380 381# StaticLibrary class 382 383gb_StaticLibrary_DEFS := 384gb_StaticLibrary_SYSPRE := lib 385gb_StaticLibrary_PLAINEXT := .a 386gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 387 388gb_StaticLibrary_FILENAMES := \ 389 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 390 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 391 392gb_StaticLibrary_StaticLibrary_platform = 393 394 395# Executable class 396 397gb_Executable_EXT := 398gb_Executable_TARGETTYPEFLAGS := -bind_at_load 399 400gb_Executable_LAYER := \ 401 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 402 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 403 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 404 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 405 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 406 407 408define gb_Executable_get_rpath 409$(call gb_LinkTarget__get_installname,$(1),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))) 410endef 411 412define gb_Executable_Executable_platform 413$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 414$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1)) 415 416endef 417 418 419# GoogleTest class 420 421gb_GoogleTest_GTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 422gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) 423 424define gb_GoogleTest_GoogleTest_platform 425$(call gb_LinkTarget_get_target,$(2)) : RPATH := 426endef 427 428# JunitTest class 429 430define gb_JunitTest_JunitTest_platform 431$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 432 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \ 433 -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH \ 434 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 435 436endef 437 438# SdiTarget class 439 440gb_SdiTarget_SVIDLPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 441 442# SrsPartMergeTarget 443 444gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 445 446# SrsPartTarget class 447 448gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 449gb_SrsPartTarget_RSCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 450 451define gb_SrsPartTarget__command_dep 452$(call gb_Helper_abbreviate_dirs,\ 453 $(gb_GCCP) \ 454 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 455 $(INCLUDE) \ 456 $(DEFS) \ 457 -c -x c++-header $(2) \ 458 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 459endef 460 461 462# ComponentTarget 463 464gb_XSLTPROCPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 465gb_Library_COMPONENTPREFIXES := \ 466 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 467 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 468 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 469 470# UnoApiTarget 471 472gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc 473gb_UnoApiTarget_IDLCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 474gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge 475gb_UnoApiTarget_REGMERGECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 476gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare 477gb_UnoApiTarget_REGCOMPARECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 478gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker 479gb_UnoApiTarget_CPPUMAKERCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 480gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview 481gb_UnoApiTarget_REGVIEWCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 482 483 484# vim: set noet sw=4 ts=4: 485