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