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