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