ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/COMP/CMSDIST/gcc-toolfile.spec
(Generate patch)

Comparing COMP/CMSDIST/gcc-toolfile.spec (file contents):
Revision 1.22 by muzaffar, Tue Jan 12 13:59:38 2010 UTC vs.
Revision 1.49 by elmer, Wed Dec 29 18:43:11 2010 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines