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