Salome HOME
NPAL18095: Pb. with dump python and mesh group by filter.
[modules/smesh.git] / build_configure
1 #!/bin/bash
2
3 #
4 # Tool for updating list of .in file for the SALOME project 
5 # and regenerating configure script
6 #
7 # Author : Marc Tajchman - CEA
8 # Date : 10/10/2002
9 # $Header$
10 #
11
12 ORIG_DIR=`pwd`
13 CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
14 SMESH_WITH_GUI="yes"
15
16 ########################################################################
17 # Test if the KERNEL_ROOT_DIR is set correctly
18
19 if test ! -d "${KERNEL_ROOT_DIR}"; then
20     echo "failed : KERNEL_ROOT_DIR variable is not correct !"
21     exit
22 fi
23
24 # Test if the KERNEL_SRC is set correctly
25
26 #if test ! -d "${KERNEL_SRC}"; then
27 #    echo "failed : KERNEL_SRC variable is not correct !"
28 #    exit
29 #fi
30
31 for option
32 do
33   case $option in
34       -with-ihm | --with-ihm)
35           SMESH_WITH_GUI="yes"
36           break;;
37       -without-ihm | --without-ihm | -with-ihm=no | --with-ihm=no)
38           SMESH_WITH_GUI="no"
39           break;;
40   esac
41 done
42
43 ########################################################################
44 # Test if the GUI_ROOT_DIR is set correctly
45
46 if test ${SMESH_WITH_GUI} = yes; then
47     if test ! -d "${GUI_ROOT_DIR}"; then
48         echo "failed : GUI_ROOT_DIR variable is not correct !"
49         exit
50     fi
51 fi
52
53 ########################################################################
54 # Test if the MED_ROOT_DIR is set correctly
55
56 if test ! -d "${MED_ROOT_DIR}"; then
57     echo "failed : MED_ROOT_DIR variable is not correct !"
58     exit
59 fi
60
61 ########################################################################
62 # Test if the GEOM_ROOT_DIR is set correctly
63
64 if test ! -d "${GEOM_ROOT_DIR}"; then
65     echo "failed : GEOM_ROOT_DIR variable is not correct !"
66     exit
67 fi
68
69 ########################################################################
70 # find_in - utility function
71 #
72 # usage :  
73 #    find_in directory filename 
74 #
75 # Finds files following the *.in pattern, recursively in the
76 # directory (first argument).
77 # Results are appended into the file (second argument)
78 #
79 # Difference from the standard unix find is that files are tested
80 # before directories
81
82
83 find_in()
84 {
85   local i
86   local f=$2
87
88 # if the first argument is not a directory, returns
89
90   if [ ! -d "$1" ] ; then 
91      return 
92   fi
93
94 # dont look in the CVS directories
95
96   case $1 in
97     */CVS) return ;;
98         */adm_local/*) return ;;
99     *) ;;
100   esac
101
102 # for each regular file contained in the directory
103 # test if it's a .in file
104
105   for i in "$1"/*
106   do
107      if [ -f "$i" ] ; then
108        case $i in 
109          *.in) echo "   "$i" \\" >> $f;;
110          *) ;;
111         esac
112      fi
113   done
114
115 # for each subdirectory of the first argument, proceeds recursively
116
117   for i in "$1"/*
118   do
119      if [ -d "$i" ] ; then
120         find_in "$i" "$f"
121      fi
122   done
123 }
124
125
126 #######################################################################
127 # Generate list of .in files (Makefile.in, config.h.in, etc)
128 # appending it in file configure.in
129
130 cd ${CONF_DIR}
131 ABS_CONF_DIR=`pwd`
132
133 #
134 # Common part of the configure.in file
135 #
136 chmod u+w configure.in.base
137 if ! \cp -f configure.in.base configure.in_tmp1 
138 then
139         echo
140         echo "error : can't create files in" ${CONF_DIR}
141         echo "aborting ..."
142         chmod u-w configure.in.base 
143         exit
144 fi
145 chmod u-w configure.in.base 
146
147 if [ -e "${CONF_DIR}/salome_adm" ] ; then
148     \rm -f ${CONF_DIR}/salome_adm
149 fi
150
151 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
152 echo "" >> configure.in_tmp1
153 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}/.' >> configure.in_tmp1
154
155 echo  "" >> configure.in_tmp1
156 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
157
158 #
159 # List of .in files in the adm/unix directory
160 # These files MUST be on top of AC_OUTPUT list so we
161 # put them "manually"
162 #
163
164 echo "  ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
165 echo "  ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
166 echo "  ./salome_adm/unix/sstream \\" >> configure.in_tmp1
167 echo "  ./salome_adm/unix/depend \\" >> configure.in_tmp1
168 echo "  ./adm_local/unix/make_omniorb:${ABS_CONF_DIR}/adm_local/unix/make_omniorb.in \\" >> configure.in_tmp1
169 echo "  ./salome_adm/unix/envScript \\" >> configure.in_tmp1
170 echo "  ./adm_local/unix/make_commence:${ABS_CONF_DIR}/adm_local/unix/make_commence.in \\" >> configure.in_tmp1
171 echo "  ./adm_local/unix/make_conclude:${ABS_CONF_DIR}/adm_local/unix/make_conclude.in \\" >> configure.in_tmp1
172 echo "  ./salome_adm/unix/make_module \\" >> configure.in_tmp1
173
174 \rm -f configure.in_tmp2 configure.in_tmp3
175 touch configure.in_tmp2
176 find_in . configure.in_tmp2
177 sed -e '/^...salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
178 sed -e '/^...adm_local.unix.make_omniorb/d' configure.in_tmp3 > configure.in_tmp2
179 sed -e '/^...adm_local.unix.make_commence/d' configure.in_tmp2 > configure.in_tmp3
180 sed -e '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
181 sed -e 's/.in / /' configure.in_tmp2 >>  configure.in_tmp1
182 #sed '/^.salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
183 #sed '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
184 #sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
185
186 echo  "])" >> configure.in_tmp1
187
188 # delete the link created for AC_OUTPUT
189 echo "" >> configure.in_tmp1
190 #echo 'rm -f ${ROOT_SRCDIR}/salome_adm' >> configure.in_tmp1
191 \mv configure.in_tmp1 configure.in_new
192 \rm  -f configure.in_tmp2 configure.in_tmp3
193
194
195 ########################################################################
196 # Create new (or replace old) configure.in file
197 # Print a message if the file is write protected
198 #
199
200 echo
201 if test ! -f configure.in
202 then
203         echo -n "Creating new file 'configure.in' ... "
204         if \mv configure.in_new configure.in >& /dev/null
205         then
206                 echo "done"
207         else
208                 echo "error, check your file permissions"
209         fi
210 else
211         echo -n "Updating 'configure.in' file ... "
212         if ! \cp configure.in configure.in_old >& /dev/null
213         then
214                 echo
215                 echo
216                 echo "Can't backup previous configure.in"
217                 echo -n "Continue (you will not be able to revert) - (Y/N) ? "
218                 read R
219                 case "x$R" in
220                     xn*) exit;;
221                     xN*) exit;;
222                 esac
223                 echo
224                 echo -n "                                 "
225         fi
226         if \cp configure.in_new configure.in >& /dev/null
227         then
228                 echo "done"
229         else
230                 echo
231                 echo "error, can't update previous configure.in"
232         fi
233 fi
234
235 ########################################################################
236 # Use autoconf to rebuild the configure script
237 #
238
239 if test -f configure
240 then
241         echo -n "Updating 'configure' script ...  "
242 else
243         echo -n "Creating 'configure' script ...  "
244 fi
245
246 if test ${SMESH_WITH_GUI} = yes; then
247 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
248                                        -I ${GUI_ROOT_DIR}/adm_local/unix/config_files \
249                                        -I ${MED_ROOT_DIR}/adm_local/unix/config_files \
250                                        -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files
251 fi
252
253 if test ${SMESH_WITH_GUI} = no; then
254 aclocal -I adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files \
255                                        -I ${MED_ROOT_DIR}/adm_local/unix/config_files \
256                                        -I ${GEOM_ROOT_DIR}/adm_local/unix/config_files
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