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