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