Salome HOME
*** empty log message ***
[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 # find_in - utility function
57 #
58 # usage :  
59 #    find_in directory filename 
60 #
61 # Finds files following the *.in pattern, recursively in the
62 # directory (first argument).
63 # Results are appended into the file (second argument)
64 #
65 # Difference from the standard unix find is that files are tested
66 # before directories
67
68
69 find_in()
70 {
71   local i
72   local f=$2
73
74 # if the first argument is not a directory, returns
75
76   if [ ! -d "$1" ] ; then 
77      return 
78   fi
79
80 # dont look in the CVS directories
81
82   case $1 in
83     */CVS) return ;;
84     */adm_local/*) return ;;
85     *) ;;
86   esac
87
88 # for each regular file contained in the directory
89 # test if it's a .in file
90
91   for i in "$1"/*
92   do
93      if [ -f "$i" ] ; then
94        case $i in 
95          *.in) echo $i" \\" >> $f;;
96          *) ;;
97         esac
98      fi
99   done
100
101 # for each subdirectory of the first argument, proceeds recursively
102
103   for i in "$1"/*
104   do
105      if [ -d "$i" ] ; then
106         find_in "$i" "$f"
107      fi
108   done
109 }
110
111
112 #######################################################################
113 # Generate list of .in files (Makefile.in, config.h.in, etc)
114 # appending it in file configure.in
115
116 cd ${CONF_DIR}
117 ABS_CONF_DIR=`pwd`
118
119 #
120 # Common part of the configure.in file
121 #
122 chmod u+w configure.in.base
123 if ! \cp -f configure.in.base configure.in_tmp1 
124 then
125         echo
126         echo "error : can't create files in" ${CONF_DIR}
127         echo "aborting ..."
128         chmod u-w configure.in.base 
129         exit
130 fi
131 chmod u-w configure.in.base 
132
133 if [ -e "${CONF_DIR}/salome_adm" ] ; then
134     \rm -f ${CONF_DIR}/salome_adm
135 fi
136
137 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
138 echo "" >> configure.in_tmp1
139 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}' >> configure.in_tmp1
140
141 echo  "" >> configure.in_tmp1
142 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
143
144 #
145 # List of .in files in the adm/unix directory
146 # These files MUST be on top of AC_OUTPUT list so we
147 # put them "manually"
148 #
149
150 echo "./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
151 echo "./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
152 echo "./salome_adm/unix/sstream \\" >> configure.in_tmp1
153 echo "./salome_adm/unix/depend \\" >> configure.in_tmp1
154 echo "./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
155 echo "./salome_adm/unix/envScript \\" >> configure.in_tmp1
156 echo "./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
157 echo "./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
158 echo "./salome_adm/unix/make_module \\" >> configure.in_tmp1
159
160 \rm -f configure.in_tmp2
161 touch configure.in_tmp2
162 find_in . configure.in_tmp2
163
164 sed -e '/^...salome_adm/d'    \
165     -e '/configure.in/d'      \
166     -e '/^...adm_local/d'     \
167     -e 's/.in / /'            \
168     configure.in_tmp2  >>  configure.in_tmp1
169
170 echo  "])" >> configure.in_tmp1
171
172 # delete the link created for AC_OUTPUT
173 echo "" >> configure.in_tmp1
174 \mv configure.in_tmp1 configure.in_new
175 \rm  -f configure.in_tmp2 
176
177
178 ########################################################################
179 # Create new (or replace old) configure.in file
180 # Print a message if the file is write protected
181 #
182
183 echo
184 if test ! -f configure.in
185 then
186         echo -n "Creating new file 'configure.in' ... "
187         if \mv configure.in_new configure.in >& /dev/null
188         then
189                 echo "done"
190         else
191                 echo "error, check your file permissions"
192         fi
193 else
194         echo -n "Updating 'configure.in' file ... "
195         if ! \cp configure.in configure.in_old >& /dev/null
196         then
197                 echo
198                 echo
199                 echo "Can't backup previous configure.in"
200                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
201                 read R
202                 case "x$R" in
203                     xn*) exit;;
204                     xN*) exit;;
205                 esac
206                 echo
207                 echo -n "                                 "
208         fi
209         if \cp configure.in_new configure.in >& /dev/null
210         then
211                 \rm  -f configure.in_new
212                 echo "done"
213         else
214                 echo
215                 echo "error, can't update previous configure.in"
216         fi
217 fi
218
219 ########################################################################
220 # Use autoconf to rebuild the configure script
221 #
222
223 if test -f configure
224 then
225         echo -n "Updating 'configure' script ...  "
226 else
227         echo -n "Creating 'configure' script ...  "
228 fi
229
230 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
231                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
232                                        -I ${MED_ROOT_DIR}/adm_local/unix/config_files
233 if autoconf
234 then
235         echo "done"
236 else
237         echo "failed (check file permissions and/or user quotas ...)"
238 fi
239
240 cd ${ORIG_DIR}
241
242 echo