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# CObject class 149 150define gb_CObject__command 151$(call gb_Output_announce,$(2),$(true),C ,3) 152$(call gb_Helper_abbreviate_dirs,\ 153 rm -f $(4) && \ 154 mkdir -p $(dir $(1)) $(dir $(4)) && \ 155 $(gb_CC) \ 156 -c $(3) \ 157 -o $(1) \ 158 -xMMD \ 159 -xMF $(4) \ 160 $(DEFS) \ 161 $(T_CFLAGS) \ 162 $(CFLAGS) \ 163 -I$(dir $(3)) \ 164 $(INCLUDE)) 165endef 166 167 168# CxxObject class 169 170define gb_CxxObject__command 171$(call gb_Output_announce,$(2),$(true),CXX,3) 172$(call gb_Helper_abbreviate_dirs,\ 173 mkdir -p $(dir $(1)) $(dir $(4)) && \ 174 $(gb_CXX) \ 175 $(DEFS) \ 176 $(T_CXXFLAGS) \ 177 $(CXXFLAGS) \ 178 -c $(3) \ 179 -o $(1) \ 180 -xMMD \ 181 -xMF $(4) \ 182 -I$(dir $(3)) \ 183 $(INCLUDE_STL) $(INCLUDE)) 184endef 185 186 187# LinkTarget class 188 189define gb_LinkTarget__get_rpath_for_layer 190$(patsubst $(1):%,%,$(filter $(1):%,$(gb_LinkTarget__RPATHS))) 191endef 192 193gb_LinkTarget__RPATHS := \ 194 URELIB:\dORIGIN \ 195 UREBIN:\dORIGIN/../lib:\dORIGIN \ 196 OOO:\dORIGIN:\dORIGIN/../ure-link/lib \ 197 BRAND:\dORIGIN:\dORIGIN/../basis-link/program:\dORIGIN/../basis-link/ure-link/lib \ 198 SDKBIN:\dORIGIN/../../ure-link/lib \ 199 NONEBIN:\dORIGIN/../lib:\dORIGIN \ 200 201gb_LinkTarget_CFLAGS := $(gb_CFLAGS) $(gb_CFLAGS_WERROR) 202gb_LinkTarget_CXXFLAGS := $(gb_CXXFLAGS) $(gb_CXXFLAGS_WERROR) 203 204 205gb_LinkTarget_INCLUDE := $(filter-out %/stl, $(subst -I. , ,$(SOLARINC))) 206gb_LinkTarget_INCLUDE_STL := $(filter %/stl, $(subst -I. , ,$(SOLARINC))) 207 208define gb_LinkTarget__command_dynamiclink 209$(call gb_Helper_abbreviate_dirs,\ 210 mkdir -p $(dir $(1)) && \ 211 $(gb_CXX) \ 212 $(if $(filter Library,$(TARGETTYPE)),$(gb_Library_TARGETTYPEFLAGS)) \ 213 $(if $(VERSIONMAP),$(gb_Library_VERSIONMAPFLAG) $(VERSIONMAP)) \ 214 $(if $(call gb_Library_is_udk_versioned,$(1)),-Wl$(COMMA)-h$(notdir $(1)).$(gb_UDK_MAJOR)) \ 215 $(subst \d,$$,$(RPATH)) \ 216 $(T_LDFLAGS) \ 217 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 218 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 219 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 220 $(foreach lib,$(LINKED_STATIC_LIBS),$(call gb_StaticLibrary_get_target,$(lib))) \ 221 $(patsubst lib%.so,-l%,$(foreach lib,$(LINKED_LIBS),$(call gb_Library_get_filename,$(lib)))) \ 222 $(patsubst %,-l%,$(EXTERNAL_LIBS)) \ 223 $(LIBS) \ 224 -o $(if $(call gb_Library_is_udk_versioned,$(1)),$(1).$(gb_UDK_MAJOR),$(1))) 225endef 226 227define gb_LinkTarget__command_symlink_udk_versioned_library 228 $(if $(call gb_Library_is_udk_versioned,$(1)), 229 $(call gb_Helper_abbreviate_dirs,\ 230 rm -f $(1) && ln -s $(notdir $(1)).$(gb_UDK_MAJOR) $(1))) 231endef 232 233define gb_LinkTarget__command_staticlink 234$(call gb_Helper_abbreviate_dirs,\ 235 mkdir -p $(dir $(1)) && \ 236 $(gb_AR) -rsu $(1) \ 237 $(foreach object,$(COBJECTS),$(call gb_CObject_get_target,$(object))) \ 238 $(foreach object,$(CXXOBJECTS),$(call gb_CxxObject_get_target,$(object))) \ 239 $(foreach object,$(GENCXXOBJECTS),$(call gb_GenCxxObject_get_target,$(object))) \ 240 2> /dev/null) 241endef 242 243define gb_LinkTarget__command 244$(call gb_Output_announce,$(2),$(true),LNK,4) 245$(if $(filter Library GoogleTest Executable,$(TARGETTYPE)),$(call gb_LinkTarget__command_dynamiclink,$(1))) 246$(if $(filter Library,$(TARGETTYPE)),$(call gb_LinkTarget__command_symlink_udk_versioned_library,$(1))) 247$(if $(filter StaticLibrary,$(TARGETTYPE)),$(call gb_LinkTarget__command_staticlink,$(1))) 248endef 249 250# Library class 251 252gb_Library_DEFS := 253gb_Library_TARGETTYPEFLAGS := -Bdynamic -z text -G 254gb_Library_SYSPRE := lib 255gb_Library_UNOVERPRE := $(gb_Library_SYSPRE)uno_ 256gb_Library_PLAINEXT := .so 257gb_Library_RTEXT := C52$(gb_Library_PLAINEXT) 258ifeq ($(gb_PRODUCT),$(true)) 259gb_Library_STLEXT := port_sunpro$(gb_Library_PLAINEXT) 260else 261gb_Library_STLEXT := port_sunpro_debug$(gb_Library_PLAINEXT) 262endif 263gb_Library_VERSIONMAPFLAG := -M 264 265ifeq ($(CPUNAME),INTEL) 266gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 267gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 268else # ifeq ($(CPUNAME),SPARC) 269gb_Library_OOOEXT := $(gb_Library_PLAINEXT) 270gb_Library_UNOEXT := .uno$(gb_Library_PLAINEXT) 271endif 272 273gb_STDLIBS := \ 274 Crun \ 275 m \ 276 c \ 277 278gb_Library_PLAINLIBS_NONE += \ 279 $(gb_STDLIBS) \ 280 dl \ 281 freetype \ 282 nsl \ 283 pthread \ 284 socket \ 285 X11 \ 286 Xext \ 287 SM \ 288 ICE 289 290gb_Library_FILENAMES := \ 291 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_OOOEXT)) \ 292 $(foreach lib,$(gb_Library_PLAINLIBS_NONE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 293 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 294 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_PLAINEXT)) \ 295 $(foreach lib,$(gb_Library_RTLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 296 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_RTEXT)) \ 297 $(foreach lib,$(gb_Library_STLLIBS),$(lib):$(gb_Library_SYSPRE)$(lib)$(gb_Library_STLEXT)) \ 298 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 299 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):$(lib)$(gb_Library_UNOEXT)) \ 300 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):$(gb_Library_UNOVERPRE)$(lib)$(gb_Library_PLAINEXT)) \ 301 302 303gb_Library_LAYER := \ 304 $(foreach lib,$(gb_Library_OOOLIBS),$(lib):OOO) \ 305 $(foreach lib,$(gb_Library_PLAINLIBS_URE),$(lib):URELIB) \ 306 $(foreach lib,$(gb_Library_PLAINLIBS_OOO),$(lib):OOO) \ 307 $(foreach lib,$(gb_Library_RTLIBS),$(lib):OOO) \ 308 $(foreach lib,$(gb_Library_RTVERLIBS),$(lib):URELIB) \ 309 $(foreach lib,$(gb_Library_STLLIBS),$(lib):URELIB) \ 310 $(foreach lib,$(gb_Library_UNOLIBS_URE),$(lib):URELIB) \ 311 $(foreach lib,$(gb_Library_UNOLIBS_OOO),$(lib):OOO) \ 312 $(foreach lib,$(gb_Library_UNOVERLIBS),$(lib):URELIB) \ 313 314define gb_Library_get_rpath 315'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Library_get_layer,$(1)))' 316endef 317 318define gb_Library_Library_platform 319$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Library_get_rpath,$(1)) 320 321ifneq (,$(call gb_Library_is_udk_versioned,$(call gb_Library_get_target,$(1)))) 322$(call gb_Library_get_target,$(1)) \ 323$(call gb_Library_get_clean_target,$(1)) : AUXTARGETS += \ 324 $(call gb_Library_get_target,$(1)).$(gb_UDK_MAJOR) 325endif 326endef 327 328 329# StaticLibrary class 330 331gb_StaticLibrary_DEFS := 332gb_StaticLibrary_SYSPRE := lib 333gb_StaticLibrary_PLAINEXT := .a 334gb_StaticLibrary_JPEGEXT := lib$(gb_StaticLibrary_PLAINEXT) 335 336gb_StaticLibrary_FILENAMES := \ 337 $(foreach lib,$(gb_StaticLibrary_JPEGLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_JPEGEXT)) \ 338 $(foreach lib,$(gb_StaticLibrary_PLAINLIBS),$(lib):$(gb_StaticLibrary_SYSPRE)$(lib)$(gb_StaticLibrary_PLAINEXT)) \ 339 340gb_StaticLibrary_StaticLibrary_platform = 341 342 343# Executable class 344 345gb_Executable_EXT := 346 347gb_Executable_LAYER := \ 348 $(foreach exe,$(gb_Executable_UREBIN),$(exe):UREBIN) \ 349 $(foreach exe,$(gb_Executable_SDK),$(exe):SDKBIN) \ 350 $(foreach exe,$(gb_Executable_OOO),$(exe):OOO) \ 351 $(foreach exe,$(gb_Executable_BRAND),$(exe):BRAND) \ 352 $(foreach exe,$(gb_Executable_NONE),$(exe):NONEBIN) \ 353 354 355define gb_Executable_get_rpath 356'-R$(call gb_LinkTarget__get_rpath_for_layer,$(call gb_Executable_get_layer,$(1)))' 357endef 358 359define gb_Executable_Executable_platform 360$(call gb_LinkTarget_get_target,$(2)) : RPATH := $(call gb_Executable_get_rpath,$(1)) 361 362endef 363 364 365# GoogleTest class 366 367gb_GoogleTest_GTESTPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 368gb_GoogleTest_get_filename = $(1)$(gb_Executable_EXT) 369 370define gb_GoogleTest_GoogleTest_platform 371$(call gb_LinkTarget_get_target,$(2)) : RPATH := 372endef 373 374# JunitTest class 375 376define gb_JunitTest_JunitTest_platform 377$(call gb_JunitTest_get_target,$(1)) : DEFS := \ 378 -Dorg.openoffice.test.arg.soffice="$$$${OOO_TEST_SOFFICE:-path:$(SRCDIR)/instsetoo_native/$(INPATH)/Apache_OpenOffice/installed/install/en-US/openoffice4/program/soffice}" \ 379 -Dorg.openoffice.test.arg.env=LD_LIBRARY_PATH \ 380 -Dorg.openoffice.test.arg.user=file://$(call gb_JunitTest_get_userdir,$(1)) \ 381 382endef 383 384# SdiTarget class 385 386gb_SdiTarget_SVIDLPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 387 388# SrsPartMergeTarget 389 390gb_SrsPartMergeTarget_TRANSEXPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 391 392# SrsPartTarget class 393 394gb_SrsPartTarget_RSCTARGET := $(OUTDIR)/bin/rsc 395gb_SrsPartTarget_RSCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_SrsPartTarget_RSCTARGET) 396 397# Sun cc/CC support -xM1/-xMF flags, but unfortunately refuse input files that 398# do not have the right suffix, so use makedepend here... 399define gb_SrsPartTarget__command_dep 400$(call gb_Helper_abbreviate_dirs_native,\ 401 $(OUTDIR)/bin/makedepend$(gb_Executable_EXT) \ 402 $(INCLUDE) \ 403 $(DEFS) \ 404 $(2) \ 405 -f - \ 406 | $(gb_AWK) -f $(GBUILDDIR)/processdeps.awk \ 407 -v OBJECTFILE=$(call gb_SrsPartTarget_get_target,$(1)) \ 408 -v OUTDIR=$(OUTDIR)/ \ 409 -v WORKDIR=$(WORKDIR)/ \ 410 -v SRCDIR=$(SRCDIR)/ \ 411 -v REPODIR=$(REPODIR)/ \ 412 > $(call gb_SrsPartTarget_get_dep_target,$(1))) 413endef 414 415 416# ComponentTarget 417 418gb_XSLTPROCPRECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib 419gb_Library_COMPONENTPREFIXES := \ 420 OOO:vnd.sun.star.expand:\dOOO_BASE_DIR/program/ \ 421 URELIB:vnd.sun.star.expand:\dURE_INTERNAL_LIB_DIR/ \ 422 NONE:vnd.sun.star.expand:\dOOO_INBUILD_SHAREDLIB_DIR/ \ 423 424# UnoApiTarget 425 426gb_UnoApiTarget_IDLCTARGET := $(OUTDIR)/bin/idlc 427gb_UnoApiTarget_IDLCCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_IDLCTARGET) 428gb_UnoApiTarget_REGMERGETARGET := $(OUTDIR)/bin/regmerge 429gb_UnoApiTarget_REGMERGECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGMERGETARGET) 430gb_UnoApiTarget_REGCOMPARETARGET := $(OUTDIR)/bin/regcompare 431gb_UnoApiTarget_REGCOMPARECOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGCOMPARETARGET) 432gb_UnoApiTarget_CPPUMAKERTARGET := $(OUTDIR)/bin/cppumaker 433gb_UnoApiTarget_CPPUMAKERCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_CPPUMAKERTARGET) 434gb_UnoApiTarget_REGVIEWTARGET := $(OUTDIR)/bin/regview 435gb_UnoApiTarget_REGVIEWCOMMAND := LD_LIBRARY_PATH=$(OUTDIR)/lib SOLARBINDIR=$(OUTDIR)/bin $(gb_UnoApiTarget_REGVIEWTARGET) 436 437# vim: set noet sw=4 ts=4: 438