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