1#************************************************************************* 2# 3# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4# 5# Copyright 2000, 2011 Oracle and/or its affiliates. 6# 7# OpenOffice.org - a multi-platform office productivity suite 8# 9# This file is part of OpenOffice.org. 10# 11# OpenOffice.org is free software: you can redistribute it and/or modify 12# it under the terms of the GNU Lesser General Public License version 3 13# only, as published by the Free Software Foundation. 14# 15# OpenOffice.org is distributed in the hope that it will be useful, 16# but WITHOUT ANY WARRANTY; without even the implied warranty of 17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18# GNU Lesser General Public License version 3 for more details 19# (a copy is included in the LICENSE file that accompanied this code). 20# 21# You should have received a copy of the GNU Lesser General Public License 22# version 3 along with OpenOffice.org. If not, see 23# <http://www.openoffice.org/license.html> 24# for a copy of the LGPLv3 License. 25# 26#************************************************************************* 27 28GUI := UNX 29COM := GCC 30 31# Darwin mktemp -t expects a prefix, not a pattern 32gb_MKTEMP ?= /usr/bin/mktemp -t gbuild. 33 34gb_CC := cc 35gb_CXX := g++ 36gb_GCCP := gcc 37gb_AR := ar 38gb_AWK := awk 39gb_CLASSPATHSEP := : 40 41# use CC/CXX if they are nondefaults 42ifneq ($(origin CC),default) 43gb_CC := $(CC) 44gb_GCCP := $(CC) 45endif 46ifneq ($(origin CXX),default) 47gb_CXX := $(CXX) 48endif 49 50gb_OSDEFS := \ 51 -D$(OS) \ 52 -D_PTHREADS \ 53 -DUNIX \ 54 -DUNX \ 55 -D_REENTRANT \ 56 -DNO_PTHREAD_PRIORITY \ 57 -DQUARTZ \ 58 $(EXTRA_CDEFS) \ 59 60gb_COMPILERDEFS := \ 61 -D$(COM) \ 62 -DHAVE_GCC_VISIBILITY_FEATURE \ 63 -DCPPU_ENV=gcc3 \ 64 -DGXX_INCLUDE_PATH=$(GXX_INCLUDE_PATH) \ 65 66ifeq ($(CPUNAME),POWERPC) 67gb_CPUDEFS := -DPOWERPC -DPPC 68else 69gb_CPUDEFS := -DX86 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-long-double \ 98 -Wno-non-virtual-dtor \ 99 -fPIC \ 100 -fmessage-length=0 \ 101 -fno-common \ 102 -fno-strict-aliasing \ 103 -fsigned-char \ 104 -malign-natural \ 105 -pipe \ 106 #-Wshadow \ break in compiler headers already 107 #-fsigned-char \ might be removed? 108 #-malign-natural \ might be removed? 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 -fno-enforce-eh-specs \ 123 124gb_LinkTarget_NOEXCEPTIONFLAGS := \ 125 -DEXCEPTIONS_OFF \ 126 -fno-exceptions \ 127 128gb_LinkTarget_LDFLAGS := \ 129 -Wl,-syslibroot,$(gb_SDKDIR) \ 130 $(subst -L../lib , ,$(SOLARLIB)) \ 131#man ld says: obsolete -Wl,-multiply_defined,suppress \ 132 133ifeq ($(gb_DEBUGLEVEL),2) 134gb_COMPILEROPTFLAGS := -O0 135else 136gb_COMPILEROPTFLAGS := -O2 137endif 138 139gb_COMPILERNOOPTFLAGS := -O0 140 141# Helper class 142 143gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 144 145# convert parametters filesystem root to native notation 146# does some real work only on windows, make sure not to 147# break the dummy implementations on unx* 148define gb_Helper_convert_native 149$(1) 150endef 151 152 153# CObject class 154 155define gb_CObject__command 156$(call gb_Output_announce,$(2),$(true),C ,3) 157$(call gb_Helper_abbreviate_dirs,\ 158 mkdir -p $(dir $(1)) && \ 159 mkdir -p $(dir $(call gb_CObject_get_dep_target,$(2))) && \ 160 $(gb_CC) \ 161 $(DEFS) $(CFLAGS) \ 162 -c $(3) \ 163 -o $(1) \ 164 -MMD -MT $(call gb_CObject_get_target,$(2)) \ 165 -MF $(call gb_CObject_get_dep_target,$(2)) \ 166 -I$(dir $(3)) \ 167 $(INCLUDE)) 168endef 169 170 171# CxxObject class 172 173# N.B: $(CXXFLAGS) may contain -x objective-c++, which must come before -c 174define gb_CxxObject__command 175$(call gb_Output_announce,$(2),$(true),CXX,3) 176$(call gb_Helper_abbreviate_dirs,\ 177 mkdir -p $(dir $(1)) && \ 178 mkdir -p $(dir $(call gb_CxxObject_get_dep_target,$(2))) && \ 179 $(gb_CXX) \ 180 $(DEFS) $(CXXFLAGS) \ 181 -c $(3) \ 182 -o $(1) \ 183 -MMD -MT $(call gb_CxxObject_get_target,$(2)) \ 184 -MF $(call gb_CxxObject_get_dep_target,$(2)) \ 185 -I$(dir $(3)) \ 186 $(INCLUDE_STL) $(INCLUDE)) 187endef 188 189 190# ObjCxxObject class 191 192define gb_ObjCxxObject__command 193$(call gb_Output_announce,$(2),$(true),OCX,3) 194$(call gb_Helper_abbreviate_dirs,\ 195 mkdir -p $(dir $(1)) && \ 196 mkdir -p $(dir $(call gb_ObjCxxObject_get_dep_target,$(2))) && \ 197 $(gb_CXX) \ 198 $(DEFS) $(OBJCXXFLAGS) \ 199 -c $(3) \ 200 -o $(1) \ 201 -MMD -MT $(call gb_ObjCxxObject_get_target,$(2)) \ 202 -MF $(call gb_ObjCxxObject_get_dep_target,$(2)) \ 203 -I$(dir $(3)) \ 204 $(INCLUDE_STL) $(INCLUDE)) 205endef 206 207 208# LinkTarget class 209 210define gb_LinkTarget__get_rpath_for_layer 211$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 212endef 213 214gb_LinkTarget__RPATHS := \ 215 URELIB:@__________________________________________________URELIB/ \ 216 UREBIN: \ 217 OOO:@__________________________________________________OOO/ \ 218 BRAND: \ 219 SDKBIN: \ 220 NONEBIN: \ 221 222define gb_LinkTarget__get_installname 223$(if $(2),-install_name '$(2)$(1)',) 224endef 225 226gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) $(gb_COMPILEROPTFLAGS) 227gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 228gb_LinkTarget_OBJCXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) $(gb_OBJCXXFLAGS) $(gb_COMPILEROPTFLAGS) 229 230ifeq ($(gb_DEBUGLEVEL),2) 231gb_LinkTarget_CFLAGS += -g 232gb_LinkTarget_CXXFLAGS += -g 233gb_LinkTarget_OBJCXXFLAGS += -g 234endif 235 236gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 237gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 238 239# FIXME framework handling very hackish 240define gb_LinkTarget__get_liblinkflags 241$(patsubst lib%.dylib,-l%,$(foreach lib,$(filter-out $(gb_Library__FRAMEWORKS),$(1)),$(call gb_Library_get_filename,$(lib)))) \ 242$(addprefix -framework ,$(filter $(gb_Library__FRAMEWORKS),$(1))) 243endef 244 245define gb_LinkTarget__get_layer 246$(if $(filter Executable,$(1)),\ 247 $$(call gb_Executable_get_layer,$(2)),\ 248 $$(call gb_Library_get_layer,$(2))) 249endef 250 251# FIXME the DYLIB_FILE mess is only necessary because 252# solver layout is different from installation layout 253define gb_LinkTarget__command_dynamiclink 254$(call gb_Helper_abbreviate_dirs,\ 255 mkdir -p $(dir $(1)) && \ 256 DYLIB_FILE=`$(gb_MKTEMP)` && \ 257 $(PERL) $(SOLARENV)/bin/macosx-dylib-link-list.pl \ 258 $(if $(filter Executable,$(TARGETTYPE)),$(gb_Executable_TARGETTYPEFLAGS)) \ 259 $(if $(filter Library CppunitTest,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 260 $(subst \d,$$,$(RPATH)) $(LDFLAGS) \ 261 $(patsubst lib%.dylib,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) > $${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 := gcc3$(gb_Library_PLAINEXT) 307ifeq ($(gb_PRODUCT),$(true)) 308gb_Library_STLEXT := port_gcc$(gb_Library_PLAINEXT) 309else 310gb_Library_STLEXT := port_gcc_stldebug$(gb_Library_PLAINEXT) 311endif 312 313ifeq ($(CPUNAME),INTEL) 314gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 315gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 316else # ifeq ($(CPUNAME),POWERPC) 317gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 318gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 319endif 320 321gb_Library__FRAMEWORKS := \ 322 Cocoa \ 323 324gb_Library_PLAINLIBS_NONE += \ 325 Cocoa \ 326 objc \ 327 jpeg \ 328 m \ 329 pthread \ 330 z \ 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