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