Salome HOME
573a23bb35af1e8270d77d38ce2ac26d6eaea717
[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 # find_in - utility function
25 #
26 # usage :  
27 #    find_in directory filename 
28 #
29 # Finds files following the *.in pattern, recursively in the
30 # directory (first argument).
31 # Results are appended into the file (second argument)
32 #
33 # Difference from the standard unix find is that files are tested
34 # before directories
35
36
37 find_in()
38 {
39   local i
40   local f=$2
41
42 # if the first argument is not a directory, returns
43
44   if [ ! -d "$1" ] ; then 
45      return 
46   fi
47
48 # dont look in the CVS directories
49
50   case $1 in
51     */CVS) return ;;
52     *) ;;
53   esac
54
55 # for each regular file contained in the directory
56 # test if it's a .in file
57
58   for i in "$1"/*
59   do
60      if [ -f "$i" ] ; then
61        case $i in 
62          *.in) echo $i" \\" >> $f;;
63          *) ;;
64         esac
65      fi
66   done
67
68 # for each subdirectory of the first argument, proceeds recursively
69
70   for i in "$1"/*
71   do
72      if [ -d "$i" ] ; then
73         find_in "$i" "$f"
74      fi
75   done
76 }
77
78
79 #######################################################################
80 # Generate list of .in files (Makefile.in, config.h.in, etc)
81 # appending it in file configure.in
82
83 cd ${CONF_DIR}
84 ABS_CONF_DIR=`pwd`
85
86 #
87 # Common part of the configure.in file
88 #
89 chmod u+w configure.in.base
90 if ! \cp -f configure.in.base configure.in_tmp1 
91 then
92         echo
93         echo "error : can't create files in" ${CONF_DIR}
94         echo "aborting ..."
95         chmod u-w configure.in.base 
96         exit
97 fi
98 chmod u-w configure.in.base 
99
100 if [ -e "${CONF_DIR}/salome_adm" ] ; then
101     \rm -f ${CONF_DIR}/salome_adm
102 fi
103
104 # make a link allowing AC_OUTPUT to find the salome_adm/.../*.in  files
105 echo "" >> configure.in_tmp1
106 echo 'ln -fs ${KERNEL_ROOT_DIR}/salome_adm ${ROOT_SRCDIR}' >> configure.in_tmp1
107
108 echo  "" >> configure.in_tmp1
109 echo "AC_OUTPUT([ \\" >> configure.in_tmp1
110
111 #
112 # List of .in files in the adm/unix directory
113 # These files MUST be on top of AC_OUTPUT list so we
114 # put them "manually"
115 #
116
117 echo "./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
118 echo "./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
119 echo "./salome_adm/unix/sstream \\" >> configure.in_tmp1
120 echo "./salome_adm/unix/depend \\" >> configure.in_tmp1
121 echo "./adm_local/unix/make_omniorb \\" >> configure.in_tmp1
122 echo "./salome_adm/unix/envScript \\" >> configure.in_tmp1
123 echo "./adm_local/unix/make_commence \\" >> configure.in_tmp1
124 echo "./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
125 echo "./salome_adm/unix/make_module \\" >> configure.in_tmp1
126
127 \rm -f configure.in_tmp2
128 touch configure.in_tmp2
129 find_in . configure.in_tmp2
130
131 sed -e '/^.\/salome_adm/d'    \
132     -e '/configure.in/d'      \
133     -e '/^.\/adm_local/d'   \
134     -e 's/.in / /'            \
135     configure.in_tmp2  >>  configure.in_tmp1
136
137 echo  "])" >> configure.in_tmp1
138
139 # delete the link created for AC_OUTPUT
140 echo "" >> configure.in_tmp1
141 \mv configure.in_tmp1 configure.in_new
142 \rm  -f configure.in_tmp2 
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                 \rm  -f configure.in_new
179                 echo "done"
180         else
181                 echo
182                 echo "error, can't update previous configure.in"
183         fi
184 fi
185
186 ########################################################################
187 # Use autoconf to rebuild the configure script
188 #
189
190 if test -f configure
191 then
192         echo -n "Updating 'configure' script ...  "
193 else
194         echo -n "Creating 'configure' script ...  "
195 fi
196
197 aclocal --acdir=adm_local/unix/config_files -I ${KERNEL_ROOT_DIR}/salome_adm/unix/config_files
198 if autoconf
199 then
200         echo "done"
201 else
202         echo "failed (check file permissions and/or user quotas ...)"
203 fi
204
205 cd ${ORIG_DIR}
206
207 echo