Salome HOME
Join modifications from BR_Dev_For_4_0 tag V4_1_1.
[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.in
139
140 cd ${CONF_DIR}
141 ABS_CONF_DIR=`pwd`
142
143 #
144 # Common part of the configure.in 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 '/^...adm_local/d'     \
191     -e 's/.in / /'            \
192     configure.in_tmp2  >>  configure.in_tmp1
193
194 echo  "])" >> configure.in_tmp1
195
196 # delete the link created for AC_OUTPUT
197 echo "" >> configure.in_tmp1
198 \mv configure.in_tmp1 configure.in_new
199 \rm  -f configure.in_tmp2 
200
201
202 ########################################################################
203 # Create new (or replace old) configure.in file
204 # Print a message if the file is write protected
205 #
206
207 echo
208 if test ! -f configure.in
209 then
210         echo -n "Creating new file 'configure.in' ... "
211         if \mv configure.in_new configure.in >& /dev/null
212         then
213                 echo "done"
214         else
215                 echo "error, check your file permissions"
216         fi
217 else
218         echo -n "Updating 'configure.in' file ... "
219         if ! \cp configure.in configure.in_old >& /dev/null
220         then
221                 echo
222                 echo
223                 echo "Can't backup previous configure.in"
224                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
225                 read R
226                 case "x$R" in
227                     xn*) exit;;
228                     xN*) exit;;
229                 esac
230                 echo
231                 echo -n "                                 "
232         fi
233         if \cp configure.in_new configure.in >& /dev/null
234         then
235                 \rm  -f configure.in_new
236                 echo "done"
237         else
238                 echo
239                 echo "error, can't update previous configure.in"
240         fi
241 fi
242
243 ########################################################################
244 # Use autoconf to rebuild the configure script
245 #
246
247 if test -f configure
248 then
249         echo -n "Updating 'configure' script ...  "
250 else
251         echo -n "Creating 'configure' script ...  "
252 fi
253
254 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
255                                        -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/DEPRECATED \
256                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
257                                        -I ${MED_ROOT_DIR}/adm_local/unix/config_files
258 if autoconf
259 then
260         echo "done"
261 else
262         echo "failed (check file permissions and/or user quotas ...)"
263 fi
264
265 cd ${ORIG_DIR}
266
267 echo