Salome HOME
Update copyright information
[modules/filter.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 # $Header$
25 #
26 ORIG_DIR=`pwd`
27 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
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 # Test if the GUI_ROOT_DIR is set correctly
45
46 if test ! -d "${GUI_ROOT_DIR}"; then
47     echo "failed : GUI_ROOT_DIR variable is not correct !"
48     exit
49 fi
50
51 ########################################################################
52 # Test if the MED_ROOT_DIR is set correctly
53
54 if test ! -d "${MED_ROOT_DIR}"; then
55     echo "failed : MED_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   local i
76   local 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         echo "error : can't create files in" ${CONF_DIR}
131         echo "aborting ..."
132         chmod u-w configure.in.base 
133         exit
134 fi
135 chmod u-w configure.in.base 
136
137 if [ -e "${CONF_DIR}/salome_adm" ] ; then
138     \rm -f ${CONF_DIR}/salome_adm
139 fi
140
141
142 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
143 echo "" >> configure.in_tmp1
144 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1
145
146 echo  "" >> configure.in_tmp1
147 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
148
149 #
150 # List of .in files in the adm/unix directory
151 # These files MUST be on top of AC_OUTPUT list so we
152 # put them "manually"
153 #
154
155 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
156 echo "  ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
157 echo "  ./salome_adm/unix/sstream \\" >> configure.in_tmp1
158 echo "  ./salome_adm/unix/depend \\" >> configure.in_tmp1
159 echo "  ./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
160 echo "  ./salome_adm/unix/envScript \\" >> configure.in_tmp1
161 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
162 echo "  ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
163 echo "  ./salome_adm/unix/make_module \\" >> configure.in_tmp1
164
165 \rm -f configure.in_tmp2 configure.in_tmp3
166 touch configure.in_tmp2
167 find_in . configure.in_tmp2
168 sed -e '/^...salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
169 sed -e '/^...adm_local.unix.make_omniorb/d' configure.in_tmp3 > configure.in_tmp2
170 sed -e '/^...adm_local.unix.make_commence/d' configure.in_tmp2 > configure.in_tmp3
171 sed -e '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
172 sed -e 's/.in / /' configure.in_tmp2 >>  configure.in_tmp1
173 #sed '/^.*salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
174 #sed '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
175 #sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
176
177 echo  "])" >> configure.in_tmp1
178
179 # delete the link created for AC_OUTPUT
180 #echo "" >> configure.in_tmp1
181 #echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
182 \mv configure.in_tmp1 configure.in_new
183 \rm  -f configure.in_tmp2 configure.in_tmp3
184
185
186 ########################################################################
187 # Create new (or replace old) configure.in file
188 # Print a message if the file is write protected
189 #
190
191 echo
192 if test ! -f configure.in
193 then
194         echo -n "Creating new file 'configure.in' ... "
195         if \mv configure.in_new configure.in >& /dev/null
196         then
197                 echo "done"
198         else
199                 echo "error, check your file permissions"
200         fi
201 else
202         echo -n "Updating 'configure.in' file ... "
203         if ! \cp configure.in configure.in_old >& /dev/null
204         then
205                 echo
206                 echo
207                 echo "Can't backup previous configure.in"
208                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
209                 read R
210                 case "x$R" in
211                     xn*) exit;;
212                     xN*) exit;;
213                 esac
214                 echo
215                 echo -n "                                 "
216         fi
217         if \cp configure.in_new configure.in >& /dev/null
218         then
219                 echo "done"
220         else
221                 echo
222                 echo "error, can't update previous configure.in"
223         fi
224 fi
225
226 ########################################################################
227 # Use autoconf to rebuild the configure script
228 #
229
230 if test -f configure
231 then
232         echo -n "Updating 'configure' script ...  "
233 else
234         echo -n "Creating 'configure' script ...  "
235 fi
236
237 aclocal -I adm_local/unix/config_files \
238         -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
239         -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files/DEPRECATED \
240         -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
241         -I ${MED_ROOT_DIR}/adm_local/unix/config_files
242         
243 if autoconf
244 then
245         echo "done"
246 else
247         echo "failed (check file permissions and/or user quotas ...)"
248 fi
249
250 cd ${ORIG_DIR}
251
252 echo