Index: CMT/HEAD/ChangeLog
===================================================================
--- CMT/HEAD/ChangeLog	(revision 473)
+++ CMT/HEAD/ChangeLog	(revision 474)
@@ -1,2 +1,29 @@
+2008-11-18    <rybkin@lal.in2p3.fr> 375
+	
+	* source/cmt_generator.h: Introduce function CmtGenerator::fill_names_outputs
+	in order to fill the Make LINE macro taking in account the constituent
+	-k=regexp, -x=regexp options
+	* source/cmt_generator.cxx: Implement the CmtGenerator::fill_names_outputs
+	function
+	* source/cmt_generators.cxx: Make use of the CmtGenerator::fill_names_outputs
+	function to fill m_LINE. In function DependencyGenerator::build, allow for
+	the options specification Windows style (/option[:value]) as the Windows
+	command shell may not pass on -option=value with the = character
+	* mgr/fragments/dependencies: Restore passing the arguments on to the
+	$(build_dependencies) command (via $(LINE)) to allow for external tool use
+	* mgr/fragments/nmake/dependencies: idem, use the -out:file option (rather
+	than -out=file)
+	* mgr/cmt_build_deps.sh: Add and implement options -no_stamps (creating
+	stamps if not specified), -out=<dependencies file>.
+	Use the same preprocessor flags as those used in fragments c, c_library,
+	cpp, cpp_library. Treat the files with non-C or non-C++ extensions as C++
+	files. Allow for the use of macro c_pp to specify the C preprocessor (the
+	tool used by default is cpp -M)
+	* mgr/cmt_filter3_version.sh: Minor correction in the description
+	* mgr/cmt_lsb_system_version.sh: Add script to retrieve the Linux
+	distribution info on LSB conformant systems in the format <distro>-<version>
+	* mgr/cmt_filter1_version.sh: Add script to keep the major version only (in
+	tags)
+	
 2008-11-02    <rybkin@lal.in2p3.fr> 374
 	
Index: CMT/HEAD/mgr/cmt_build_deps.sh
===================================================================
--- CMT/HEAD/mgr/cmt_build_deps.sh	(revision 473)
+++ CMT/HEAD/mgr/cmt_build_deps.sh	(revision 474)
@@ -3,5 +3,5 @@
 #
 # This shell script emulates the behaviour of the 'cmt buid dependencies' operation
-# but using cpp -M instead
+# but using the tool specified by the $(c_pp) macro (or cpp -M) instead
 #
 #===============================================================
@@ -16,18 +16,36 @@
   #  ends with a dependency to the stamp file
 
-  a=`eval cpp -M ${allflags} ${file} | \
+if [ -z "$c_pp" ]; then
+    c_pp="cpp -M"
+fi
+
+  a=`eval ${c_pp} ${allflags} ${file} | \
     sed -e 's#[.]o:#_'"${suffix}"'_dependencies = #' -e 's#[\\]$##'`
 
   if test ! `echo ${a} | wc -w` = "0"; then
-    echo -n ${a}
+    line="`echo ${a}`"
   else
-    echo -n "${file_name}_${suffix}_dependencies = ${file}"
+    line="${file_name}_${suffix}_dependencies = ${file}"
   fi
 
-  echo " \$(bin)${constituent}_deps/${file_name}_${suffix}.stamp"
+if [ "$no_stamps" != yes ]; then
+    stamp_output_base=${constituent}_deps/${file_name}_${suffix}.stamp
+    stamp_output=${bin}${stamp_output_base}
+    line="${line} \$(bin)${stamp_output_base}"
 
   # create or update the stamp file
-
-  touch ${bin}/${constituent}_deps/${file_name}_${suffix}.stamp
+    if [ -f "${stamp_output}" ]; then
+	read old_stamp <${stamp_output}
+	if [ "${line}" != "${old_stamp}" ]; then
+	    /bin/rm -f ${stamp_output}
+	    printf "${line}\n" >${stamp_output}
+	fi
+    else
+	printf "${line}\n" >${stamp_output}
+    fi
+
+  #touch ${bin}/${constituent}_deps/${file_name}_${suffix}.stamp
+fi
+printf "${line}\n"
 }
 
@@ -37,6 +55,6 @@
   name=$1
   shift
-
-  grep "^${name}=" ${tempmacros} | sed -e "s#^${name}=##"
+  sed -n '/^'${name}'=/{s#^'${name}'=##p;q}' ${tempmacros}
+#  grep "^${name}=" ${tempmacros} | sed -e "s#^${name}=##"
 }
 
@@ -60,16 +78,23 @@
 #  Expected arguments:
 #    1    : <constituent name>
-#    2    : -all_sources
+#    2    : [ options: -all_sources | -no_stamps | -out=<dependencies file> ]
 #    3... : <source file list>
 #
 #------------------------------------------------------------------------------------------
 
+[ $# -gt 0 ] || exit
 constituent=$1
 shift
 
-all_sources=$1
-shift
-
-files=$*
+n=0
+for f; do
+    case ${f} in
+	-all_sources) all_sources=yes; n=`expr $n + 1` ;;
+	-no_stamps) no_stamps=yes; n=`expr $n + 1` ;;
+	-out=*) output=`expr "$f" : '-out=\(.*\)'`; n=`expr $n + 1` ;;
+	*) break ;;
+    esac
+done
+shift $n
 
 #---------------
@@ -77,6 +102,6 @@
 #
 tempprefix=/tmp/CMT$$
-if test ! "${TMP}" = ""; then
-  tempprefix=${TMP}/CMT$$
+if test ! "${TMPDIR}" = ""; then
+  tempprefix=${TMPDIR}/CMT$$
 fi
 
@@ -96,15 +121,38 @@
 prepare_context
 
+type=`cmt show constituent ${constituent} | cut -d' ' -f1`
+case "${type}" in
+    application) type=app ;;
+    library) type=lib ;;
+    document) type=doc ;;
+esac
+
 incl=`macro_value includes`
 
 cflags=`macro_value cflags`
+pp_cflags=`macro_value pp_cflags`
+use_pp_cflags=`macro_value use_pp_cflags`
+const_pp_cflags=`macro_value ${constituent}_pp_cflags`
+type_pp_cflags=`macro_value ${type}_${constituent}_pp_cflags`
+use_cflags=`macro_value use_cflags`
 const_cflags=`macro_value ${constituent}_cflags`
-const_pp_cflags=`macro_value ${constituent}_pp_cflags`
+type_const_cflags=`macro_value ${type}_${constituent}_cflags`
 
 cppflags=`macro_value cppflags`
+pp_cppflags=`macro_value pp_cppflags`
+use_pp_cppflags=`macro_value use_pp_cppflags`
+const_pp_cppflags=`macro_value ${constituent}_pp_cppflags`
+type_pp_cppflags=`macro_value ${type}_${constituent}_pp_cppflags`
+use_cppflags=`macro_value use_cppflags`
 const_cppflags=`macro_value ${constituent}_cppflags`
-const_pp_cppflags=`macro_value ${constituent}_pp_cppflags`
-
-bin=`macro_value bin`
+type_const_cppflags=`macro_value ${type}_${constituent}_cppflags`
+
+c_pp=`macro_value c_pp`
+
+if [ "$output" ]; then
+    bin=`dirname $output`/
+elif [ -z "$bin" ]; then
+    bin=`macro_value bin`
+fi
 #--------------
 
@@ -112,5 +160,7 @@
 # Prepare the directory for the stamp files
 #
+if [ "$no_stamps" != yes ]; then
 mkdir -p ${bin}/${constituent}_deps
+fi
 #--------------
 
@@ -118,5 +168,7 @@
 # Prepare the dependency file
 #
+if [ -z "$output" ]; then
 output=${bin}${constituent}_dependencies.make
+fi
 #--------------
 
@@ -124,5 +176,5 @@
 # Loop over source files (if any)
 #
-for f in `echo ${files}`; do
+for f; do
   suffix=`echo ${f} | sed -e 's#.*[.]##'`
   file_name=`basename ${f} .${suffix}`
@@ -130,21 +182,21 @@
   # First remove the old dependency line from the output
 
+if [ "$all_sources" != yes ]; then
   if test -f ${output}; then
-    grep -v "${file_name}_${suffix}_dependencies" ${output} >t$$; mv t$$ ${output}
+    grep -v "${file_name}_${suffix}_dependencies" ${output} >${tempprefix}/t$$
+    mv ${tempprefix}/t$$ ${output}
   fi
-
-  echo "computing dependencies for ${file_name}.${suffix}"
+fi
+#  echo "computing dependencies for ${file_name}.${suffix}"
 
   case ${suffix} in
-    c ) allflags="${incl} ${cflags} ${const_cflags} ${const_cpp_cflags}";;
-    C|cc|cxx|cpp ) allflags="${incl} ${cppflags} ${const_cppflags} ${const_cpp_cppflags}";;
+    c ) allflags="${incl} ${cflags} ${pp_cflags} ${use_pp_cflags} ${const_pp_cflags} ${type_pp_cflags} ${use_cflags} ${const_cflags} ${type_const_cflags}" ;;
+    C|cc|cxx|cpp ) allflags="${incl} ${cppflags} ${pp_cppflags} ${use_pp_cppflags} ${const_pp_cppflags} ${type_pp_cppflags} ${use_cppflags} ${const_cppflags} ${type_const_cppflags}" ;;
+    * ) allflags="-x c++ ${incl} ${cppflags} ${pp_cppflags} ${use_pp_cppflags} ${const_pp_cppflags} ${type_pp_cppflags} ${use_cppflags} ${const_cppflags} ${type_const_cppflags}" ;;
+#    c ) allflags="${incl} ${cflags} ${const_cflags} ${const_cpp_cflags}";;
+#    C|cc|cxx|cpp ) allflags="${incl} ${cppflags} ${const_cppflags} ${const_cpp_cppflags}";;
   esac
-
-  echo "cpp -M ${allflags} ${f}"
 
   compute_dependencies ${f} >>${output}
 done
 #--------------
-
-
-
Index: CMT/HEAD/mgr/cmt_filter1_version.sh
===================================================================
--- CMT/HEAD/mgr/cmt_filter1_version.sh	(revision 474)
+++ CMT/HEAD/mgr/cmt_filter1_version.sh	(revision 474)
@@ -0,0 +1,30 @@
+
+#--------------------------------------------------
+# Procedure to filter system version specifications
+#
+#   Input is received from stdin
+#   Output wll be sent to stdout
+#
+#   Input format
+#    <some letters>[-]<dot separated numeric fields>
+#
+#   Output format
+#    <some letters><field1>
+#
+#   o only the first one numeric field is kept
+#   o separators ('-' or '.') are all filtered out
+#
+#--------------------------------------------------
+
+export LC_ALL=C
+exec sed -n '
+h
+s#[-.0-9]##g
+x
+s#[^-.0-9]##g
+s#^[^0-9]##
+y#-.#  #
+s#^\([0-9]*\) *.*#\1#
+G
+s#\(.*\)\n\(.*\)#\2\1#p
+'
Index: CMT/HEAD/mgr/cmt_filter3_version.sh
===================================================================
--- CMT/HEAD/mgr/cmt_filter3_version.sh	(revision 473)
+++ CMT/HEAD/mgr/cmt_filter3_version.sh	(revision 474)
@@ -12,5 +12,5 @@
 #    <some letters><field1><field2><field3>
 #
-#   o only the first two numeric fields are kept
+#   o only the first three numeric fields are kept
 #   o separators ('-' or '.') are all filtered out
 #
Index: CMT/HEAD/mgr/cmt_lsb_system_version.sh
===================================================================
--- CMT/HEAD/mgr/cmt_lsb_system_version.sh	(revision 474)
+++ CMT/HEAD/mgr/cmt_lsb_system_version.sh	(revision 474)
@@ -0,0 +1,6 @@
+export LC_ALL=C
+lsb_release -d | sed -n '
+s#^.* \{1,\}\([^ ]\{1,\}\) \{1,\}release \{1,\}\([^ ]\{1,\}\) *.*#\1-\2#
+y#ABCDEFGHIJKLMNOPQRSTUVWXYZ#abcdefghijklmnopqrstuvwxyz#
+p
+'
Index: CMT/HEAD/mgr/fragments/dependencies
===================================================================
--- CMT/HEAD/mgr/fragments/dependencies	(revision 473)
+++ CMT/HEAD/mgr/fragments/dependencies	(revision 474)
@@ -7,5 +7,5 @@
 $(bin)${CONSTITUENT}_dependencies.make : ${LINE} $(use_requirements) $(cmt_final_setup_${CONSTITUENT})
 	$(echo) "(${CONSTITUENT}.make) Rebuilding $@"; \
-	  $(build_dependencies) ${CONSTITUENT} -all_sources -out=$@
+	  $(build_dependencies) ${CONSTITUENT} -all_sources -out=$@ ${LINE}
 endif
 
Index: CMT/HEAD/mgr/fragments/nmake/dependencies
===================================================================
--- CMT/HEAD/mgr/fragments/nmake/dependencies	(revision 473)
+++ CMT/HEAD/mgr/fragments/nmake/dependencies	(revision 474)
@@ -4,5 +4,5 @@
 
 !if exist ("$(CMTROOT)/$(CMTBIN)/cmt.exe")
-!if [$(build_dependencies) ${CONSTITUENT} -all_sources -out=$(bin)${CONSTITUENT}_dependencies.nmake] == 0
+!if [$(build_dependencies) ${CONSTITUENT} -all_sources -out:$(bin)${CONSTITUENT}_dependencies.nmake ${LINE}] == 0
 !endif
 !else
Index: CMT/HEAD/source/cmt_generator.cxx
===================================================================
--- CMT/HEAD/source/cmt_generator.cxx	(revision 473)
+++ CMT/HEAD/source/cmt_generator.cxx	(revision 474)
@@ -316,4 +316,42 @@
 
 //--------------------------------------------------
+void CmtGenerator::fill_names_outputs ()
+{
+  bool first = true;
+
+  m_LINE = "";
+  m_OBJS = "";
+
+  for (int i = 0; i < m_source_files.size (); i++)
+    {
+      const SourceFile& file = m_source_files[i];
+      const cmt_string name = file.name ();
+      const cmt_string output = file.output ();
+
+      if (output != "")
+        {
+          if (first)
+            {
+              first = false;
+            }
+          else
+            {
+	      m_LINE += " ";
+              m_OBJS += " ";
+            }
+	  m_LINE += name;
+          m_OBJS += output;
+        }
+
+      if (Cmt::get_debug ())
+        {
+          cout << "CmtGenerator::fill_names_ outputs>" << endl;
+	  cout << "name=" << name << " LINE=" << m_LINE << endl;
+	  cout << "output=" << output << " OBJS=" << m_OBJS << endl;
+        }
+    }
+}
+
+//--------------------------------------------------
 void CmtGenerator::fill_outputs ()
 {
Index: CMT/HEAD/source/cmt_generator.h
===================================================================
--- CMT/HEAD/source/cmt_generator.h	(revision 473)
+++ CMT/HEAD/source/cmt_generator.h	(revision 474)
@@ -56,4 +56,5 @@
   void terminate ();
 
+  void fill_names_outputs ();
   void fill_outputs ();
 
Index: CMT/HEAD/source/cmt_generators.cxx
===================================================================
--- CMT/HEAD/source/cmt_generators.cxx	(revision 473)
+++ CMT/HEAD/source/cmt_generators.cxx	(revision 474)
@@ -351,9 +351,11 @@
   filter_path (m_FILEPATH.value);
 
+  /*
   m_LINE = m_FULLNAME.value;
   m_LINE += " ";
+  */
 
   filter_path (m_FULLNAME.value);
-  filter_path (m_LINE.value);
+  //  filter_path (m_LINE.value);
 
   CmtSystem::get_suffix (name, m_FILESUFFIX.value);
@@ -394,5 +396,6 @@
   if (m_PACKOS9)
     {
-      os9sources += m_LINE;
+      //      os9sources += m_LINE;
+      os9sources += m_FULLNAME.value;
       os9sources += " ";
     }
@@ -464,5 +467,5 @@
   const cmt_vector<cmt_regexp>& selects = constituent.select_exprs;
 
-  m_LINE = "";
+  //  m_LINE = "";
 
   for (i = 0; i < sources.size (); i++)
@@ -496,4 +499,5 @@
         }
 
+      /*
       if (count > 0)
         {
@@ -501,7 +505,9 @@
           m_LINE += " ";
         }
-    }
-
-  fill_outputs ();
+      */
+    }
+
+  fill_names_outputs ();
+  //fill_outputs ();
 
   prepare_use_context ();
@@ -942,5 +948,5 @@
   const cmt_vector<cmt_regexp>& selects = constituent.select_exprs;
 
-  m_LINE = "";
+  //  m_LINE = "";
 
   for (i = 0; i < sources.size (); i++)
@@ -960,4 +966,5 @@
       filter_path (full_name);
 
+      /*
       if (count > 0)
         {
@@ -965,4 +972,5 @@
           m_LINE += " ";
         }
+      */
 
       for (int j = 0; j < files.size (); j++)
@@ -977,5 +985,6 @@
     }
 
-  fill_outputs ();
+  fill_names_outputs ();
+  //  fill_outputs ();
 
   prepare_use_context ();
@@ -2743,19 +2752,24 @@
       // Get rid of files that may come from the makefile fragment
       if (file_name.find ("requirements") != cmt_string::npos) source_number--;
-      else if (file_name.substr (0, 5) == "-out=")
-        {
-          if (!all_sources) source_number--;
+      else if (file_name.substr (0, 5) == "-out=" ||
+	       file_name.substr (0, 5) == "-out:" ||
+	       file_name.substr (0, 5) == "/out:" ||
+	       file_name.substr (0, 5) == "/out=")
+        {
+          source_number--;
 	  file_name.erase (0, 5);
 	  m_output_file_name = file_name;
         }
       else if (file_name.find (".make") != cmt_string::npos) source_number--;
-      else if (file_name == "-all_sources") 
+      else if (file_name == "-all_sources" ||
+	       file_name == "/all_sources") 
         {
           source_number = sources.size ();
           all_sources = true;
         }
-      else if (file_name == "-no_stamps") 
-        {
-          if (!all_sources) source_number--;
+      else if (file_name == "-no_stamps" ||
+	       file_name == "/no_stamps") 
+        {
+          source_number--;
 	  m_stamps = false;
         }
