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 := C52 26 27gb_MKTEMP := mktemp -t gbuild.XXXXXX 28 29gb_CC := cc 30gb_CXX := CC 31gb_GCCP := cc 32gb_AR := ar 33gb_AWK := /usr/xpg4/bin/awk 34gb_CLASSPATHSEP := : 35 36# use CC/CXX if they are nondefaults 37ifneq ($(origin CC),default) 38gb_CC := $(CC) 39gb_GCCP := $(CC) 40endif 41ifneq ($(origin CXX),default) 42gb_CXX := $(CXX) 43endif 44 45gb_OSDEFS := \ 46 -D$(OS) \ 47 -D$(GUI) \ 48 -DSYSV \ 49 -DSUN \ 50 -DSUN4 \ 51 -D_REENTRANT \ 52 -D_POSIX_PTHREAD_SEMANTICS \ 53 -D_PTHREADS \ 54 -DUNIX \ 55 56gb_COMPILERDEFS := \ 57 -D$(COM) \ 58 -DCPPU_ENV=$(COMNAME) \ 59 60gb_CPUDEFS := -D$(ALIGN) -D$(CPUNAME) 61ifeq ($(CPUNAME),SPARC) 62gb_CPUDEFS += -D__sparcv8plus 63endif 64 65gb_CFLAGS := \ 66 -temp=/tmp \ 67 -KPIC \ 68 -mt \ 69 -xldscope=hidden \ 70 -xCC \ 71 -xc99=none \ 72 73gb_CXXFLAGS := \ 74 -temp=/tmp \ 75 -KPIC \ 76 -mt \ 77 -xldscope=hidden \ 78 -features=no%altspell \ 79 -library=no%Cstd \ 80 +w2 \ 81 -erroff=doubunder,identexpected,inllargeuse,inllargeint,notemsource,reftotemp,truncwarn,wnoretvalue,anonnotype \ 82 83ifneq ($(EXTERNAL_WARNINGS_NOT_ERRORS),TRUE) 84gb_CFLAGS_WERROR := -errwarn=%all 85gb_CXXFLAGS_WERROR := -xwe 86endif 87 88gb_LinkTarget_EXCEPTIONFLAGS := \ 89 -DEXCEPTIONS_ON \ 90 91gb_LinkTarget_NOEXCEPTIONFLAGS := \ 92 -DEXCEPTIONS_OFF \ 93 -noex \ 94 95gb_LinkTarget_LDFLAGS := \ 96 $(subst -L../lib , ,$(SOLARLIB)) \ 97 -temp=/tmp \ 98 -w \ 99 -mt \ 100 -Bdirect \ 101 -z defs \ 102 -z combreloc \ 103 -norunpath \ 104 -PIC \ 105 -library=no%Cstd \ 106 107 108gb_DEBUG_CFLAGS := -g 109 110ifeq ($(gb_DEBUGLEVEL),2) 111gb_COMPILEROPTFLAGS := 112gb_COMPILEROPT1FLAGS := 113else 114ifeq ($(CPUNAME),INTEL) 115gb_COMPILEROPTFLAGS := -xarch=generic -xO3 116gb_COMPILEROPT1FLAGS := -xarch=generic -xO1 117else # ifeq ($(CPUNAME),SPARC) 118# -m32 -xarch=sparc restrict target to 32 bit sparc 119# -xO3 optimization level 3 120# -xspace don't do optimizations which do increase binary size 121# -xprefetch=yes do prefetching (helps on UltraSparc III) 122gb_COMPILEROPTFLAGS := -m32 -xarch=sparc -xO3 -xspace -xprefetch=yes 123gb_COMPILEROPT1FLAGS := -m32 -xarch=sparc -xO1 -xspace -xprefetch=yes 124endif 125endif 126 127gb_COMPILERNOOPTFLAGS := 128 129# Helper class 130 131gb_Helper_abbreviate_dirs_native = $(gb_Helper_abbreviate_dirs) 132 133# convert parametters filesystem root to native notation 134# does some real work only on windows, make sure not to 135# break the dummy implementations on unx* 136define gb_Helper_convert_native 137$(1) 138endef 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# AsmObject class 149 150gb_AsmObject_EXT := .s 151 152define gb_AsmObject__command 153$(call gb_Output_announce,$(2),$(true),ASM,3) 154$(call gb_Helper_abbreviate_dirs,\ 155 mkdir -p $(dir $(1)) && \ 156 $(gb_CC) \ 157 $(DEFS) \ 158 $(T_CFLAGS) \ 159 $(CFLAGS) \ 160 -c $(3) \ 161 -o $(1) \ 162 -I$(dir $(3)) \ 163 $(INCLUDE)) 164endef 165 166# CObject class 167 168define gb_CObject__command 169$(call gb_Output_announce,$(2),$(true),C ,3) 170$(call gb_Helper_abbreviate_dirs,\ 171 rm -f $(4) && \ 172 mkdir -p $(dir $(1)) $(dir $(4)) && \ 173 $(gb_CC) \ 174 -c $(3) \ 175 -o $(1) \ 176 -xMMD \ 177 -xMF $(4) \ 178 $(DEFS) \ 179 $(T_CFLAGS) \ 180 $(CFLAGS) \ 181 -I$(dir $(3)) \ 182 $(INCLUDE)) 183endef 184 185 186# CxxObject class 187 188define gb_CxxObject__command 189$(call gb_Output_announce,$(2),$(true),CXX,3) 190$(call gb_Helper_abbreviate_dirs,\ 191 mkdir -p $(dir $(1)) $(dir $(4)) && \ 192 $(gb_CXX) \ 193 $(DEFS) \ 194 $(T_CXXFLAGS) \ 195 $(CXXFLAGS) \ 196 -c $(3) \ 197 -o $(1) \ 198 -xMMD \ 199 -xMF $(4) \ 200 -I$(dir $(3)) \ 201 $(INCLUDE_STL) $(INCLUDE)) 202endef 203 204 205# LinkTarget class 206 207define gb_LinkTarget__get_rpath_for_layer 208$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 209endef 210 211gb_LinkTarget__RPATHS := \ 212 URELIB:\dORIGIN \ 213 UREBIN:\dORIGIN/../lib:\dORIGIN \ 214 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 215 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 216 SDKBIN:\dORIGIN/../../ure-link/lib \ 217 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 218 219gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) 220gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 221 222 223gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 224gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 225 226define gb_LinkTarget__command_dynamiclink 227$(call gb_Helper_abbreviate_dirs,\ 228 mkdir -p $(dir $(1)) && \ 229 $(gb_CXX) \ 230 $(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 231 $(if $(VERSIONMAP),$(gb_Library_VERSIONMAPFLAG) $(VERSIONMAP)) \ 232 $(if $(call gb_Library_is_udk_versioned,$(1)),-Wl$(COMMA)-h$(notdir $(1)).$(gb_UDK_MAJOR)) \ 233 $(subst \d,$$,$(RPATH)) \ 234 $(T_LDFLAGS) \ 235 $(foreach object,$(ASMOBJECTS),$(call gb_AsmObject_get_target,$(object))) \ 236 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 237 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 238 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \ 239 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 240 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \ 241 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 242 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 243 $(LIBS) \ 244 -o $(if $(call gb_Library_is_udk_versioned,$(1)),$(1).$(gb_UDK_MAJOR),$(1))) 245endef 246 247define gb_LinkTarget__command_symlink_udk_versioned_library 248 $(if $(call gb_Library_is_udk_versioned,$(1)), 249 $(call gb_Helper_abbreviate_dirs,\ 250 rm -f $(1) && ln -s $(notdir $(1)).$(gb_UDK_MAJOR) $(1))) 251endef 252 253define gb_LinkTarget__command_staticlink 254$(call gb_Helper_abbreviate_dirs,\ 255 mkdir -p $(dir $(1)) && \ 256 $(gb_AR) -rsu $(1) \ 257 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 258 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 259 $(foreach object,$(GENCOBJECTS),$(call gb_GenCObject_get_target,$(object))) \ 260 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 261 2> /dev/null) 262endef 263 264define gb_LinkTarget__command 265$(call gb_Output_announce,$(2),$(true),LNK,4) 266$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 267$(if $(filter Library,$(TARGETTYPE)),$(call gb_LinkTarget__command_symlink_udk_versioned_library,$(1))) 268$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 269endef 270 271# Library class 272 273gb_Library_DEFS := 274gb_Library_TARGETTYPEFLAGS := -Bdynamic -z text -G 275gb_Library_SYSPRE := lib 276gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 277gb_Library_PLAINEXT := .so 278gb_Library_RTEXT := C52$(gb_Library_PLAINEXT) 279ifeq ($(gb_PRODUCT),$(true)) 280gb_Library_STLEXT := port_sunpro$(gb_Library_PLAINEXT) 281else 282gb_Library_STLEXT := port_sunpro_debug$(gb_Library_PLAINEXT) 283endif 284gb_Library_VERSIONMAPFLAG := -M 285 286ifeq ($(CPUNAME),INTEL) 287gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 288gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 289else # ifeq ($(CPUNAME),SPARC) 290gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 291gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 292endif 293 294gb_STDLIBS := \ 295 Crun \ 296 m \ 297 c \ 298 299gb_Library_PLAINLIBS_NONE += \ 300 $(gb_STDLIBS) \ 301 dl \ 302 freetype \ 303 nsl \ 304 pthread \ 305 socket \ 306 X11 \ 307 Xext \ 308 SM \ 309 ICE 310 311gb_Library_FILENAMES := \ 312 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 313 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 314 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 315 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 316 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 317 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 318 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 319 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 320 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 321 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 322 323 324gb_Library_LAYER := \ 325 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 326 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 327 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 328 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 329 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 330 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 331 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 332 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 333 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 334 335define gb_Library_get_rpath 336'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' 337endef 338 339define gb_Library_Library_platform 340$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 341 342ifneq (,$(call gb_Library_is_udk_versioned,$(call gb_Library_get_target,$(1)))) 343$(call gb_Library_get_target,$(1)) \ 344$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS += \ 345 $(call gb_Library_get_target,$(1)).$(gb_UDK_MAJOR) 346endif 347endef 348 349 350# StaticLibrary class 351 352gb_StaticLibrary_DEFS := 353gb_StaticLibrary_SYSPRE := lib 354gb_StaticLibrary_PLAINEXT := .a 355gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 356 357gb_StaticLibrary_FILENAMES := \ 358 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 359 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 360 361gb_StaticLibrary_StaticLibrary_platform = 362 363 364# Executable class 365 366gb_Executable_EXT := 367 368gb_InBuild_Library_Path := $(OUTDIR)/lib 369gb_Augment_Library_Path := LD_LIBRARY_PATH=$(gb_InBuild_Library_Path) 370 371gb_Executable_LAYER := \ 372 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 373 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 374 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 375 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 376 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 377 378 379define gb_Executable_get_rpath 380'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' 381endef 382 383define gb_Executable_Executable_platform 384$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 385 386endef 387 388 389# GoogleTest class 390 391gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 392gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) 393 394define gb_GoogleTest_GoogleTest_platform 395$(call gb_LinkTarget_get_target,$(2)) : RPATH := 396endef 397 398# JunitTest class 399 400define gb_JunitTest_JunitTest_platform 401$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 402 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \ 403 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 404 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 405 406endef 407 408 409# Ant class 410 411define gb_Ant_add_dependencies 412__ant_out:=$(shell $(gb_Ant_ANTCOMMAND) -v -Ddependencies.outfile=$(WORKDIR)/Ant/$(1)/deps -f $(2) dependencies) 413$$(eval $(foreach dep,$(shell cat $(WORKDIR)/Ant/$(1)/deps),$$(call gb_Ant_add_dependency,$(call gb_Ant_get_target,$(1)),$(dep)))) 414 415endef 416 417 418# SdiTarget class 419 420gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 421 422# SrsPartMergeTarget 423 424gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 425 426# SrsPartTarget class 427 428gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 429gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 430 431# Sun cc/CC support -xM1/-xMF flags, but unfortunately refuse input files that 432# do not have the right suffix, so use makedepend here... 433define gb_SrsPartTarget__command_dep 434$(call gb_Helper_abbreviate_dirs_native,\ 435 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 436 $(INCLUDE) \ 437 $(DEFS) \ 438 $(2) \ 439 -f - \ 440 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 441 -v OBJECTFILE=$(call gb_SrsPartTarget_get_target,$(1)) \ 442 -v OUTDIR=$(OUTDIR)/ \ 443 -v WORKDIR=$(WORKDIR)/ \ 444 -v SRCDIR=$(SRCDIR)/ \ 445 -v REPODIR=$(REPODIR)/ \ 446 > $(call gb_SrsPartTarget_get_dep_target,$(1))) 447endef 448 449 450# ComponentTarget 451 452gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 453gb_Library_COMPONENTPREFIXES := \ 454 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 455 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 456 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 457 458# UnoApiTarget 459 460gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc 461gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 462gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge 463gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 464gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare 465gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 466gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker 467gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 468gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview 469gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 470 471# vim: set noet sw=4 ts=4: 472