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