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