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,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 239 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \ 240 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 241 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 242 $(LIBS) \ 243 -o $(if $(call gb_Library_is_udk_versioned,$(1)),$(1).$(gb_UDK_MAJOR),$(1))) 244endef 245 246define gb_LinkTarget__command_symlink_udk_versioned_library 247 $(if $(call gb_Library_is_udk_versioned,$(1)), 248 $(call gb_Helper_abbreviate_dirs,\ 249 rm -f $(1) && ln -s $(notdir $(1)).$(gb_UDK_MAJOR) $(1))) 250endef 251 252define gb_LinkTarget__command_staticlink 253$(call gb_Helper_abbreviate_dirs,\ 254 mkdir -p $(dir $(1)) && \ 255 $(gb_AR) -rsu $(1) \ 256 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 257 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 258 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 259 2> /dev/null) 260endef 261 262define gb_LinkTarget__command 263$(call gb_Output_announce,$(2),$(true),LNK,4) 264$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 265$(if $(filter Library,$(TARGETTYPE)),$(call gb_LinkTarget__command_symlink_udk_versioned_library,$(1))) 266$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 267endef 268 269# Library class 270 271gb_Library_DEFS := 272gb_Library_TARGETTYPEFLAGS := -Bdynamic -z text -G 273gb_Library_SYSPRE := lib 274gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 275gb_Library_PLAINEXT := .so 276gb_Library_RTEXT := C52$(gb_Library_PLAINEXT) 277ifeq ($(gb_PRODUCT),$(true)) 278gb_Library_STLEXT := port_sunpro$(gb_Library_PLAINEXT) 279else 280gb_Library_STLEXT := port_sunpro_debug$(gb_Library_PLAINEXT) 281endif 282gb_Library_VERSIONMAPFLAG := -M 283 284ifeq ($(CPUNAME),INTEL) 285gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 286gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 287else # ifeq ($(CPUNAME),SPARC) 288gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 289gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 290endif 291 292gb_STDLIBS := \ 293 Crun \ 294 m \ 295 c \ 296 297gb_Library_PLAINLIBS_NONE += \ 298 $(gb_STDLIBS) \ 299 dl \ 300 freetype \ 301 nsl \ 302 pthread \ 303 socket \ 304 X11 \ 305 Xext \ 306 SM \ 307 ICE 308 309gb_Library_FILENAMES := \ 310 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 311 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 312 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 313 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 314 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 315 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 316 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 317 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 318 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 319 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 320 321 322gb_Library_LAYER := \ 323 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 324 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 325 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 326 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 327 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 328 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 329 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 330 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 331 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 332 333define gb_Library_get_rpath 334'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' 335endef 336 337define gb_Library_Library_platform 338$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 339 340ifneq (,$(call gb_Library_is_udk_versioned,$(call gb_Library_get_target,$(1)))) 341$(call gb_Library_get_target,$(1)) \ 342$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS += \ 343 $(call gb_Library_get_target,$(1)).$(gb_UDK_MAJOR) 344endif 345endef 346 347 348# StaticLibrary class 349 350gb_StaticLibrary_DEFS := 351gb_StaticLibrary_SYSPRE := lib 352gb_StaticLibrary_PLAINEXT := .a 353gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 354 355gb_StaticLibrary_FILENAMES := \ 356 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 357 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 358 359gb_StaticLibrary_StaticLibrary_platform = 360 361 362# Executable class 363 364gb_Executable_EXT := 365 366gb_Executable_LAYER := \ 367 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 368 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 369 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 370 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 371 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 372 373 374define gb_Executable_get_rpath 375'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' 376endef 377 378define gb_Executable_Executable_platform 379$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 380 381endef 382 383 384# GoogleTest class 385 386gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 387gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) 388 389define gb_GoogleTest_GoogleTest_platform 390$(call gb_LinkTarget_get_target,$(2)) : RPATH := 391endef 392 393# JunitTest class 394 395define gb_JunitTest_JunitTest_platform 396$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 397 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \ 398 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 399 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 400 401endef 402 403 404# Ant class 405 406define gb_Ant_add_dependencies 407__ant_out:=$(shell $(gb_Ant_ANTCOMMAND) -v -Ddependencies.outfile=$(WORKDIR)/Ant/$(1)/deps -f $(2) dependencies) 408$$(eval $(foreach dep,$(shell cat $(WORKDIR)/Ant/$(1)/deps),$$(call gb_Ant_add_dependency,$(call gb_Ant_get_target,$(1)),$(dep)))) 409 410endef 411 412 413# SdiTarget class 414 415gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 416 417# SrsPartMergeTarget 418 419gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 420 421# SrsPartTarget class 422 423gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 424gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 425 426# Sun cc/CC support -xM1/-xMF flags, but unfortunately refuse input files that 427# do not have the right suffix, so use makedepend here... 428define gb_SrsPartTarget__command_dep 429$(call gb_Helper_abbreviate_dirs_native,\ 430 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 431 $(INCLUDE) \ 432 $(DEFS) \ 433 $(2) \ 434 -f - \ 435 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 436 -v OBJECTFILE=$(call gb_SrsPartTarget_get_target,$(1)) \ 437 -v OUTDIR=$(OUTDIR)/ \ 438 -v WORKDIR=$(WORKDIR)/ \ 439 -v SRCDIR=$(SRCDIR)/ \ 440 -v REPODIR=$(REPODIR)/ \ 441 > $(call gb_SrsPartTarget_get_dep_target,$(1))) 442endef 443 444 445# ComponentTarget 446 447gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 448gb_Library_COMPONENTPREFIXES := \ 449 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 450 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 451 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 452 453# UnoApiTarget 454 455gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc 456gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 457gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge 458gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 459gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare 460gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 461gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker 462gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 463gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview 464gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 465 466# vim: set noet sw=4 ts=4: 467