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