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