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