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