Salome HOME
Changing version to 4.1.5
[modules/superv.git] / build_configure
1 #!/bin/bash
2 #  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
3 #
4 #  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
5 #  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 #
7 #  This library is free software; you can redistribute it and/or
8 #  modify it under the terms of the GNU Lesser General Public
9 #  License as published by the Free Software Foundation; either
10 #  version 2.1 of the License.
11 #
12 #  This library is distributed in the hope that it will be useful,
13 #  but WITHOUT ANY WARRANTY; without even the implied warranty of
14 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 #  Lesser General Public License for more details.
16 #
17 #  You should have received a copy of the GNU Lesser General Public
18 #  License along with this library; if not, write to the Free Software
19 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
20 #
21 #  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 #
23 # Tool for updating list of .in file for the SALOME project 
24 # and regenerating configure script
25 # Author : Marc Tajchman - CEA
26 # Date : 10/10/2002
27 # $Header$
28 #
29 ORIG_DIR=`pwd`
30 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
31
32 ########################################################################
33 # Check --with-kernel option
34
35 SUPERV_WITH_GUI="yes"
36
37 for option
38 do
39   case $option in
40       -with-ihm | --with-ihm)
41           SUPERV_WITH_GUI="yes"
42           break;;
43       -without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no)
44           SUPERV_WITH_GUI="no"
45           break;;
46   esac
47 done
48
49 ########################################################################
50 # Test if the KERNEL_ROOT_DIR is set correctly
51
52 if test ! -d "${KERNEL_ROOT_DIR}"; then
53     echo "failed : KERNEL_ROOT_DIR variable is not correct !"
54     exit
55 fi
56
57 # Test if the KERNEL_SRC is set correctly
58
59 #if test ! -d "${KERNEL_SRC}"; then
60 #    echo "failed : KERNEL_SRC variable is not correct !"
61 #    exit
62 #fi
63 ########################################################################
64 # Test if the GUI_ROOT_DIR is set correctly
65
66 if test ${SUPERV_WITH_GUI} = yes; then
67   if test ! -d "${GUI_ROOT_DIR}"; then
68     echo "failed : GUI_ROOT_DIR variable is not correct !"
69     exit
70   fi
71 fi
72
73 ########################################################################
74 # find_in - utility function
75 #
76 # usage :  
77 #    find_in directory filename 
78 #
79 # Finds files following the *.in pattern, recursively in the
80 # directory (first argument).
81 # Results are appended into the file (second argument)
82 #
83 # Difference from the standard unix find is that files are tested
84 # before directories
85
86
87 find_in()
88 {
89   local i
90   local f=$2
91
92 # if the first argument is not a directory, returns
93
94   if [ ! -d "$1" ] ; then 
95      return 
96   fi
97
98 # dont look in the CVS directories
99
100   case $1 in
101     */CVS) return ;;
102     */adm_local/*) return ;;
103     *) ;;
104   esac
105
106 # for each regular file contained in the directory
107 # test if it's a .in file
108
109   for i in "$1"/*
110   do
111      if [ -f "$i" ] ; then
112        case $i in 
113          *.in) echo "   "$i" \\" >> $f;;
114          *) ;;
115         esac
116      fi
117   done
118
119 # for each subdirectory of the first argument, proceeds recursively
120
121   for i in "$1"/*
122   do
123      if [ -d "$i" ] ; then
124         find_in "$i" "$f"
125      fi
126   done
127 }
128
129
130 #######################################################################
131 # Generate list of .in files (Makefile.in, config.h.in, etc)
132 # appending it in file configure.in
133
134 cd ${CONF_DIR}
135 ABS_CONF_DIR=`pwd`
136
137 #
138 # Common part of the configure.in file
139 #
140 chmod u+w configure.in.base
141 if ! \cp -f configure.in.base configure.in_tmp1 
142 then
143         echo
144         echo "error : can't create files in" ${CONF_DIR}
145         echo "aborting ..."
146         chmod u-w configure.in.base 
147         exit
148 fi
149 chmod u-w configure.in.base 
150
151 if [ -e "${CONF_DIR}/salome_adm" ] ; then
152     \rm -f ${CONF_DIR}/salome_adm
153 fi
154
155 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
156 echo "" >> configure.in_tmp1
157 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1
158
159 echo  "" >> configure.in_tmp1
160 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
161
162 #
163 # List of .in files in the adm/unix directory
164 # These files MUST be on top of AC_OUTPUT list so we
165 # put them "manually"
166 #
167
168 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
169 echo "  ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
170 echo "  ./salome_adm/unix/sstream \\" >> configure.in_tmp1
171 echo "  ./salome_adm/unix/depend \\" >> configure.in_tmp1
172 echo "  ./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
173 echo "  ./salome_adm/unix/envScript \\" >> configure.in_tmp1
174 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
175 echo "  ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
176 echo "  ./salome_adm/unix/make_module \\" >> configure.in_tmp1
177
178 \rm -f configure.in_tmp2 configure.in_tmp3
179 touch configure.in_tmp2
180 find_in . configure.in_tmp2
181 sed -e '/^...salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
182 sed -e '/^...adm_local.unix.make_omniorb/d' configure.in_tmp3 > configure.in_tmp2
183 sed -e '/^...adm_local.unix.make_commence/d' configure.in_tmp2 > configure.in_tmp3
184 sed -e '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
185 sed -e 's/.in / /' configure.in_tmp2 >>  configure.in_tmp1
186 #sed '/^.*salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
187 #sed '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
188 #sed '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                 echo
220                 echo "Can't backup previous configure.in"
221                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
222                 read R
223                 case "x$R" in
224                     xn*) exit;;
225                     xN*) exit;;
226                 esac
227                 echo
228                 echo -n "                                 "
229         fi
230         if \cp configure.in_new configure.in >& /dev/null
231         then
232                 echo "done"
233         else
234                 echo
235                 echo "error, can't update previous configure.in"
236         fi
237 fi
238
239 ########################################################################
240 # Use autoconf to rebuild the configure script
241 #
242
243 if test -f configure
244 then
245         echo -n "Updating 'configure' script ...  "
246 else
247         echo -n "Creating 'configure' script ...  "
248 fi
249
250 if test ${SUPERV_WITH_GUI} = yes; then
251   aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
252                                          -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/DEPRECATED \
253                                          -I ${GUI_ROOT_DIR}/adm_local/unix/config_files
254 else
255   aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
256                                          -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/DEPRECATED
257 fi
258
259 if autoconf
260 then
261         echo "done"
262 else
263         echo "failed (check file permissions and/or user quotas ...)"
264 fi
265
266 cd ${ORIG_DIR}
267
268 echo