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