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