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