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