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 261 $(gb_CXX) \ 262 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ 263 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 264 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 265 $(call gb_LinkTarget__get_liblinkflags,$(LINKED_LIBS)) \ 266 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 267 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 268 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \ 269 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 270 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \ 271 -o $(1) \ 272 `cat $${DYLIB_FILE}` && \ 273 $(if $(filter Library CppunitTest,$(TARGETTYPE)),\ 274 $(PERL) $(SOLARENV)/bin/macosx-change-install-names.pl Library $(LAYER) $(1) && \ 275 ln -sf $(1) $(patsubst %.dylib,%.jnilib,$(1)) &&) \ 276 rm -f $${DYLIB_FILE}) 277endef 278 279# parameters: 1-linktarget 2-cobjects 3-cxxobjects 280define gb_LinkTarget__command_staticlink 281$(call gb_Helper_abbreviate_dirs,\ 282 mkdir -p $(dir $(1)) && \ 283 $(gb_AR) -rsu $(1) \ 284 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 285 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 286 $(foreach object,$(OBJCXXOBJECTS),$(call gb_ObjCxxObject_get_target,$(object))) \ 287 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 288 2> /dev/null) 289endef 290 291define gb_LinkTarget__command 292$(call gb_Output_announce,$(2),$(true),LNK,4) 293$(if $(filter Library CppunitTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1),$(2))) 294$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 295endef 296 297 298# Library class 299 300gb_Library_DEFS := 301gb_Library_TARGETTYPEFLAGS := -dynamiclib -single_module 302gb_Library_SYSPRE := lib 303gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 304gb_Library_PLAINEXT := .dylib 305gb_Library_RTEXT := gcc3$(gb_Library_PLAINEXT) 306ifeq ($(gb_PRODUCT),$(true)) 307gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 308else 309gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 310endif 311 312ifeq ($(CPUNAME),INTEL) 313gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 314gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 315else # ifeq ($(CPUNAME),POWERPC) 316gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 317gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 318endif 319 320gb_Library__FRAMEWORKS := \ 321 Cocoa \ 322 323gb_Library_PLAINLIBS_NONE += \ 324 Cocoa \ 325 objc \ 326 jpeg \ 327 m \ 328 pthread \ 329 z \ 330 cppunit 331 332gb_Library_FILENAMES := \ 333 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 334 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 335 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 336 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 337 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 338 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 339 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 340 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 341 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 342 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 343 344 345gb_Library_LAYER := \ 346 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 347 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 348 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 349 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 350 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 351 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 352 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 353 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 354 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 355 356define gb_Library_get_rpath 357$(call gb_LinkTarget__get_installname,$(call gb_Library_get_filename,$(1)),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))) 358endef 359 360define gb_Library_Library_platform 361$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 362$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Library_get_layer,$(1)) 363 364endef 365 366 367# StaticLibrary class 368 369gb_StaticLibrary_DEFS := 370gb_StaticLibrary_SYSPRE := lib 371gb_StaticLibrary_PLAINEXT := .a 372gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 373 374gb_StaticLibrary_FILENAMES := \ 375 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 376 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 377 378gb_StaticLibrary_StaticLibrary_platform = 379 380 381# Executable class 382 383gb_Executable_EXT := 384gb_Executable_TARGETTYPEFLAGS := -bind_at_load 385 386gb_Executable_LAYER := \ 387 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 388 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 389 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 390 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 391 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 392 393 394define gb_Executable_get_rpath 395$(call gb_LinkTarget__get_installname,$(1),$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))) 396endef 397 398define gb_Executable_Executable_platform 399$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 400$(call gb_LinkTarget_get_target,$(2)) : LAYER := $(call gb_Executable_get_layer,$(1)) 401 402endef 403 404 405# CppunitTest class 406 407gb_CppunitTest_CPPTESTPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 408gb_CppunitTest_SYSPRE := libtest_ 409gb_CppunitTest_EXT := .dylib 410gb_CppunitTest_get_filename = $(gb_CppunitTest_SYSPRE)$(1)$(gb_CppunitTest_EXT) 411gb_CppunitTest_get_libfilename = $(gb_CppunitTest_get_filename) 412 413define gb_CppunitTest_CppunitTest_platform 414$(call gb_LinkTarget_get_target,$(2)) : RPATH := 415$(call gb_LinkTarget_get_target,$(2)) : LAYER := NONE 416 417endef 418 419# JunitTest class 420 421define gb_JunitTest_JunitTest_platform 422$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 423 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(OUTDIR)/installation/opt/OpenOffice.org.app/Contents/MacOS/soffice}" \ 424 -Dorg.openoffice.test.arg.env=DYLD_LIBRARY_PATH \ 425 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 426 427endef 428 429# SdiTarget class 430 431gb_SdiTarget_SVIDLPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 432 433# SrsPartMergeTarget 434 435gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 436 437# SrsPartTarget class 438 439gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 440gb_SrsPartTarget_RSCCOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 441 442define gb_SrsPartTarget__command_dep 443$(call gb_Helper_abbreviate_dirs,\ 444 $(gb_GCCP) \ 445 -MM -MT $(call gb_SrsPartTarget_get_target,$(1)) \ 446 $(INCLUDE) \ 447 $(DEFS) \ 448 -c -x c++-header $(2) \ 449 -o $(call gb_SrsPartTarget_get_dep_target,$(1))) 450endef 451 452 453# ComponentTarget 454 455gb_XSLTPROCPRECOMMAND := DYLD_LIBRARY_PATH=$(OUTDIR)/lib 456gb_Library_COMPONENTPREFIXES := \ 457 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 458 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 459 460 461# vim: set noet sw=4 ts=4: 462