Salome HOME
Join modifications from branch OCC_debug_for_3_2_0b1
[samples/light.git] / build_configure
1 #!/bin/bash
2
3 ########################################################################
4 #  LIGHT : sample (no-corba-engine) SALOME module
5 #
6 #  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
7 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
8 #
9 #  This library is free software; you can redistribute it and/or
10 #  modify it under the terms of the GNU Lesser General Public
11 #  License as published by the Free Software Foundation; either
12 #  version 2.1 of the License.
13 #
14 #  This library is distributed in the hope that it will be useful,
15 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
16 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17 #  Lesser General Public License for more details.
18 #
19 #  You should have received a copy of the GNU Lesser General Public
20 #  License along with this library; if not, write to the Free Software
21 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
22 #
23 #  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 #
25 #  Author : Marc Tajchman - CEA
26 #  Date   : 10/10/2002
27 #  $Header$
28 #
29 #  Tool for updating list of .in file for the SALOME project 
30 #  and regenerating configure script
31 #
32 ########################################################################
33
34 ORIG_DIR=`pwd`
35 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
36
37 ########################################################################
38 # Test if the KERNEL_ROOT_DIR is set correctly
39
40 if test ! -d "${KERNEL_ROOT_DIR}"; then
41     echo "failed : KERNEL_ROOT_DIR variable is not correct !"
42     exit
43 fi
44
45 # Test if the KERNEL_SRC is set correctly
46
47 #if test ! -d "${KERNEL_SRC}"; then
48 #    echo "failed : KERNEL_SRC variable is not correct !"
49 #    exit
50 #fi
51 ########################################################################
52 # Test if the GUI_ROOT_DIR is set correctly
53
54 if test ! -d "${GUI_ROOT_DIR}"; then
55     echo "failed : GUI_ROOT_DIR variable is not correct !"
56     exit
57 fi
58
59 ########################################################################
60 # find_in - utility function
61 #
62 # usage :  
63 #    find_in directory filename 
64 #
65 # Finds files following the *.in pattern, recursively in the
66 # directory (first argument).
67 # Results are appended into the file (second argument)
68 #
69 # Difference from the standard unix find is that files are tested
70 # before directories
71
72
73 find_in()
74 {
75   i=0
76   f=$2
77
78 # if the first argument is not a directory, returns
79
80   if [ ! -d "$1" ] ; then 
81      return 
82   fi
83
84 # dont look in the CVS directories
85
86   case $1 in
87     */CVS) return ;;
88     */adm_local/*) return ;;
89     *) ;;
90   esac
91
92 # for each regular file contained in the directory
93 # test if it's a .in file
94
95   for i in "$1"/*
96   do
97      if [ -f "$i" ] ; then
98        case $i in 
99          *.in) echo "   "$i" \\" >> $f;;
100          *) ;;
101         esac
102      fi
103   done
104
105 # for each subdirectory of the first argument, proceeds recursively
106
107   for i in "$1"/*
108   do
109      if [ -d "$i" ] ; then
110         find_in "$i" "$f"
111      fi
112   done
113 }
114
115
116 #######################################################################
117 # Generate list of .in files (Makefile.in, config.h.in, etc)
118 # appending it in file configure.in
119
120 cd ${CONF_DIR}
121 ABS_CONF_DIR=`pwd`
122
123 #
124 # Common part of the configure.in file
125 #
126 chmod u+w configure.in.base
127 if \cp -f configure.in.base configure.in_tmp1
128 then
129         echo
130 else
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}/.' >> configure.in_tmp1
146
147 # make a link allowing AC_OUTPUT to find the GUI make_conlude.in  files
148 echo "" >> configure.in_tmp1
149 echo 'ln -fs ${GUI_ROOT_DIR}/adm_local ${ROOT_SRCDIR}/gui_adm' >> configure.in_tmp1
150
151 echo  "" >> configure.in_tmp1
152 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
153
154 #
155 # List of .in files in the adm/unix directory
156 # These files MUST be on top of AC_OUTPUT list so we
157 # put them "manually"
158 #
159 # Attention, l'ordre d'entrée des fichiers doit être choisi avec
160 # précision
161 #
162 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
163 echo "  ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
164 echo "  ./salome_adm/unix/sstream \\" >> configure.in_tmp1
165
166 echo "  ./salome_adm/unix/depend \\" >> configure.in_tmp1
167 echo "  ./salome_adm/unix/envScript \\" >> configure.in_tmp1
168 echo "  ./salome_adm/unix/make_module \\" >> configure.in_tmp1
169
170 # _CS_gbo Pour assurer ls construction correct de la chaîne de
171 # dépendance, il apparaît nécessaire de surcharger le make_conclude
172 # (resp. make_commence) pardéfaut, c'est à dire le make_conclude de
173 # salome_adm, par le make_conclude (resp. make_commence) du module,
174 # c'est à dire le make_conclude (resp. make_commence) du répertoire
175 # adm_local
176 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
177 echo "  ./gui_adm/unix/make_conclude \\" >> configure.in_tmp1
178
179 \rm -f configure.in_tmp2 configure.in_tmp3
180 touch configure.in_tmp2
181
182 find_in . configure.in_tmp2
183
184 # _CS_gbo_100204 Mise à jour du filtre pour prise en compte des
185 # restrictions imposées par les versions récente de autoconf.
186     sed -e '/^  \.\/salome_adm/d' \
187         -e '/configure.in/d'      \
188         -e 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
189
190 echo  "])" >> configure.in_tmp1
191
192 # delete the link created for AC_OUTPUT
193 echo "" >> configure.in_tmp1
194 #echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
195 \mv configure.in_tmp1 configure.in_new
196 \rm  -f configure.in_tmp2 configure.in_tmp3
197
198
199 ########################################################################
200 # Create new (or replace old) configure.in file
201 # Print a message if the file is write protected
202 #
203
204 echo
205 if test ! -f configure.in
206 then
207         echo -n "Creating new file 'configure.in' ... "
208         if \mv configure.in_new configure.in >& /dev/null
209         then
210                 echo "done"
211         else
212                 echo "error, check your file permissions"
213         fi
214 else
215         echo -n "Updating 'configure.in' file ... "
216         if \cp configure.in configure.in_old >& /dev/null
217         then
218                 echo
219         else
220                 echo
221                 echo
222                 echo "Can't backup previous configure.in"
223                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
224                 read R
225                 case "x$R" in
226                     xn*) exit;;
227                     xN*) exit;;
228                 esac
229                 echo
230                 echo -n "                                 "
231         fi
232         if \cp configure.in_new configure.in >& /dev/null
233         then
234                 echo "done"
235         else
236                 echo
237                 echo "error, can't update previous configure.in"
238         fi
239 fi
240
241 ########################################################################
242 # Use autoconf to rebuild the configure script
243 #
244
245 if test -f configure
246 then
247         echo -n "Updating 'configure' script ...  "
248 else
249         echo -n "Creating 'configure' script ...  "
250 fi
251
252 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
253                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files
254 if autoconf
255 then
256         echo "done"
257 else
258         echo "failed (check file permissions and/or user quotas ...)"
259 fi
260
261 cd ${ORIG_DIR}
262
263 echo