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

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

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


Revision 1.3 - (show annotations) (download) (as text)
Tue Jan 8 22:29:57 2008 UTC (17 years, 6 months ago) by jmc
Branch: MAIN
CVS Tags: checkpoint63m, checkpoint63n, HEAD
Changes since 1.2: +3 -0 lines
File MIME type: application/x-sh
Error occurred while calculating annotation data.
get default "einfo=" from prm_site_config_file (commented line)
note: will have no effect if "einfo" is set in local "makemake.header"

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

  ViewVC Help
Powered by ViewVC 1.1.22