gcc.mak

来自「stl的源码」· MAK 代码 · 共 312 行

MAK
312
字号
# -*- makefile -*- Time-stamp: <08/06/12 15:48:58 ptr>## Copyright (c) 1997-1999, 2002, 2003, 2005-2008# Petr Ovtchenkov## Portion Copyright (c) 1999-2001# Parallel Graphics Ltd.## Licensed under the Academic Free License version 3.0## Oh, the commented below work for gmake 3.78.1 and above,# but phrase without tag not work for it. Since gmake 3.79 # tag with assignment fail, but work assignment for all tags# (really that more correct).ifneq ($(OSNAME), cygming)OPT += -fPICendififndef NOT_USE_NOSTDLIBifeq ($(CXX_VERSION_MAJOR),2)# i.e. gcc before 3.x.x: 2.95, etc.# gcc before 3.x don't had libsupc++.a and libgcc_s.so# exceptions and operators new are in libgcc.a#  Unfortunatly gcc before 3.x has a buggy C++ language support outside stdc++, so definition of STDLIBS below is commentedNOT_USE_NOSTDLIB := 1#STDLIBS := $(shell ${CXX} -print-file-name=libgcc.a) -lpthread -lc -lmendififeq ($(CXX_VERSION_MAJOR),3)# 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 oneifeq ($(CXX_VERSION_MINOR),0)NOT_USE_NOSTDLIB := 1endififeq ($(CXX_VERSION_MINOR),1)NOT_USE_NOSTDLIB := 1endififeq ($(CXX_VERSION_MINOR),2)NOT_USE_NOSTDLIB := 1endifendifendififndef NOT_USE_NOSTDLIBifeq ($(OSNAME),linux)_USE_NOSTDLIB := 1endififeq ($(OSNAME),openbsd)_USE_NOSTDLIB := 1endififeq ($(OSNAME),freebsd)_USE_NOSTDLIB := 1endififeq ($(OSNAME),netbsd)_USE_NOSTDLIB := 1endififeq ($(OSNAME),sunos)_USE_NOSTDLIB := 1endififeq ($(OSNAME),darwin)_USE_NOSTDLIB := 1endififeq ($(OSNAME),cygming)_USE_NOSTDLIB := 1endifendififndef WITHOUT_STLPORTifeq (${STLPORT_LIB_DIR},)ifneq ($(OSNAME),cygming)release-shared:	STLPORT_LIB = -lstlportdbg-shared:	STLPORT_LIB = -lstlportgstldbg-shared:	STLPORT_LIB = -lstlportstlgelseLIB_VERSION = ${LIBMAJOR}.${LIBMINOR}release-shared:	STLPORT_LIB = -lstlport.${LIB_VERSION}dbg-shared:	STLPORT_LIB = -lstlportg.${LIB_VERSION}stldbg-shared:	STLPORT_LIB = -lstlportstlg.${LIB_VERSION}endifelse# STLPORT_LIB_DIR not emptyifneq ($(OSNAME),cygming)release-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportdbg-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportgstldbg-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlgelseLIB_VERSION = ${LIBMAJOR}.${LIBMINOR}release-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlport.${LIB_VERSION}dbg-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportg.${LIB_VERSION}stldbg-shared:	STLPORT_LIB = -L${STLPORT_LIB_DIR} -lstlportstlg.${LIB_VERSION}endifendifendififdef _USE_NOSTDLIBNOSTDLIB :=# Check whether gcc builded with --disable-sharedifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_eh.a),libgcc_eh.a)# gcc builded with --disable-shared, (no library libgcc_eh.a); all exception support in libgcc.a_LGCC_EH :=_LGCC_S := -lgccelse# gcc builded with --enable-shared (default)ifdef USE_STATIC_LIBGCC# if force usage of static libgcc, then exceptions support should be taken from libgcc_eh_LGCC_EH := -lgcc_eh_LGCC_S := -lgccelse#ifneq ($(OSNAME),darwin)# otherwise, exceptions support is in libgcc_s.so_LGCC_EH :=ifneq ($(OSNAME),darwin)_LGCC_S := -lgcc_selseifeq ($(MACOSX_TEN_FIVE),true)_LGCC_S := -lgcc_s.10.5else_LGCC_S := -lgcc_s.10.4endif# end of Darwinendif# end of !USE_STATIC_LIBGCCendif# end of present libgcc_eh.aendif_LSUPCPP := $(shell ${CXX} ${CXXFLAGS} -print-file-name=libsupc++.a)ifeq (${OSNAME},darwin)ifdef GCC_APPLE_CC_LSUPCPP := $(shell mkdir -p $(PRE_OUTPUT_DIR) && lipo ${_LSUPCPP} -thin ${M_ARCH} -output $(PRE_OUTPUT_DIR)/libsupc++.a && echo $(PRE_OUTPUT_DIR)/libsupc++.a)endifendififneq (${_LSUPCPP},libsupc++.a)_LSUPCPP_OBJ     := $(shell $(AR) t ${_LSUPCPP})_LSUPCPP_AUX_OBJ := $(addprefix $(AUX_DIR)/,${_LSUPCPP_OBJ})_LSUPCPP_TSMP    := .supc++_LSUPCPP_AUX_TSMP:= $(AUX_DIR)/$(_LSUPCPP_TSMP)endif# ifeq ($(CXX_VERSION_MAJOR),3)# Include whole language support archive (libsupc++.a) into libstlport:# all C++ issues are in libstlport now.ifeq ($(OSNAME),linux)START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)#START_A_OBJ := $(shell for o in crti.o crtbeginT.o; do ${CXX} -print-file-name=$$o; done)END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)STDLIBS = -Wl,--whole-archive -lsupc++ ${_LGCC_EH} -Wl,--no-whole-archive ${_LGCC_S} -lpthread -lc -lmendififeq ($(OSNAME),openbsd)START_OBJ := $(shell for o in crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)END_OBJ := $(shell for o in crtendS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)STDLIBS = -Wl,--whole-archive -lsupc++ ${_LGCC_EH} -Wl,--no-whole-archive ${_LGCC_S} -lpthread -lc -lmendififeq ($(OSNAME),freebsd)# FreeBSD < 5.3 should use -lc_r, while FreeBSD >= 5.3 use -lpthreadPTHR := $(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)START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)STDLIBS := -Wl,--whole-archive -lsupc++ ${_LGCC_EH} -Wl,--no-whole-archive ${_LGCC_S} -l${PTHR} -lc -lmendififeq ($(OSNAME),netbsd)START_OBJ := $(shell for o in crti.o crtbeginS.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)END_OBJ := $(shell for o in crtendS.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)STDLIBS = -Wl,--whole-archive -lsupc++ ${_LGCC_EH} -Wl,--no-whole-archive ${_LGCC_S} -lpthread -lc -lmendififeq ($(OSNAME),sunos)START_OBJ := $(shell for o in crti.o crtbegin.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)END_OBJ := $(shell for o in crtend.o crtn.o; do ${CXX} ${CXXFLAGS} -print-file-name=$$o; done)STDLIBS := -Wl,-zallextract -lsupc++ ${_LGCC_EH} -Wl,-zdefaultextract ${_LGCC_S} -lpthread -lc -lmendififeq ($(OSNAME),darwin)ifndef USE_STATIC_LIBGCC# MacOS X, shared-libgccifeq ($(MACOSX_TEN_FIVE),true)# MacOS X >= 10.5START_OBJ :=else# MacOS X < 10.5START_OBJ :=endifelse# MacOS X, not shared-libgccSTART_OBJ := endifEND_OBJ :=# -all_load don't demonstrate any visible effect, looks like# this is dummy option; but nevertheless, with _LSUPCPP_AUX_OBJ# trick (as in static library) we can resolve problem, in potentialifdef GCC_APPLE_CCSTDLIBS := ${_LGCC_S} -lc -lm -all_load ${_LSUPCPP} ${_LGCC_EH}elseLDFLAGS += -single_moduleSTDLIBS := ${_LGCC_S} -lc -lm -all_load -lsupc++ ${_LGCC_EH}endifendif#END_A_OBJ := $(shell for o in crtn.o; do ${CXX} -print-file-name=$$o; done)# endififneq ($(OSNAME),cygming)NOSTDLIB := -nostdlibelseNOSTDLIB := -nodefaultlibsifndef USE_STATIC_LIBGCCifeq ($(shell ${CXX} ${CXXFLAGS} -print-file-name=libgcc_s.a),libgcc_s.a)_LGCC_S := -lgccelse_LGCC_S := -lgcc_sendifelse_LGCC_S := -lgccendififeq ($(OSREALNAME),mingw)STDLIBS = -lsupc++ ${_LGCC_S} -lm -lmoldname -lmingw32 -lmingwex -lmsvcrt -lkernel32elseLIBSUPC++ := $(shell ${CXX} ${CXXFLAGS} -print-file-name=libsupc++.a)LSUPC++DEF := $(PRE_OUTPUT_DIR)/libsupc++.def$(LSUPC++DEF) : $(LIBSUPC++)	dlltool --export-all-symbols --output-def=$(LSUPC++DEF) $(LIBSUPC++)ifneq (,$(findstring no-cygwin,$(EXTRA_CXXFLAGS)))STDLIBS = -Wl,-whole-archive -lsupc++ -Wl,-no-whole-archive ${_LGCC_S} -lm -lmoldname -lmingw32 -lmingwex -lmsvcrt -lkernel32elseSTDLIBS = -Wl,-whole-archive -lsupc++ -Wl,--no-whole-archive ${_LGCC_S} -lpthread -lm -lc -lkernel32endifendifendifelseifndef WITHOUT_STLPORTifndef STLP_BUILDSTDLIBS = ${STLPORT_LIB}elseSTDLIBS =endifelseSTDLIBS = endifendififneq ($(OSNAME),darwin)dbg-shared:	LDFLAGS += -sharedstldbg-shared:	LDFLAGS += -sharedrelease-shared:	LDFLAGS += -sharedendififeq ($(OSNAME),hp-ux)dbg-shared:	LDFLAGS += -Wl,-dynamic -Wl,+h$(SO_NAME_DBGxx)stldbg-shared:	LDFLAGS += -Wl,-dynamic -Wl,+h$(SO_NAME_STLDBGxx)release-shared:	LDFLAGS += -Wl,-dynamic -Wl,+h$(SO_NAMExx)endififeq ($(OSNAME),sunos)dbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB}stldbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB}release-shared:	LDFLAGS += -Wl,-h$(SO_NAMExx) ${NOSTDLIB}endififeq ($(OSNAME),linux)dbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB}stldbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB}release-shared:	LDFLAGS += -Wl,-h$(SO_NAMExx) ${NOSTDLIB}endififeq ($(OSNAME),cygming)ifndef USE_STATIC_LIBGCCdbg-shared:	LDFLAGS += -shared-libgccstldbg-shared:	LDFLAGS += -shared-libgccrelease-shared:	LDFLAGS += -shared-libgccendifdbg-shared:	LDFLAGS += -Wl,--out-implib=${LIB_NAME_OUT_DBG},--enable-auto-image-base ${NOSTDLIB}stldbg-shared:	LDFLAGS += -Wl,--out-implib=${LIB_NAME_OUT_STLDBG},--enable-auto-image-base ${NOSTDLIB}release-shared:	LDFLAGS += -Wl,--out-implib=${LIB_NAME_OUT},--enable-auto-image-base ${NOSTDLIB}dbg-static:	LDFLAGS += -staticstldbg-static:	LDFLAGS += -staticrelease-static:	LDFLAGS += -staticendififeq ($(OSNAME),freebsd)dbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_DBGxx) ${NOSTDLIB}stldbg-shared:	LDFLAGS += -Wl,-h$(SO_NAME_STLDBGxx) ${NOSTDLIB}release-shared:	LDFLAGS += -Wl,-h$(SO_NAMExx) ${NOSTDLIB}endififeq ($(OSNAME),darwin)CURRENT_VERSION := ${MAJOR}.${MINOR}.${PATCH}COMPATIBILITY_VERSION := $(CURRENT_VERSION)dbg-shared:	LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_DBGxx) ${NOSTDLIB}stldbg-shared:	LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAME_STLDBGxx) ${NOSTDLIB}release-shared:	LDFLAGS += -dynamic -dynamiclib -compatibility_version $(COMPATIBILITY_VERSION) -current_version $(CURRENT_VERSION) -install_name $(SO_NAMExx) ${NOSTDLIB}dbg-static:	LDFLAGS += -staticlibstldbg-static:	LDFLAGS += -staticlibrelease-static:	LDFLAGS += -staticlibendififeq ($(OSNAME),openbsd)dbg-shared:	LDFLAGS += -Wl,-soname -Wl,$(SO_NAME_DBGxx) ${NOSTDLIB}stldbg-shared:	LDFLAGS += -Wl,-soname -Wl,$(SO_NAME_STLDBGxx) ${NOSTDLIB}release-shared:	LDFLAGS += -Wl,-soname -Wl,$(SO_NAMExx) ${NOSTDLIB}endif

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?