1# -*- Makefile -*- Time-stamp: <08/06/12 16:03:31 ptr> 2# 3# Copyright (c) 1997-1999, 2002, 2003, 2005-2007 4# Petr Ovtchenkov 5# 6# Portion Copyright (c) 1999-2001 7# Parallel Graphics Ltd. 8# 9# Licensed under the Academic Free License version 3.0 10# 11 12ifndef NOT_USE_NOSTDLIB 13 14ifeq ($(CXX_VERSION_MAJOR),2) 15# i.e. gcc before 3.x.x: 2.95, etc. 16# gcc before 3.x don't had libsupc++.a and libgcc_s.so 17# exceptions and operators new are in libgcc.a 18# Unfortunatly gcc before 3.x has a buggy C++ language support outside stdc++, so definition of STDLIB below is commented 19NOT_USE_NOSTDLIB := 1 20#STDLIBS := $(shell ${CXX} -print-file-name=libgcc.a) -lpthread -lc -lm 21endif 22 23ifeq ($(CXX_VERSION_MAJOR),3) 24# gcc before 3.3 (i.e. 3.0.x, 3.1.x, 3.2.x) has buggy libsupc++, so we should link with libstdc++ to avoid one 25ifeq ($(CXX_VERSION_MINOR),0) 26NOT_USE_NOSTDLIB := 1 27endif 28ifeq ($(CXX_VERSION_MINOR),1) 29NOT_USE_NOSTDLIB := 1 30endif 31ifeq ($(CXX_VERSION_MINOR),2) 32NOT_USE_NOSTDLIB := 1 33endif 34endif 35 36endif 37 38ifndef NOT_USE_NOSTDLIB 39ifeq ($(OSNAME),linux) 40_USE_NOSTDLIB := 1 41endif 42 43ifeq ($(OSNAME),openbsd) 44_USE_NOSTDLIB := 1 45endif 46 47ifeq ($(OSNAME),freebsd) 48_USE_NOSTDLIB := 1 49endif 50 51ifeq ($(OSNAME),netbsd) 52_USE_NOSTDLIB := 1 53endif 54 55ifeq ($(OSNAME),sunos) 56_USE_NOSTDLIB := 1 57endif 58 59ifeq ($(OSNAME),darwin) 60_USE_NOSTDLIB := 1 61endif 62 63ifeq ($(OSNAME),cygming) 64_USE_NOSTDLIB := 1 65endif 66endif 67 68ifndef WITHOUT_STLPORT 69ifeq (${STLPORT_LIB_DIR},) 70ifneq ($(OSNAME),cygming) 71release-shared: STLPORT_LIB = -lstlport 72release-static: STLPORT_LIB = -Wl,-Bstatic -lstlport -Wl,-Bdynamic 73dbg-shared: STLPORT_LIB = -lstlportg 74dbg-static: STLPORT_LIB = -Wl,-Bstatic -lstlportg -Wl,-Bdynamic 75stldbg-shared: STLPORT_LIB = -lstlportstlg 76stldbg-static: STLPORT_LIB = -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic 77else 78LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} 79release-shared : STLPORT_LIB = -lstlport.${LIB_VERSION} 80dbg-shared : STLPORT_LIB = -lstlportg.${LIB_VERSION} 81stldbg-shared : STLPORT_LIB = -lstlportstlg.${LIB_VERSION} 82endif 83else 84# STLPORT_LIB_DIR not empty 85ifneq ($(OSNAME),cygming) 86release-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport 87release-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlport -Wl,-Bdynamic 88dbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg 89dbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportg -Wl,-Bdynamic 90stldbg-shared: STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg 91stldbg-static: STLPORT_LIB = -L${STLPORT_LIB_DIR} -Wl,-Bstatic -lstlportstlg -Wl,-Bdynamic 92else 93LIB_VERSION = ${LIBMAJOR}.${LIBMINOR} 94release-shared : STLPORT_LIB = -L${BASE_INSTALL_DIR}/lib -lstlport.${LIB_VERSION} 95dbg-shared : STLPORT_LIB = -L${BASE_INSTALL_DIR}/lib -lstlportg.${LIB_VERSION} 96stldbg-shared : STLPORT_LIB = -L${BASE_INSTALL_DIR}/lib -lstlportstlg.${LIB_VERSION} 97endif 98endif 99 100endif 101 102ifdef _USE_NOSTDLIB 103 104# Check whether gcc builded with --disable-shared 105ifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_eh.a),libgcc_eh.a) 106# gcc builded with --disable-shared, (no library libgcc_eh.a); all exception support in libgcc.a 107_LGCC_EH := 108_LGCC_S := -lgcc 109else 110# gcc builded with --enable-shared (default) 111ifdef USE_STATIC_LIBGCC 112# if force usage of static libgcc, then exceptions support should be taken from libgcc_eh 113_LGCC_EH := -lgcc_eh 114_LGCC_S := -lgcc 115else 116# otherwise, exceptions support is in libgcc_s.so 117_LGCC_EH := 118ifneq ($(OSNAME),darwin) 119_LGCC_S := -lgcc_s 120else 121ifdef GCC_APPLE_CC 122ifeq ($(MACOSX_TEN_FIVE),true) 123_LGCC_S := -lgcc_s.10.5 124else 125_LGCC_S := -lgcc_s.10.4 126endif 127else 128_LGCC_S := -lgcc_s 129# end of GCC_APPLE_CC 130endif 131# end of Darwin 132endif 133# end of !USE_STATIC_LIBGCC 134endif 135# end of present libgcc_eh.a 136endif 137 138# ifeq ($(CXX_VERSION_MAJOR),3) 139ifeq ($(OSNAME),linux) 140START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 141END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 142STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm 143endif 144 145ifeq ($(OSNAME),openbsd) 146START_OBJ := $(shell for o in crt0.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 147END_OBJ := $(shell for o in crtend.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 148STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm 149endif 150 151ifeq ($(OSNAME),freebsd) 152# FreeBSD < 5.3 should use -lc_r, while FreeBSD >= 5.3 use -lpthread 153PTHR := $(shell if [ ${OSREL_MAJOR} -gt 5 ] ; then echo "pthread" ; else if [ ${OSREL_MAJOR} -lt 5 ] ; then echo "c_r" ; else if [ ${OSREL_MINOR} -lt 3 ] ; then echo "c_r" ; else echo "pthread"; fi ; fi ; fi) 154START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 155END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 156STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -l${PTHR} -lc -lm 157endif 158 159ifeq ($(OSNAME),netbsd) 160START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 161END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 162STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm 163endif 164 165ifeq ($(OSNAME),sunos) 166START_OBJ := $(shell for o in crt1.o crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 167END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 168STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm 169endif 170 171ifeq ($(OSNAME),darwin) 172# sometimes crt3.o will required: it has __cxa_at_exit, but the same defined in libc.dyn 173# at least in Mac OS X 10.4.10 (8R2218) 174ifeq ($(CXX_VERSION_MAJOR),3) 175# i.e. gcc 3.3 176START_OBJ := $(shell for o in crt1.o crt2.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done) 177else 178START_OBJ := -lcrt1.o 179endif 180END_OBJ := 181STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lpthread -lc -lm -lsupc++ ${_LGCC_EH} 182#LDFLAGS += -dynamic 183endif 184 185ifeq ($(OSNAME),cygming) 186LDFLAGS += -nodefaultlibs 187ifndef USE_STATIC_LIBGCC 188ifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_s.a),libgcc_s.a) 189_LGCC_S := -lgcc 190else 191_LGCC_S := -lgcc_s 192endif 193else 194_LGCC_S := -lgcc 195endif 196ifeq ($(OSREALNAME),mingw) 197STDLIBS = ${STLPORT_LIB} -lsupc++ ${_LGCC_S} -lmingw32 -lmingwex -lmsvcrt -lm -lmoldname -lcoldname -lkernel32 198else 199LDFLAGS += -Wl,-enable-auto-import 200ifneq (,$(findstring no-cygwin,$(EXTRA_CXXFLAGS))) 201STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lmingw32 -lmingwex -lmsvcrt -lm -lmoldname -lcoldname -lkernel32 202else 203STDLIBS = ${STLPORT_LIB} ${_LGCC_S} -lm -lc -lpthread -lkernel32 204endif 205endif 206else 207LDFLAGS += -nostdlib 208endif 209 210# endif 211# _USE_NOSTDLIB 212else 213ifndef USE_STATIC_LIBGCC 214release-shared : LDFLAGS += -shared-libgcc 215dbg-shared : LDFLAGS += -shared-libgcc 216stldbg-shared : LDFLAGS += -shared-libgcc 217endif 218ifndef WITHOUT_STLPORT 219STDLIBS = ${STLPORT_LIB} 220else 221STDLIBS = 222endif 223endif 224 225# workaround for gcc 2.95.x bug: 226ifeq ($(CXX_VERSION_MAJOR),2) 227ifneq ($(OSNAME),cygming) 228OPT += -fPIC 229endif 230endif 231