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