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