Salome HOME
Fix problem with autoconf wrapper on Debian Etch 4.0
[modules/multipr.git] / build_configure
1 #!/bin/bash
2
3 #
4 # Tool for updating list of .in file for the SALOME project 
5 # and regenerating configure script
6 #
7 # Author : Marc Tajchman - CEA
8 # Date : 10/10/2002
9 # $Header $
10 #
11
12 ORIG_DIR=`pwd`
13 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
14
15 ########################################################################
16 # Test if the KERNEL_ROOT_DIR is set correctly
17
18 if test ! -d "${KERNEL_ROOT_DIR}"; then
19     echo "failed : KERNEL_ROOT_DIR variable is not correct !"
20     exit
21 fi
22
23 ########################################################################
24 # Test if the GUI_ROOT_DIR is set correctly
25
26 if test ! -d "${GUI_ROOT_DIR}"; then
27     echo "failed : GUI_ROOT_DIR variable is not correct !"
28     exit
29 fi
30
31 ########################################################################
32 # Test if the MED_ROOT_DIR is set correctly
33
34 if test ! -d "${MED_ROOT_DIR}"; then
35     echo "failed : MED_ROOT_DIR variable is not correct !"
36     exit
37 fi
38
39 ########################################################################
40 # Test if the MED2HOME is set correctly
41
42 if test ! -d "${MED2HOME}"; then
43     echo "failed : MED2HOME variable is not correct !"
44     exit
45 fi
46
47 ########################################################################
48 # Test if the HDF5HOME is set correctly
49
50 if test ! -d "${HDF5HOME}"; then
51     echo "failed : HDF5HOME variable is not correct !"
52     exit
53 fi
54
55 ########################################################################
56 # Test if the CASROOT is set correctly
57
58 if test ! -d "${CASROOT}"; then
59     echo "failed : CASROOT variable is not correct !"
60     exit
61 fi
62
63 ########################################################################
64 # Test if the QTDIR is set correctly
65
66 if test ! -d "${QTDIR}"; then
67     echo "failed : QTDIR variable is not correct !"
68     exit
69 fi
70
71 ########################################################################
72 # Test if the OMNIORBDIR is set correctly
73
74 if test ! -d "${OMNIORBDIR}"; then
75     echo "failed : OMNIORBDIR variable is not correct !"
76     exit
77 fi
78
79 ########################################################################
80 # find_in - utility function
81 #
82 # usage :  
83 #    find_in directory filename 
84 #
85 # Finds files following the *.in pattern, recursively in the
86 # directory (first argument).
87 # Results are appended into the file (second argument)
88 #
89 # Difference from the standard unix find is that files are tested
90 # before directories
91
92
93 find_in()
94 {
95   local i
96   local f=$2
97
98 # if the first argument is not a directory, returns
99
100   if [ ! -d "$1" ] ; then 
101      return 
102   fi
103
104 # dont look in the CVS directories
105
106   case $1 in
107     */CVS) return ;;
108     */adm_local/*) return ;;
109     *) ;;
110   esac
111
112 # for each regular file contained in the directory
113 # test if it's a .in file
114
115   for i in "$1"/*
116   do
117      if [ -f "$i" ] ; then
118        case $i in 
119          *.in) echo $i" \\" >> $f;;
120          *) ;;
121         esac
122      fi
123   done
124
125 # for each subdirectory of the first argument, proceeds recursively
126
127   for i in "$1"/*
128   do
129      if [ -d "$i" ] ; then
130         find_in "$i" "$f"
131      fi
132   done
133 }
134
135
136 #######################################################################
137 # Generate list of .in files (Makefile.in, config.h.in, etc)
138 # appending it in file configure.ac
139
140 cd ${CONF_DIR}
141 ABS_CONF_DIR=`pwd`
142
143 #
144 # Common part of the configure.ac file
145 #
146 chmod u+w configure.in.base
147 if ! \cp -f configure.in.base configure.in_tmp1 
148 then
149         echo
150         echo "error : can't create files in" ${CONF_DIR}
151         echo "aborting ..."
152         chmod u-w configure.in.base 
153         exit
154 fi
155 chmod u-w configure.in.base 
156
157 if [ -e "${CONF_DIR}/salome_adm" ] ; then
158     \rm -f ${CONF_DIR}/salome_adm
159 fi
160
161 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
162 echo "" >> configure.in_tmp1
163 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}' >> configure.in_tmp1
164
165 echo  "" >> configure.in_tmp1
166 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
167
168 #
169 # List of .in files in the adm/unix directory
170 # These files MUST be on top of AC_OUTPUT list so we
171 # put them "manually"
172 #
173
174 echo "./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
175 echo "./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
176 echo "./salome_adm/unix/sstream \\" >> configure.in_tmp1
177 echo "./salome_adm/unix/depend \\" >> configure.in_tmp1
178 echo "./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
179 echo "./salome_adm/unix/envScript \\" >> configure.in_tmp1
180 echo "./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
181 echo "./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
182 echo "./salome_adm/unix/make_module \\" >> configure.in_tmp1
183
184 \rm -f configure.in_tmp2
185 touch configure.in_tmp2
186 find_in . configure.in_tmp2
187
188 sed -e '/^...salome_adm/d'    \
189     -e '/configure.in/d'      \
190     -e '/configure.ac/d'      \
191     -e '/^...adm_local/d'     \
192     -e 's/.in / /'            \
193     configure.in_tmp2  >>  configure.in_tmp1
194
195 echo  "])" >> configure.in_tmp1
196
197 # delete the link created for AC_OUTPUT
198 echo "" >> configure.in_tmp1
199 \mv configure.in_tmp1 configure.in_new
200 \rm  -f configure.in_tmp2 
201
202
203 ########################################################################
204 # Create new (or replace old) configure.ac file
205 # Print a message if the file is write protected
206 #
207
208 echo
209 if test ! -f configure.ac
210 then
211         echo -n "Creating new file 'configure.ac' ... "
212         if \mv configure.in_new configure.ac >& /dev/null
213         then
214                 echo "done"
215         else
216                 echo "error, check your file permissions"
217         fi
218 else
219         echo -n "Updating 'configure.ac' file ... "
220         if ! \cp configure.ac configure.in_old >& /dev/null
221         then
222                 echo
223                 echo
224                 echo "Can't backup previous configure.ac"
225                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
226                 read R
227                 case "x$R" in
228                     xn*) exit;;
229                     xN*) exit;;
230                 esac
231                 echo
232                 echo -n "                                 "
233         fi
234         if \cp configure.in_new configure.ac >& /dev/null
235         then
236                 \rm  -f configure.in_new
237                 echo "done"
238         else
239                 echo
240                 echo "error, can't update previous configure.ac"
241         fi
242 fi
243
244 ########################################################################
245 # Use autoconf to rebuild the configure script
246 #
247
248 if test -f configure
249 then
250         echo -n "Updating 'configure' script ...  "
251 else
252         echo -n "Creating 'configure' script ...  "
253 fi
254
255 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
256                                        -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/DEPRECATED \
257                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
258                                        -I ${MED_ROOT_DIR}/adm_local/unix/config_files
259 if autoconf
260 then
261         echo "done"
262 else
263         echo "failed (check file permissions and/or user quotas ...)"
264 fi
265
266 cd ${ORIG_DIR}
267
268 echo