ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/gcc-toolfile.spec
Revision: 1.56
Committed: Sat Jan 22 14:19:14 2011 UTC (14 years, 3 months ago) by fwyzard
Branch: MAIN
CVS Tags: CMSSW_3_11_3, CMSSW_3_11_2, CMSSW_3_11_1_hclpatch1, sjgFor3111hclp1, sjgFor3111hcalp1, pe20110225a-for311X, CMSSW_3_11_1_hltpatch1, CMSSW_3_11_1_patch3, CMSSW_3_11_1_onlpatch1_ONLINE, fwFor3111op1-online, CMSSW_3_11_1_patch2, CMSSW_3_11_1_patch1, sjgFor3111p1b, sjgFor3111p1, DQMGUI_5_3_2b, DQMGUI_5_3_2a, CMSSW_3_11_1_ONLINE, CMSSW_3_11_1, fwFor3111, pe20110207a-for4XY, CMSSW_4_2_0_pre2-ports, CMSSW_4_2_0_pre2, azFor420pre2gcc434c, azFor420pre2gcc434b, azFor420pre2gcc451, CMSSW_4_1_0_pre1, azFor420pre2gcc434, pe20110205-for410p1, pe20110203a-for4XY-ports, pe20110203a-for4XY, pe20110203-for410p1, pe20110202a-for311X, pe20110202a-for4XY-ports, pe20110202a-for4XY, fw20110201-41X-online, pe20110131b-for4XY-ports, pe20110131b-for4XY, pe20110131a-for4XY-ports, pe20110131a-for4XY, fw20110131-311x-online, CMSSW_3_11_0_ONLINE, fw20110128-311X-online, CMSSW_4_2_0_pre1-ports, CMSSW_4_2_0_pre1, CMSSW_3_11_0, azFor420pre1gcc451, azFor420pre1g451n, azFor420pre1g434, pe20110127a-for311X-ports, pe20110127a-for311X, azFor420pre1g451, azFor420pre1, fw20110127a-311X, fw20110127-311X, fwFor3110, pe20110126b-for311X-ports, pe20110126b-for311X, fw20110126a-311X-online, fw20110126a-311X-ports, pe20110126a-for311X-ports, pe20110126a-for311X, sm110126a, sm110126, fw20110126-311X-online, sm110125, pe20110124b-311X-ports, pe20110124b-311X, pe20110124a-311X, fw20110122-311X-ports, fw20110122-311X-online, pe20110122b-311X-ports, pe20110122a-311X-ports, pe20110122a-311X
Changes since 1.55: +5 -4 lines
Log Message:
rework Mac OS X override logic to use shell commands instead of rpmbuild macros

File Contents

# User Rev Content
1 elmer 1.51 ### RPM cms gcc-toolfile 11.0
2 eulisse 1.1
3     # gcc has a separate spec file for the generating a
4     # toolfile because gcc.spec could be not build because of the
5     # "--use-system-compiler" option.
6    
7     Source: none
8    
9 elmer 1.51 %if "%(echo %cmsos | grep osx >/dev/null && echo true)" == "true"
10     Requires: gfortran-macosx
11     %endif
12    
13 eulisse 1.1 %prep
14     %build
15     %install
16     mkdir -p %i/etc/scram.d
17 elmer 1.51
18 fwyzard 1.54 # Determine the GCC_ROOT if "use system compiler" is used.
19 eulisse 1.1 if [ "X$GCC_ROOT" = X ]
20     then
21 elmer 1.51 export GCC_PATH=`which gcc` || exit 1
22     export GCC_ROOT=`echo $GCC_PATH | sed -e 's|/bin/gcc||'`
23     export GCC_VERSION=`gcc -v 2>&1 | grep "gcc version" | sed 's|[^0-9]*\([0-9].[0-9].[0-9]\).*|\1|'` || exit 1
24 fwyzard 1.54 export G77_ROOT=$GCC_ROOT
25 elmer 1.51 else
26     export GCC_PATH
27     export GCC_ROOT
28     export GCC_VERSION
29     export G77_ROOT=$GCC_ROOT
30 eulisse 1.1 fi
31    
32 fwyzard 1.56 if echo %cmsos | grep -q osx; then
33     # on Mac OS X, override G77_ROOT with GFORTRAN_MACOSX_ROOT
34     export G77_ROOT=$GFORTRAN_MACOSX_ROOT
35     fi
36    
37 elmer 1.51 export COMPILER_VERSION=`echo %cmsplatf | sed -e 's|.*gcc\([0-9]*\).*|\1|'`
38     export COMPILER_VERSION_MAJOR=`echo %cmsplatf | sed -e 's|.*gcc\([0-9]\).*|\1|'`
39     export COMPILER_VERSION_MINOR=`echo %cmsplatf | sed -e 's|.*gcc[0-9]\([0-9]\).*|\1|'`
40    
41     # Generic template for the toolfiles.
42     # *** USE @VARIABLE@ plus associated environment variable to customize. ***
43     # DO NOT DUPLICATE the toolfile template.
44 eulisse 1.1
45 muzaffar 1.22 cat << \EOF_TOOLFILE >%i/etc/scram.d/cxxcompiler.xml
46     <tool name="cxxcompiler" version="@GCC_VERSION@" type="compiler">
47     <client>
48 elmer 1.51 <environment name="CXXCOMPILER_BASE" default="@GCC_ROOT@"/>
49     <environment name="GCCBINDIR" default="$CXXCOMPILER_BASE/bin"/>
50     <environment name="CXX" value="$GCCBINDIR/c++@COMPILER_NAME_SUFFIX@"/>
51 muzaffar 1.22 </client>
52 elmer 1.51 <flags SCRAM_COMPILER_NAME="gcc@COMPILER_VERSION@"/>
53     <flags CCCOMPILER="gcc@COMPILER_VERSION_MAJOR@"/>
54     <flags MODULEFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
55     <flags CXXDEBUGFLAG="-g"/>
56     <flags CPPDEFINES="GNU_GCC"/>
57     <flags CPPDEFINES="_GNU_SOURCE"/>
58     <flags CXXSHAREDOBJECTFLAGS="-fPIC"/>
59     <flags CXXFLAGS="-O2 -pedantic -ansi -pthread -pipe"/>
60     <flags CXXFLAGS="@ARCH_CXXFLAGS@ @COMPILER_CXXFLAGS@"/>
61     <flags CXXFLAGS="-felide-constructors -fmessage-length=0 -ftemplate-depth-300"/>
62     <flags CXXFLAGS="-Wall -Wno-non-template-friend -Wno-long-long -Wimplicit -Wreturn-type -Wunused -Wparentheses -Wno-deprecated -Werror=return-type -Werror=missing-braces -Werror=unused-value -Werror=address -Werror=format -Werror=sign-compare -Werror=write-strings -Werror=strict-overflow -fdiagnostics-show-option"/>
63     <flags LDFLAGS="@OS_LDFLAGS@"/>
64     <flags CXXSHAREDFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
65     <flags SHAREDSUFFIX="@OS_SHAREDSUFFIX@"/>
66     <flags LD_UNIT="@OS_LD_UNIT@ @ARCH_LD_UNIT@"/>
67     <flags SCRAM_LANGUAGE_TYPE="C++"/>
68     <runtime name="@OS_RUNTIME_LDPATH_NAME@" value="$CXXCOMPILER_BASE/@ARCH_LIB64DIR@" type="path"/>
69     <runtime name="@OS_RUNTIME_LDPATH_NAME@" value="$CXXCOMPILER_BASE/lib" type="path"/>
70     <runtime name="PATH" value="$CXXCOMPILER_BASE/bin" type="path"/>
71 muzaffar 1.22 </tool>
72 elmer 1.7 EOF_TOOLFILE
73 elmer 1.51
74 muzaffar 1.22 cat << \EOF_TOOLFILE >%i/etc/scram.d/ccompiler.xml
75     <tool name="ccompiler" version="@GCC_VERSION@" type="compiler">
76     <client>
77 elmer 1.51 <environment name="CCOMPILER_BASE" default="@GCC_ROOT@"/>
78     <environment name="GCCBINDIR" value="$CCOMPILER_BASE/bin"/>
79     <environment name="CC" value="$GCCBINDIR/gcc@COMPILER_NAME_SUFFIX@"/>
80 muzaffar 1.22 </client>
81 elmer 1.51 <flags CDEBUGFLAG="-g"/>
82     <flags CSHAREDOBJECTFLAGS="-fPIC"/>
83     <flags CFLAGS="-pthread"/>
84     <flags CFLAGS="-O2"/>
85     <flags LDFLAGS="@OS_LDFLAGS@"/>
86     <flags CSHAREDFLAGS="@OS_SHAREDFLAGS@ @ARCH_SHAREDFLAGS@"/>
87     <flags SCRAM_COMPILER_NAME="gcc@COMPILER_VERSION@"/>
88     <flags SCRAM_LANGUAGE_TYPE="C"/>
89 muzaffar 1.22 </tool>
90 elmer 1.7 EOF_TOOLFILE
91 elmer 1.51
92     # Notice that on OSX we have a LIBDIR defined for f77compiler because gcc C++
93     # compiler (which comes from the system) does not know about where to find
94     # libgfortran.
95 muzaffar 1.22 cat << \EOF_TOOLFILE >%i/etc/scram.d/f77compiler.xml
96     <tool name="f77compiler" version="@GCC_VERSION@" type="compiler">
97     <lib name="gfortran"/>
98     <lib name="m"/>
99     <client>
100 elmer 1.51 <environment name="F77COMPILER_BASE" default="@G77_ROOT@"/>
101     <environment name="FC" default="$F77COMPILER_BASE/bin/gfortran"/>
102     @ARCH_FORTRAN_LIBDIR@
103 muzaffar 1.22 </client>
104 elmer 1.51 <flags SCRAM_COMPILER_NAME="gcc@COMPILER_VERSION@"/>
105     <flags FFLAGS="-fno-second-underscore -Wunused -Wuninitialized -O2"/>
106     <flags FCO2FLAG="-O2"/>
107     <flags FCOPTIMISED="-O2"/>
108     <flags FCDEBUGFLAG="-g"/>
109     <flags FCSHAREDOBJECTFLAGS="-fPIC"/>
110     <flags SCRAM_LANGUAGE_TYPE="FORTRAN"/>
111 fwyzard 1.50 </tool>
112     EOF_TOOLFILE
113 elmer 1.51
114     # NON-empty defaults
115     export COMPILER_EXEC_NAME="c++"
116    
117     # First of all handle OS specific options.
118     case %cmsplatf in
119     slc* )
120     export OS_SHAREDFLAGS="-shared -Wl,-E"
121     export OS_SHAREDSUFFIX="so"
122     export OS_LDFLAGS="-Wl,-E -Wl,--hash-style=gnu"
123     export OS_RUNTIME_LDPATH_NAME="LD_LIBRARY_PATH"
124     ;;
125     osx* )
126     export OS_SHAREDFLAGS="-shared -dynamic -single_module"
127     export OS_SHAREDSUFFIX="dylib"
128     export OS_LDFLAGS="-Wl,-commons -Wl,use_dylibs"
129     export OS_RUNTIME_LDPATH_NAME="DYLD_LIBRARY_PATH"
130     ;;
131 eulisse 1.1 esac
132    
133 elmer 1.51 # Then handle OS + architecture specific options (maybe we should enable more
134     # aggressive optimizations for amd64 as well??)
135 elmer 1.15 case %cmsplatf in
136 elmer 1.51 osx*_ia32_* )
137     export ARCH_CXXFLAGS="-arch i386"
138     export ARCH_SHAREDFLAGS="-arch i386"
139     export ARCH_LIB64DIR="lib"
140     export ARCH_FORTRAN_LIBDIR='<environment name="LIBDIR" default="$F77COMPILER_BASE/lib/gcc/i686-apple-darwin10/4.2.1"/>'
141     ;;
142     osx*_amd64_* )
143     export ARCH_CXXFLAGS="-arch x86_64"
144     export ARCH_SHAREDFLAGS="-arch x86_64"
145     export ARCH_LIB64DIR="lib"
146     export ARCH_FORTRAN_LIBDIR='<environment name="LIBDIR" default="$F77COMPILER_BASE/lib/gcc/i686-apple-darwin10/4.2.1/x86_64"/>'
147 elmer 1.15 ;;
148 elmer 1.51 osx*_ppc32_* )
149     export ARCH_CXXFLAGS="-arch ppc"
150     export ARCH_SHAREDFLAGS="-arch ppc"
151     export ARCH_LIB64DIR="lib"
152 dsr 1.24 ;;
153 elmer 1.51 slc*_amd64_* )
154     # For some reason on mac, some of the header do not compile if this is
155     # defined. Ignore for now.
156     export ARCH_CXXFLAGS="-Werror=overflow"
157     export ARCH_LIB64DIR="lib64"
158     export ARCH_LD_UNIT="-r -m elf_x86_64"
159 muzaffar 1.35 ;;
160 elmer 1.51 slc*_ia32_* )
161     # For some reason on mac, some of the header do not compile if this is
162     # defined. Ignore for now.
163     export ARCH_CXXFLAGS="-Werror=overflow"
164     export ARCH_LIB64DIR="lib"
165     export ARCH_LD_UNIT="-r -m elf_i386"
166     ;;
167     *)
168     echo "Unsupported."
169     exit 1
170     ;;
171     esac
172    
173     # Then handle compiler specific options. E.g. enable
174     # optimizations as they become available in gcc.
175     COMPILER_CXXFLAGS=
176 fwyzard 1.55 # The following is the default even if not set here
177     F77_MMD="-MMD"
178 elmer 1.51 case %cmsplatf in
179     *_gcc4[56789]* )
180     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -std=c++0x -ftree-vectorize"
181     F77_MMD="-cpp -MMD"
182     ;;
183     esac
184 fwyzard 1.55 export F77_MMD
185 elmer 1.51
186     case %cmsplatf in
187     *_gcc4[3456789]* )
188     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -Werror=array-bounds -Werror=format-contains-nul -Werror=type-limits"
189     ;;
190     esac
191    
192     # Enable visibility inlines hidden. Should drastically remove
193     # the amount of symbols due to templates.
194     # FIXME: not enabled on linux, yet, change the case statement
195     # to *_gcc4[23456789]* when stable.
196     case %cmsplatf in
197     osx* )
198     COMPILER_CXXFLAGS="$COMPILER_CXXFLAGS -fvisibility-inlines-hidden"
199 eulisse 1.45 ;;
200 elmer 1.51 esac
201    
202     export COMPILER_CXXFLAGS
203    
204     # Handle here platform specific overrides. In case we
205     # want to tune something for a specific architecture.
206     case %cmsplatf in
207     osx10[56]*)
208     # On macosx we explicitly pick up a compiler version so that there is
209     # actually matching between the platform specified to cmsBuild and the
210     # compiler.
211     export COMPILER_NAME_SUFFIX="-$COMPILER_VERSION_MAJOR.$COMPILER_VERSION_MINOR"
212 dsr 1.24 ;;
213 elmer 1.15 esac
214    
215     # General substitutions
216 elmer 1.51 perl -p -i -e 's|\@([^@]*)\@|$ENV{$1}|g' %i/etc/scram.d/*.xml
217    
218 eulisse 1.1 %post
219 muzaffar 1.52 %{relocateConfig}etc/scram.d/*.xml
220 elmer 1.51 echo "GCC_TOOLFILE_ROOT='$CMS_INSTALL_PREFIX/%{pkgrel}'; export GCC_TOOLFILE_ROOT" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.sh
221     echo "setenv GCC_TOOLFILE_ROOT '$CMS_INSTALL_PREFIX/%{pkgrel}'" > $RPM_INSTALL_PREFIX/%{pkgrel}/etc/profile.d/init.csh