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