Salome HOME
CCAR: remove memory leaks in non local SALOMEDS
[modules/kernel.git] / build_configure
index 6f7bd330956f742e1a519d80307a71d63aadf424..53cfcb15a87e91f9a979374b13ab83caeded8001 100755 (executable)
-#!/bin/bash
-
-#
-# Tool for updating list of .in file for the SALOME project 
-# and regenerating configure script
+#!/bin/sh
+#  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
 #
-# Author : Marc Tajchman - CEA
-# Date : 10/10/2002
-# $Header$
+#  Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+#  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 #
-
-ORIG_DIR=`pwd`
-CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
-
-########################################################################
-# find_in - utility function
+#  This library is free software; you can redistribute it and/or
+#  modify it under the terms of the GNU Lesser General Public
+#  License as published by the Free Software Foundation; either
+#  version 2.1 of the License.
 #
-# usage :  
-#    find_in directory filename 
+#  This library is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+#  Lesser General Public License for more details.
 #
-# Finds files following the *.in pattern, recursively in the
-# directory (first argument).
-# Results are appended into the file (second argument)
+#  You should have received a copy of the GNU Lesser General Public
+#  License along with this library; if not, write to the Free Software
+#  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 #
-# Difference from the standard unix find is that files are tested
-# before directories
-# 
-
-find_in()
-{
-  local i
-  local f=$2
-
-# if the first argument is not a directory, returns
-
-  if [ ! -d "$1" ] ; then 
-     return 
-  fi
-
-# dont look in the CVS directories
-
-  case $1 in
-    */CVS) return ;;
-    *) ;;
-  esac
-
-# for each regular file contained in the directory
-# test if it's a .in file
-
-  for i in "$1"/*
-  do
-     if [ -f "$i" ] ; then
-       case $i in 
-         *.in) echo "  "$i" \\" >> $f;;
-         *) ;;
-        esac
-     fi
-  done
-
-# for each subdirectory of the first argument, proceeds recursively
-
-  for i in "$1"/*
-  do
-     if [ -d "$i" ] ; then
-        find_in "$i" "$f"
-     fi
-  done
-}
-
-
-#######################################################################
-# Generate list of .in files (Makefile.in, config.h.in, etc)
-# appending it in file configure.in
-
-cd ${CONF_DIR}
-ABS_CONF_DIR=`pwd`
-
+#  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
-# Common part of the configure.in file
+# ====================================================================
+# This script is just here to illustrate the procedure for preparing
+# the configure process. It creates configuration files (ex:
+# ltmain.sh) using libtoolize, the aclocal macro, the configure script
+# using autoconf and some scripts used in building process (ex:
+# install-sh) using automake. Automake is used here to creates the
+# files Makefile.in from the files Makefile.am.
+# ====================================================================
+# CONF_DIR is the path containing the present script
 #
-chmod u+w configure.in.base
-if ! \cp -f configure.in.base configure.in_tmp1 
-then
-       echo
-       echo "error : can't create files in" ${CONF_DIR}
-       echo "aborting ..."
-        chmod u-w configure.in.base 
-       exit
-fi
-chmod u-w configure.in.base 
-
-#############################################
-echo '' >> configure.in_tmp1
-echo 'export TEMPO=${KERNEL_ROOT_DIR}' >> configure.in_tmp1
-echo 'export KERNEL_ROOT_DIR=${ROOT_SRCDIR}' >> configure.in_tmp1
-#############################################
-
-echo  "" >> configure.in_tmp1
-echo "AC_OUTPUT([ \\" >> configure.in_tmp1
+CONF_DIR=`echo $0 | sed -e "s,[^/]*$,,;s,/$,,;s,^$,.,"`
+cd ${CONF_DIR}
 
+# ____________________________________________________________________
+# aclocal creates the aclocal.m4 file from the standard macro and the
+# custom macro embedded in the directory salome_adm/unix/config_files.
+# output:
+#   aclocal.m4
+#   autom4te.cache (directory)
+echo "====================================================== aclocal"
+
+aclocal -I salome_adm/unix/config_files || exit 1
+
+
+# ____________________________________________________________________
+# libtoolize creates some configuration files (ltmain.sh,
+# config.guess and config.sub). It only depends on the libtool
+# version. The files are created in the directory specified with the
+# AC_CONFIG_AUX_DIR(<mydir>) tag (see configure.ac).
+# output:
+#   salome_adm/unix/config_files/config.guess
+#   salome_adm/unix/config_files/config.sub
+#   salome_adm/unix/config_files/ltmain.sh
+echo "====================================================== libtoolize"
+
+libtoolize --force --copy --automake || exit 1
+
+
+# ____________________________________________________________________
+# autoconf creates the configure script from the file configure.ac (or
+# configure.in if configure.ac doesn't exist)
+# output:
+#   configure
+echo "====================================================== autoconf"
+
+autoconf
+
+# ____________________________________________________________________
+# autoheader creates config.h.in
+# output:
+#   configure
+#echo "====================================================== autoheader"
+
+#autoheader
+
+# ____________________________________________________________________
+# automake creates some scripts used in building process
+# (install-sh, missing, ...). It only depends on the automake
+# version. The files are created in the directory specified with the
+# AC_CONFIG_AUX_DIR(<mydir>) tag (see configure.ac). This step also
+# creates the Makefile.in files from the Makefile.am files.
+# output:
+#   salome_adm/unix/config_files/compile
+#   salome_adm/unix/config_files/depcomp
+#   salome_adm/unix/config_files/install-sh
+#   salome_adm/unix/config_files/missing
+#   salome_adm/unix/config_files/py-compile
+#   Makefile.in (from Makefile.am)
+echo "====================================================== automake"
+
+automake --add-missing --copy --gnu
+
+
+# ____________________________________________________________________
 #
-# List of .in files in the adm/unix directory
-# These files MUST be on top of AC_OUTPUT list so we
-# put them "manually"
-#
-
-echo " ./salome_adm/unix/SALOMEconfig.h \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/F77config.h \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/sstream \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/depend \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/make_omniorb \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/envScript \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/make_commence \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/make_conclude \\" >> configure.in_tmp1
-echo " ./salome_adm/unix/make_module \\" >> configure.in_tmp1
-echo "  ./salome_adm/Makefile \\" >> configure.in_tmp1
-
-\rm -f configure.in_tmp2 configure.in_tmp3
-touch configure.in_tmp2
-find_in . configure.in_tmp2
-sed '/^...salome_adm/d' configure.in_tmp2 >  configure.in_tmp3
-sed '/configure.in/d' configure.in_tmp3 >  configure.in_tmp2
-sed 's/.in / /' configure.in_tmp2 >> configure.in_tmp1
-
-echo  "])" >> configure.in_tmp1
-
-#############################################
-echo 'export KERNEL_ROOT_DIR=${TEMPO}' >> configure.in_tmp1
-#############################################
-
-\mv configure.in_tmp1 configure.in_new
-\rm  -f configure.in_tmp2 configure.in_tmp3
-
-
-########################################################################
-# Create new (or replace old) configure.in file
-# Print a message if the file is write protected
+# Note that automake could be executed at last after autoconf. The
+# order doesn't matter.
 #
-
-echo
-if test ! -f configure.in
-then
-       echo -n "Creating new file 'configure.in' ... "
-       if \mv configure.in_new configure.in >& /dev/null
-       then
-               echo "done"
-       else
-               echo "error, check your file permissions"
-       fi
-else
-       echo -n "Updating 'configure.in' file ... "
-       if ! \cp configure.in configure.in_old >& /dev/null
-       then
-               echo
-               echo
-               echo "Can't backup previous configure.in"
-               echo -n "Continue (you will not be able to revert) - (Y/N) ? "
-               read R
-                case "x$R" in
-                   xn*) exit;;
-                   xN*) exit;;
-               esac
-               echo
-               echo -n "                                 "
-       fi
-       if \cp configure.in_new configure.in >& /dev/null
-       then
-               echo "done"
-       else
-               echo
-               echo "error, can't update previous configure.in"
-       fi
-fi
-
-########################################################################
-# Use autoconf to rebuild the configure script
+# When modifying a Makefile.am file, after a first step of
+# configure+make, you just have to :
+# - go to the top source directory and run automake, to rebuild the Makefile.in,
+# - go to the top build directory and run config.status to rebuild the
+#   Makefile from the Makefile.in,
+# - go to the source directory being modified, and then run make.
 #
-
-if test -f configure
-then
-       echo -n "Updating 'configure' script ...  "
-else
-       echo -n "Creating 'configure' script ...  "
-fi
-
-aclocal --acdir=salome_adm/unix/config_files
-if autoconf
-then
-       echo "done"
-else
-       echo "failed (check file permissions and/or user quotas ...)"
-fi
-
-cd ${ORIG_DIR}
-
-echo