/[MITgcm]/MITgcm_contrib/PRM/build_scripts/makemake.sh
ViewVC logotype

Annotation of /MITgcm_contrib/PRM/build_scripts/makemake.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (hide annotations) (download) (as text)
Mon Sep 17 03:10:20 2007 UTC (17 years, 10 months ago) by cnh
Branch: MAIN
Changes since 1.1: +22 -1 lines
File MIME type: application/x-sh
Stuff for upgraded columbia compilers build.

1 cnh 1.1 #! /usr/bin/env bash
2     #
3     # Cheap shell script for building makefile
4     # Has various missing features
5     # o can't cope with source files that have duplicate names but that
6     # are in different libraries
7     # o doesn't have any explicit concept of ordering
8     # o needs to deal with .F, .F90 and .c suffixes
9     #
10     # Debug settings
11     # set -uvx
12     #
13     if test -f makemake.header ; then
14     cat makemake.header
15     fi
16    
17     F90_SUFF=F90
18     OBJ_SUFF='o'
19     MOD_SUFF='mod'
20     F90C=gfortran
21     F90C=ifort
22     F90C_ARGS='-O0 -c -CB -g -o'
23     F90C_ARGS='-O0 -c -g -o'
24     LINK=gfortran
25     LINK=ifort
26     EXE=a.out
27     #
28     dlist='../src ../pkg'
29     command=`which $0`
30     tdir=.`echo ${command} | sed -e 's/\/.*\///g' | sed -e 's/\..*$//g'`.$$
31     echo "# Searching directories "${dlist}
32     echo "# Using temporary directory "${tdir}
33    
34     echo ifndef F90C
35     echo F90C=${F90C}
36     echo endif
37    
38     echo F90C_ARGS=${F90C_ARGS}
39     echo OBJ_SUFF=${OBJ_SUFF}
40     echo MOD_SUFF=${MOD_SUFF}
41    
42     echo ifndef F90C
43     echo LINK=${LINK}
44     echo endif
45    
46     echo ifndef EXE
47     echo EXE=${EXE}
48     echo endif
49    
50     mkdir ${tdir}
51    
52     # Set the includes
53     echo IDIR='\'
54     for d in ${dlist} ; do
55     dl=`find $d -follow -type d -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
56     for di in ${dl} ; do
57     echo '-I'${di}' \'
58     done
59     done
60     echo '$(EXTRA_IDIR)'
61    
62     # Executable links all the .o from ${dlist} except libs which are built
63     # from each ../pkg subdirectory
64     ol=''
65     ll=''
66     lo=''
67     for d in ${dlist} ; do
68     if test "${d##*/}" = "pkg" ; then
69     # All these are treated as separate library sources
70     dl=`find $d -follow -type d -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
71     for dd in ${dl} ; do
72     if test "${dd##*/}" != "pkg" ; then
73     echo '## Library name = 'lib${dd##*/}.a
74     lfl=`find ${dd} -follow -maxdepth 1 -type f -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
75     echo '## Library files = '${lfl##*/}
76     ll=${ll}' 'lib${dd##*/}.a
77     lo=${lo}' '-l${dd##*/}
78     fi
79     done
80     else
81     # All others are .o
82     fl=`find $d -follow -name '*.'${F90_SUFF} -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
83     for f in ${fl} ; do
84     fn=${f##*/}
85     of=${fn%.*}.${OBJ_SUFF}
86     ol=${ol}' '${of}
87     done
88     fi
89     done
90    
91     # Write objlist
92     echo 'OBJLIST=\'
93     for o in ${ol} ; do
94     echo ${o}' \'
95     done
96     echo ' '
97    
98     # Write library list
99     echo 'LIBLIST=\'
100     for l in ${ll} ; do
101     echo ${l}' \'
102     done
103     echo '$(EXTRA_LIB_LIST)'
104     echo ' '
105    
106 cnh 1.2 # Write liball.a library list
107     echo 'LIBLIST_ALL=\'
108     for l in ${ll} ; do
109     echo ${l}' \'
110     done
111     echo ' '
112    
113 cnh 1.1 # Write library option
114     # write it twice because gnu linker doesn't search backwards and we don't know the
115     # right order (I think this is what ar and ranlib are for!)
116 cnh 1.2 # Add liball.a to fix issues with intel compiler on columbia (2007-09-16) (ifort 9.1.039).
117 cnh 1.1 echo 'LIBOPT=\'
118     for l in ${lo} ; do
119     echo ${l}' \'
120     done
121     for l in ${lo} ; do
122     echo ${l}' \'
123     done
124 cnh 1.2 echo '-lall '
125 cnh 1.1 echo ' '
126    
127    
128     # Set rule for executable
129 cnh 1.2 echo '$(EXE): $(OBJLIST) $(LIBLIST) liball.a'
130 cnh 1.1 echo -e \\t'$(LINK) -L. -o $(EXE) $(OBJLIST) $(LIBOPT) $(EXTRA_LOPT)'
131    
132 cnh 1.2 # Set rule for liball.a
133     echo ' '
134     echo 'liball.a: $(LIBLIST_ALL)'
135     echo ' \rm -fr tmp'
136     echo ' \rm -f liball.a'
137     echo ' mkdir tmp'
138     echo ' cp $(LIBLIST_ALL) tmp'
139     echo ' cd tmp; ls -1 *.a | sed "s/^.*/ar x &/" > foo'
140     echo ' cd tmp; source foo'
141     echo ' cd tmp; ar rc liball.a *.o; cp liball.a ..'
142    
143    
144 cnh 1.1 # Set rule for libraries
145     ol=''
146     ll=''
147     for d in ${dlist} ; do
148     if test "${d##*/}" = "pkg" ; then
149     # All these are treated as separate library sources
150     dl=`find $d -follow -type d -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
151     for dd in ${dl} ; do
152     if test "${dd##*/}" != "pkg" ; then
153     lfl=`find ${dd} -follow -maxdepth 1 -type f -not -regex '.*/\.[a-zA-Z].*' -not -regex '.*\CVS*'`
154     # lfl=`find -L ${dd} -maxdepth 1 -type f -not -regex '.*\.svn.*'`
155     fo=''
156     for ff in ${lfl}; do
157     f=${ff##*/}
158     fo=${fo}' '${f%%.${F90_SUFF}}.${OBJ_SUFF}
159     done
160     echo lib${dd##*/}.a:' '${fo}
161     echo -e \\t'@touch 'lib${dd##*/}.a
162     echo -e \\t'@rm 'lib${dd##*/}.a
163     echo -e \\t'$(AR) -rus' lib${dd##*/}.a ${fo}
164     fi
165     echo ' '
166     done
167     fi
168     done
169    
170     # Set rule for individual object and module files
171     for d in ${dlist} ; do
172     fl=`find $d -follow -name '*.'${F90_SUFF} -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
173     for f in ${fl} ; do
174     fonly=${f##*/}
175     base=${fonly%.*}
176     echo ${base}.${OBJ_SUFF}: $f
177     echo -e \\t'$(F90C) $(IDIR) $(F90C_ARGS) $@ $<'
178     echo ${base}.${MOD_SUFF}: $f
179     echo -e \\t'$(F90C) $(IDIR) $(F90C_ARGS) '${base}.${OBJ_SUFF}' $<'
180     done
181     done
182    
183     # Add dependency rules for source that includes another module via a USE
184     # statement
185     for d in ${dlist} ; do
186     fl=`find $d -follow -name '*.'${F90_SUFF} -not -regex '.*\.svn.*' -not -regex '.*\CVS*'`
187     for f in ${fl} ; do
188     fonly=${f##*/}
189     base=${fonly%.*}
190     mlist=`grep -i '^ *use *' ${f} | awk '{print $2}'`
191     for m in ${mlist} ; do
192     # echo ${base}.'$(OBJ_SUFF)': $m.'$(OBJ_SUFF)'
193     if test -f makemake.externals; then
194     chkext=`grep -i '^'$m' *$' makemake.externals `
195     extyn=$?
196     fi
197     if test "$extyn" != "0" ; then
198     echo ${base}.'$(OBJ_SUFF)': $m.'$(MOD_SUFF)'
199     echo ${base}.'$(MOD_SUFF)': $m.'$(MOD_SUFF)'
200     fi
201     done
202     done
203     done
204    
205     \rm -fr ${tdir}

  ViewVC Help
Powered by ViewVC 1.1.22