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