Salome HOME
Join modifications from branch CEAFor_V3_2_0
[modules/med.git] / build_configure
1 #!/bin/sh
2
3 #
4 # Tool for updating list of .in file for the SALOME project 
5 # and regenerating configure script
6 #
7 # It may be called with --with-kernel[=yes,no] or --without-kernel
8 # option, default is --with-kernel=yes
9 #
10 # Author : Marc Tajchman - CEA
11 # Date : 10/10/2002
12 # $Header$
13 #
14
15 ORIG_DIR=`pwd`
16 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
17
18 ########################################################################
19 # Check --with-kernel option
20
21 MED_WITH_KERNEL=""
22
23 for option
24 do
25   case $option in
26       -with-kernel | --with-kernel)
27           MED_WITH_KERNEL="yes"
28           break;;
29       -without-kernel | --without-kernel | -with-kernel=no | --with-kernel=no)
30           MED_WITH_KERNEL="no"
31           break;;
32   esac
33 done
34
35
36 ########################################################################
37 # Test if the GUI_ROOT_DIR is set correctly if GUI required
38
39 if test ! -d "${GUI_ROOT_DIR}"; then
40     echo "failed : GUI_ROOT_DIR variable is not correct !"
41     exit
42 fi
43
44 ########################################################################
45 # find_in - utility function
46 #
47 # usage :  
48 #    find_in directory filename 
49 #
50 # Finds files following the *.in pattern, recursively in the
51 # directory (first argument).
52 # Results are appended into the file (second argument)
53 #
54 # Difference from the standard unix find is that files are tested
55 # before directories
56
57
58 find_in()
59 {
60   i=0
61   f=$2
62
63 # if the first argument is not a directory, returns
64
65   if [ ! -d "$1" ] ; then 
66      return 
67   fi
68
69 # dont look in the CVS directories
70
71   case $1 in
72     */CVS) return ;;
73     */adm_local/*) return ;;
74     *) ;;
75   esac
76
77 # for each regular file contained in the directory
78 # test if it's a .in file
79
80   for i in "$1"/*
81   do
82      if [ -f "$i" ] ; then
83        case $i in 
84          *.in) echo "   "$i" \\" >> $f;;
85          *) ;;
86         esac
87      fi
88   done
89
90 # for each subdirectory of the first argument, proceeds recursively
91
92   for i in "$1"/*
93   do
94      if [ -d "$i" ] ; then
95         find_in "$i" "$f"
96      fi
97   done
98 }
99
100
101 #######################################################################
102 # Generate list of .in files (Makefile.in, config.h.in, etc)
103 # appending it in file configure.in
104
105 cd ${CONF_DIR}
106 ABS_CONF_DIR=`pwd`
107
108 #
109 # Common part of the configure.in file
110 #
111 if \cp -f configure.in.base configure.in_tmp1
112 then
113         echo
114         chmod u+w configure.in_tmp1
115 else
116         echo
117         echo "error : can't create files in" ${CONF_DIR}
118         echo "aborting ..."
119         exit
120 fi
121 chmod u-w configure.in.base 
122
123 if [ -e "${CONF_DIR}/salome_adm" ] ; then
124     \rm -f ${CONF_DIR}/salome_adm
125 fi
126
127 # insert header and AC_INIT(src) which must go before anything else
128 cat > configure.in_tmp1 <<EOF
129 #
130 #  PLEASE DO NOT MODIFY configure.in FILE
131 #
132 #  ALL CHANGES WILL BE DISCARDED BY THE NEXT
133 #  build_configure COMMAND
134 #
135 #  CHANGES MUST BE MADE IN configure.in.base FILE
136 #
137 #
138 # Author : Marc Tajchman (CEA)
139 # Date : 28/06/2001
140 # Modified by : Patrick GOLDBRONN (CEA)
141 # Modified by : Marc Tajchman (CEA)
142 #
143 # Created from configure.in.base
144 #
145
146 AC_INIT(src)
147
148 EOF
149
150 # initialize MED_WITH_KERNEL
151 echo "MED_WITH_KERNEL=${MED_WITH_KERNEL}"                        >> configure.in_tmp1
152
153 # insert the configure.in.base
154 cat configure.in.base                                            >> configure.in_tmp1
155
156 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
157 echo ""                                                          >> configure.in_tmp1
158 echo 'if test ${MED_WITH_KERNEL} = yes; then'                   >> configure.in_tmp1
159 echo '    ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1
160 echo 'else'                                                      >> configure.in_tmp1
161 echo '    ln -fs ${ROOT_SRCDIR}/adm_local_without_kernel ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
162 echo 'fi'                                                        >> configure.in_tmp1
163
164
165 #
166 # List of .in files in the adm/unix directory
167 # These files MUST be on top of AC_OUTPUT list so we
168 # put them "manually"
169 #
170 # Attention, l'ordre d'entrée des fichiers doit être choisi avec
171 # précision
172 #
173 echo ""                                      >> configure.in_tmp1
174 echo "AC_OUTPUT([ \\"                        >> configure.in_tmp1
175 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
176 echo "  ./salome_adm/unix/sstream \\"        >> configure.in_tmp1
177 echo "  ./salome_adm/unix/depend \\"         >> configure.in_tmp1
178 echo  " ])"                                  >> configure.in_tmp1
179 echo ""                                      >> configure.in_tmp1
180 echo 'if test $MED_WITH_KERNEL = yes; then' >> configure.in_tmp1
181 echo "{"                                     >> configure.in_tmp1
182 echo "AC_OUTPUT([ \\"                        >> configure.in_tmp1
183 echo "  ./salome_adm/unix/F77config.h \\"    >> configure.in_tmp1
184 echo "  ./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\"    >> configure.in_tmp1
185 echo "  ./salome_adm/unix/envScript \\"      >> configure.in_tmp1
186 echo  " ])"                                  >> configure.in_tmp1
187 echo "}"                                     >> configure.in_tmp1
188 echo "fi"                                    >> configure.in_tmp1
189 echo ""                                      >> configure.in_tmp1
190 echo "AC_OUTPUT([ \\"                        >> configure.in_tmp1
191 echo "  ./salome_adm/unix/make_module \\"    >> configure.in_tmp1
192
193 # _CS_gbo Pour assurer ls construction correct de la chaîne de
194 # dépendance, il apparaît nécessaire de surcharger le make_conclude
195 # (resp. make_commence) pardéfaut, c'est à dire le make_conclude de
196 # salome_adm, par le make_conclude (resp. make_commence) du module,
197 # c'est à dire le make_conclude (resp. make_commence) du répertoire
198 # adm_local
199 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\"   >> configure.in_tmp1
200 echo "  ./adm_local/unix/make_conclude:${ABS_CONF_DIR}/adm_local/unix/make_conclude.in \\"   >> configure.in_tmp1
201
202 \rm -f configure.in_tmp2 configure.in_tmp3
203 touch configure.in_tmp2
204
205 find_in . configure.in_tmp2
206
207 # _CS_gbo_100204 Mise à jour du filtre pour prise en compte des
208 # restrictions imposées par les versions récente de autoconf.
209     sed -e '/^...salome_adm/d' \
210         -e '/configure.in/d'      \
211         -e 's/.in / /' configure.in_tmp2     >> configure.in_tmp1
212
213 echo  " ])"                                  >> configure.in_tmp1
214
215
216 # delete the link created for AC_OUTPUT
217 #echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
218 \mv configure.in_tmp1 configure.in_new
219 \rm  -f configure.in_tmp2 configure.in_tmp3
220
221
222 ########################################################################
223 # Create new (or replace old) configure.in file
224 # Print a message if the file is write protected
225 #
226
227 echo
228 if test ! -f configure.in
229 then
230         echo -n "Creating new file 'configure.in' ... "
231         if \mv configure.in_new configure.in >& /dev/null
232         then
233                 echo "done"
234         else
235                 echo "error, check your file permissions"
236         fi
237 else
238         echo -n "Updating 'configure.in' file ... "
239         if \cp configure.in configure.in_old >& /dev/null
240         then
241                 echo
242         else
243                 echo
244                 echo
245                 echo "Can't backup previous configure.in"
246                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
247                 read R
248                 case "x$R" in
249                     xn*) exit;;
250                     xN*) exit;;
251                 esac
252                 echo
253                 echo -n "                                 "
254         fi
255         if \cp configure.in_new configure.in >& /dev/null
256         then
257                 echo "done"
258         else
259                 echo
260                 echo "error, can't update previous configure.in"
261         fi
262 fi
263
264 ########################################################################
265 # Use autoconf to rebuild the configure script
266 #
267
268 if test -f configure
269 then
270         echo -n "Updating 'configure' script ...  "
271 else
272         echo -n "Creating 'configure' script ...  "
273 fi
274
275 if test "x${MED_WITH_KERNEL}" != "xno"; then
276    AUX_CONFIG_DIR=${KERNEL_ROOT_DIR}/salome_adm/unix/config_files
277 else
278    AUX_CONFIG_DIR=adm_local_without_kernel/unix/config_files
279 fi
280
281 aclocal -I adm_local/unix/config_files -I ${AUX_CONFIG_DIR} -I ${GUI_ROOT_DIR}/adm_local/unix/config_files
282 if autoconf
283 then
284         echo "done"
285 else
286         echo "failed (check file permissions and/or user quotas ...)"
287 fi
288
289 cd ${ORIG_DIR}
290
291 echo