# -*- Makefile -*- # # $Id$ # # configuration file for IBM VisualAge and XLC++ # ############################################################################## # # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed # with this work for additional information regarding copyright # ownership. The ASF licenses this file to you under the Apache # License, Version 2.0 (the "License"); you may not use this file # except in compliance with the License. You may obtain a copy of # the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # implied. See the License for the specific language governing # permissions and limitations under the License. # # Copyright 1999-2007 Rogue Wave Software, Inc. # ############################################################################## # see if the xlCcore command exists and use it in preference to xlC # xlCcore, available in VAC++ 6.0 patches released since 4/2004, and # later, avoids linking with the native C++ Standard Library ifneq ($(shell xlCcore /dev/null >/dev/null 2>&1; echo $$?),127) CXX := xlCcore # enable Run-Time Linking for true shared libraries # (i.e., .so's but not AIX shared archives) ifneq (,$(findstring shared,$(BUILDMODE))) ifeq (,$(findstring archive,$(BUILDMODE))) rtl_enabled = 1 endif endif else ifeq ($(OSNAME),AIX) CXX := xlC # Run-Time Linking not enabled as its known to cause conflicts # with the native VAC++ C++ Standard Library on AIX, libC.a else # assume Linux # use xlc on Linux to prevent linking in the native # C++ Standard Library (gcc's libstdc++) CXX := xlc endif endif # _r suffix links with reentrant versions of system libraries ifeq ($(findstring pthread,$(BUILDMODE)),pthread) CXX := $(CXX)_r endif # invoke a script to determine the exact version CCVER := $(shell etc/config/xlC_version.sh) # determine the major and minor version of the compiler CXX_MAJOR := $(shell echo "$(CCVER)" | sed "s/^\([1-9][0-9]*\).*/\1/") CXX_MINOR := $(shell echo "$(CCVER)" | sed "s/[1-9]*\.\([0-9]*\).*/\1/") # determine the major and minor version of the OS on AIX ifeq ($(OSNAME),AIX) OS_MAJOR := $(shell uname -v) OS_MINOR := $(shell uname -r) endif # suppress bogus warnings: # 1540-0152: A template dependent name that is a type must be qualified # with "typename". # 1540-0183: The explicit instantiation should either be explictly # qualified or be declared in the namespace containing # the template. (See VAC++ 7.0 bug #449.) ifeq ($(shell expr $(CXX_MAJOR) \< 6),1) WARNFLAGS = -qsuppress=1540-0152 endif # version < 6.0 ifeq ($(CCVER),7.0) WARNFLAGS += -qsuppress=1540-0183 endif # version == 7.0 DEPENDFLAGS = -MP CXXFLAGS = # enable C++ C library headers (the kind) CPPFLAGS = -I$(TOPDIR)/include/ansi # use -qmkshrobj with VAC++ 6.0 and prior or when building # a shared library (either a shared archive or a .so) ifneq (,$(findstring shared,$(BUILDMODE))) shared = 1 else ifneq (,$(findstring |$(BUILDTYPE)|,|8d|8D|11d|11D|12d|12D|15d|15D|)) shared = 1 endif endif ifneq ($(shared),) PRELINKFLAGS = -qmkshrobj else ifeq ($(shell expr $(CXX_MAJOR) \< 7),1) PRELINKFLAGS = -qmkshrobj endif endif LDFLAGS = $(CPPFLAGS) ifeq ($(OSNAME),AIX) # link with libiconv only on AIX (and not on Linux) LDFLAGS += -liconv ifneq ($(rtl_enabled),1) # bump up the maximum AIX binder error level from the default of 4 # to silence ld warning 0711-224 (Duplicate symbol) when the tempinc # template instantiation model is active (-qtempinc) ifneq ($(PRELINKFLAGS),) # append to PRELINKFLAGS only if the variable is not empty # to avoid trying to prelink with the wrong options (i.e., # without -qmkshrobj) PRELINKFLAGS += -Wl,-bh:5 endif LDFLAGS += -Wl,-bh:5 else ifeq ($(CXX_MAJOR),6) # also silence ld warning 0711-224 (Duplicate symbol) for shared # library linking with VisualAge C++ 6.0 (see STDCXX-439) LDFLAGS += -Wl,-bh:5 endif endif # disable assembly files on AIX but leave them enabled (at the default # setting) elsewhere (e.g., Linux) AS_EXT = . else # not AIX (assume Linux) # position-dependent code necessary on Linux only PICFLAGS = -qpic # set the assembler file suffix to .s AS_EXT = .s ifeq ($(findstring xlCcore,$(CXX)),) LDLIBS = -lxlopt -lxl -libmc++ -lsupc++ -lgcc -lgcc_eh -lc endif endif # when Run-Time Linking is enabled create a dynamically loadable # library and use run-time linking, otherwise make a shared archive ifeq ($(rtl_enabled),1) LDFLAGS += -brtl LDSOFLAGS = -G endif # The flag(s) to use to embed a library search path into generated executables. ifeq ($(OSNAME),AIX) ifeq ($(shell [ $(OS_MAJOR) -gt 5 -o $(OS_MAJOR) -eq 5 -a $(OS_MINOR) -ge 3 \ ] && echo 1), 1) # -bsrv4, -R only available on AIX 5.3 and newer RPATH = -Wl,-bsvr4,-R endif else # assume Linux RPATH = -Wl,-R endif # math library to link with LIBM = -lm # debug/optimization options DEBUG_CXXFLAGS = -g DEBUG_CPPFLAGS = # -O enables inlining of all functions declared inline OPTMZ_CXXFLAGS = -O OPTMZ_CPPFLAGS = # shared/archive library options SHARED_CXXFLAGS = SHARED_CPPFLAGS = SHARED_LDFLAGS = ifeq ($(rtl_enabled),1) # Run-Time Loadable shared library SHARED_SUFFIX = .so else # archive or shared archive SHARED_SUFFIX = .a endif STATIC_CXXFLAGS = STATIC_CPPFLAGS = STATIC_LDFLAGS = STATIC_SUFFIX = .a # multi/single thread options; xlC_r driver defines -qthreaded # and _THREAD_SAFE and __VACPP_MULTI__ macros MULTI_CPPFLAGS_POSIX = MULTI_CPPFLAGS_DCE = # no need to explicitly list libpthread since the xlCxxx_r driver # implicitly passes -lpthread to the linker MULTI_LDFLAGS_POSIX = MULTI_LDFLAGS_DCE = # POSIX threads MULTI_CPPFLAGS = $(MULTI_CPPFLAGS_POSIX) MULTI_LDFLAGS = $(MULTI_LDFLAGS_POSIX) SINGL_CPPFLAGS = SINGL_LDFLAGS = # wide (64-bit) flags -- must be set explicitly CXXFLAGS.wide = -q64 # do not use the overly chatty -qwarn64 LDFLAGS.wide = -q64 LDSOFLAGS.wide = -q64 ifeq ($(OSNAME),AIX) ARFLAGS.wide = -X64 endif # narrow (32-bit) flags -- implicit in the default invocation # CXXFLAGS.narrow = -q32 # LDFLAGS.narrow = -q32 # LDSOFLAGS.narrow = -q32 # ARFLAGS.narrow = # override default (rv, no leading dash) to make ar -rv -X64 well-formed ARFLAGS = -rv ifeq ($(OSNAME),AIX) # default shared object on AIX (not on Linux) ifneq ($(shared),) DEFAULT_SHROBJ = shr.o endif endif # check if the -qtemplateregistry option is recognized use_tempinc=$(shell cd $${TMPDIR:=/tmp} \ && echo "int i;" >foo.$$$$.c \ && $(CXX) -c -qmaxerr=1:w -qtemplateregistry \ foo.$$$$.c >/dev/null 2>&1; \ echo $$?; rm -f foo.$$$$.c foo.$$$$.o) # template repository/registry name override ifneq ($(use_tempinc),0) CXX_REPOSITORY = -qtempinc= else CXX_REPOSITORY = -qtemplateregistry= endif