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