Index: unk/make2deps.sh
===================================================================
--- /trunk/make2deps.sh	(revision 4)
+++ 	(revision )
@@ -1,443 +1,0 @@
-#! /bin/sh
-#
-# module :
-# generation of a .deps file for snakefood-graph from a makefile
-#
-# ++ pas de regles implicites
-# ++ ce n'est pas parce que cet outils reprend les dependances du
-# makefile que le schema produit reflète ce qui effectivement fait
-# car si les regles n'utilisent pas toutes les dépendances voires
-# d'autres fichiers ... on est dans les chous
-#
-# ++ doc
-# $ make2deps.sh -i ../doc/makefile -o schema.deps
-# $ sfood-graph schema.deps > docperso_schema.dot
-#
-# update :
-# ambiguite entre repertoire/fichier et librairie/module
-# comme par exemple dans les lignes suivantes
-# $(MODEL_LIB)/%.o : %.f
-# $(MODEL_LIB)/in_out_manager.o
-# ++ remplacer les macros par leurs valeurs
-# ++ pas encore ok pour les formes
-# VAR2 = $(VAR1) si VAR1 est une variable d'environnement
-# P_P =  $(P_P:%=$(prefix)%)
-# ++ surtout sensibles si les macros en question sont des
-# dependances et que ces dépendances sont multiples (cf fiche demande projets dans
-# /usr/home/incas/fiches-projets/src_xml/2007/synthese/makefile DOCUMEMENT_F2007
-# incas/
-# ++ les macros forme VAR := $(shell ...)
-
-# $Id$
-# fplod 2007-11-16T10:39:52Z aedon.locean-ipsl.upmc.fr (Darwin)
-# less technical replacement of macro but more easily debugable !
-# sed files in tmp instead of current directory
-# add -f to force overriding of existing output file
-# fplod 2007-05-25T08:30:36Z aedon.locean-ipsl.upmc.fr (Darwin)
-# filter les directives m4 ++ c'est pas forcément très rusé mais je ne sais
-# pas quoi en faire pour l'instant
-# fplod 2007-05-24T09:17:32Z aedon.locean-ipsl.upmc.fr (Darwin)
-# creation
-# inspired by
-# http://sed.sourceforge.net/grabbag/tutorials/do_it_with_sed.txt
-#
-set -o posix
-command=$(basename ${0} .sh)
-log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
-log=/tmp/${command}.log_${log_date}
-#
-usage=" Usage : ${command}.sh -i makefile -o depsfile [-f]"
-#
-# default
-force=0
-#
-minargcount=4
-#echo " narg ${#}"
-if [ ${#} -lt ${minargcount} ]
-then
-  echo "eee : not enought arguments"
-  echo "${usage}"
-  exit 1
-fi
-#
-while [ ! -z "${1}" ] # ++ pb bash
-do
- case ${1} in
- -i)
-  makefile=${2}
-  shift
- ;;
- -o)
-  depsfile=${2}
-  shift
- ;;
- -f)
-  force=1
- ;;
- *) # other choice
-  echo "${usage}"
-  exit 1
- ;;
- esac
- shift # next flag
-done
-#
-set -u
-#
-# check for makefile
-if [ ! -f ${makefile} ]
-then
-  echo "eee : ${makefile} not found"
-  exit 1
-fi
-#
-set -u
-#
-# check for makefile
-if [ ! -f ${makefile} ]
-then
-  echo "eee : ${makefile} not found"
-  exit 1
-fi
-#
-# check for depsfile
-if [ -f ${depsfile} ]
-then
-  if [ ${force} -eq 0 ]
-  then
-    echo "eee : ${depsfile} found"
-    exit 1
-  else
-    echo "iii : existing ${depsfile} move to ${depsfile}_$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
-    mv ${depsfile} ${depsfile}_$(date -u +"%Y-%m-%dT%H:%M:%SZ")
-  fi
-fi
-#++ droit d'écriture
-#
-if [ ! -w $(dirname  ${depsfile}) ]
-then
-  echo "eee : pb for writing in directory of  ${depsfile}"
-  exit 1
-fi
-#
-# temporary files definition
-tmp1=/tmp/${command}.tmp1_${log_date}
-/bin/rm -f ${tmp1} 2> /dev/null
-tmp2=/tmp/${command}.tmp2_${log_date}
-/bin/rm -f ${tmp2} 2> /dev/null
-#
-# Look for strange patterns in makefile
-grep -q "^ *"  ${makefile}
-grep_status=${?}
-if [ ${grep_status} -eq 1 ]
-then
- echo "www : there is some line(s) beginning with blank in ${makefile}"
-fi
-#
-cp ${makefile} ${tmp1}_b
-#
-# following sed commands may seem to be a bit heavy but like this
-# it will be easier to debug, to parametrize and to complete ...
-#
-# remove blank lines
-cmd_sed="/^$/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-status=${?}
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"remove blank lines\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# remove all comments
-cmd_sed="/^#/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"remove all comments\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# join all lines ended with `\', after deleting the `\' it self
-#++ cmd_sed=${cmd_sed}":b;/\\$/{;N;s/\n//;bb;};"
-# ça ne fonctionne pas en ligne de commande ... unused label
-# je le met dans un fichier /tmp/join${$}.sed en attendant
-# nb ici à cause du cat je dois mettre deux \ en plus
-cat << EOF > /tmp/join${$}.sed
-:n
-/\\\\$/{
-        N
-        s/\\\\\n//
-        bn
-}
-EOF
-#echo "commande : sed -f /tmp/join${$}.sed "
-sed -f /tmp/join${$}.sed ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"join lines\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# remove lines beginning with TAB (should be rules but ++ can be others
-# so that we join lines ending with \ before)
-cmd_sed="/^	/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"remove lines with TAB\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# replace ":=" by "="
-cmd_sed="s/ :=/ = /"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"replacing := by =\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# replace TAB by blank (TABs in rules have been already removed. see below)
-cmd_sed="s/	/ /g"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"replacing TAB with blank\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# finding macro definition
-grep "=" ${tmp1}_b > /tmp/macro_def${$}
-if [ -s /tmp/macro_def${$} ]
-then
-#
-   macro_value=1
-   while [ ${macro_value} -eq 1 ]
-   do
-    nbl=$(wc -l /tmp/macro_def${$} | awk '{print $1}')
-    il=1
-    while [ ${il} -le ${nbl} ]
-    do
-     ll=$(sed -ne "${il},${il}p" /tmp/macro_def${$} )
-     # loop on macro definition
-     macro=$(echo ${ll} | awk -F "=" '{print $1}' | sed -e "s/ //g")
-     value=$(echo ${ll} | awk -F "=" '{print $2}' | sed -e "s/ //g")
-     commande_sed="s=\\\$(${macro})=${value}=g"
-     echo "${commande_sed}" >> /tmp/macro${$}.sed
-     il=` expr ${il} + 1`
-    done
-    sed -f /tmp/macro${$}.sed /tmp/macro_def${$} > /tmp/macro_def${$}_2
-    mv /tmp/macro_def${$}_2 /tmp/macro_def${$}
-    # je fais une liste de variables d'environnement qui peuvent apparaitre
-    # et dont par définition je ne connais pas la valeur qu'elles peuvent prendre
-    # au moment du run
-    list_envar="LOGNAME HOME PWD"
-    cp /tmp/macro_def${$} /tmp/macro_value_t${$}
-    for envar in ${list_envar}
-    do
-      sed -e "/\$(${envar})/d" /tmp/macro_value_t${$} > /tmp/macro_value_t${$}_1
-      mv /tmp/macro_value_t${$}_1 /tmp/macro_value_t${$}
-    done
-    grep -q ".* = .*\$(.*).*"  /tmp/macro_value_t${$}
-    grep_status=${?}
-    if [ ${grep_status} -eq 0 ]
-    then
-      macro_value=1
-    else
-      macro_value=0
-    fi
-    rm /tmp/macro${$}.sed 2> /dev/null
-    rm /tmp/macro_value_t${$}  2> /dev/null
-   done
-   #
-   # here /tmp/macro_def${$} contains lines of this form
-   # MACRO = value
-   # and no line of this form
-   # MACRO2 = $(MACRO1)/VAL
-   #echo "/tmp/macro_def${$} sans macro value"
-   #
-   # assign macro values
-   nbl=$(wc -l /tmp/macro_def${$} | awk '{print $1}')
-   il=1
-   while [ ${il} -le ${nbl} ]
-   do
-    ll=$(sed -ne "${il},${il}p" /tmp/macro_def${$} )
-    #echo "${il} : ${ll}"
-    # loop on macro definition
-    macro=$(echo ${ll} | awk -F "=" '{print $1}' | sed -e "s/ //g")
-    value=$(echo ${ll} | awk -F "=" '{print $2}' | sed -e "s/ //g")
-    commande_l=$( echo ${macro})=\"${value}\"
-    #++eval ${commande_l}
-    commande_sed="s=\\\$(${macro})=${value}=g"
-    echo "${commande_sed}" >> /tmp/macro${$}.sed
-    il=` expr ${il} + 1`
-   done
-   #
-   rm /tmp/macro_def${$} 2> /dev/null
-   #echo "/tmp/macro${$}.sed"
-   # replace macro by there value
-   #echo "commande : sed -f /tmp/macro${$}.sed "
-   sed -f /tmp/macro${$}.sed ${tmp1}_b > ${tmp1}_c
-   if [ ${status} -ne 0 ]
-   then
-      echo "eee : pb with sed command \"replacing macro by their value\""
-      exit 1
-   fi
-   mv ${tmp1}_c ${tmp1}_b
-fi
-# remove macro lines
-cmd_sed="/=/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing macro definition\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line beginning with ifeq
-cmd_sed="/^ifeq/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with ifeq\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line beginning with ifneq
-cmd_sed="/^ifneq/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with ifneq\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line beginning with else
-cmd_sed="/^else/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with else\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line beginning with endif
-cmd_sed="/^endif/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with endif\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line containing .PRECIOUS
-# ++ mais on pourrait les mettre en valeurs
-cmd_sed="/^.PRECIOUS/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with .PRECIOUS\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove line containing .SUFFIXES
-# ++ mais on pourrait les mettre en valeurs
-cmd_sed="/^.SUFFIXES/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing lines with .SUFFIXES\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-# remove lines ending by : ie target without dependance
-cmd_sed="/:$/d"
-#echo "commande : sed -e \"${cmd_sed}\""
-sed -e "${cmd_sed}" ${tmp1}_b > ${tmp1}_c
-if [ ${status} -ne 0 ]
-then
-   echo "eee : pb with sed command \"removing target without dependencies\""
-   exit 1
-fi
-mv ${tmp1}_c ${tmp1}_b
-#
-# end of makefile manipulation
-mv ${tmp1}_b ${tmp1}
-#
-grep -q "\#\#" ${tmp1} > /dev/null
-grep_status=${?}
-if [ ${grep_status} -eq 0 ]
-then
- echo "www : some problem in macro replacement" 2>> ${log}
- echo "www : $(grep "\#\#" ${tmp1})" 2>> ${log}
-fi
-#
-# loop one each line of the form
-# target : source1 source2 ... sourcen
-# to have
-# target : source1
-# target : source2
-# target : ...
-# target : sourcen
-il=1
-nbl=$(wc -l ${tmp1} | awk '{print $1}')
-while [ ${il} -le ${nbl} ]
-do
- ll=$(sed -ne "${il},${il}p" ${tmp1})
- #echo "${il} : ${ll}"
- # loop on dependencies
- deps=$(echo ${ll} | awk -F ':' '{print $2}')
- target=$(echo ${ll} | awk -F ':' '{print $1}')
- for dep in ${deps}
- do
-  dtarget=$(dirname ${target})
-  dirname_status=${?}
-  if [ ${dirname_status} -ne 0 ]
-  then
-    echo "eee : pb with dirname target on line ${il}"
-    echo "eee : ${ll}"
-    # ++ ne pas traiter cette ligne  ou sortir
-  fi
-  ftarget=$(basename ${target})
-  basename_status=${?}
-  if [ ${basename_status} -ne 0 ]
-  then
-    echo "eee : pb with basename target on line ${il}"
-    echo "eee : ${ll}"
-    # ++ ne pas traiter cette ligne  ou sortir
-  fi
-  ddep=$(dirname ${dep})
-  fdep=$(basename ${dep})
-  echo "(('${ddep}','${fdep}'),('${dtarget}','${ftarget}'))" >> ${tmp2}
-  #echo "(('${ddep}','${fdep}'),('${dtarget}','${ftarget}'))"
- done
- il=` expr ${il} + 1`
-done
-cp ${tmp2} ${depsfile}
-#
-# cleaning
-/bin/rm /tmp/macro${$}.sed 2> /dev/null
-/bin/rm /tmp/join${$}.sed 2> /dev/null
-/bin/rm -f ${tmp1} 2> /dev/null
-/bin/rm -f ${tmp2} 2> /dev/null
-#
-exit 0
Index: unk/makefile
===================================================================
--- /trunk/makefile	(revision 4)
+++ 	(revision )
@@ -1,146 +1,0 @@
-# module :
-# makefile of schema project
-#
-# update :
-# $Id$
-# fplod 2007-11-16T16:14:11Z cerbere.locean-ipsl.upmc.fr (Linux)
-# ajout des test primaires de make2deps.sh
-# fplod 2007-05-25T08:16:17Z aedon.locean-ipsl.upmc.fr (Darwin)
-# creation
-#
-PRODUCT = \
-schema
-
-DIRTMP = \
-/tmp/
-
-clean :
-	/bin/rm $(DIRTMP)/tp1.deps*
-	/bin/rm $(DIRTMP)/tp2.deps*
-	/bin/rm $(DIRTMP)/tp3.deps*
-	/bin/rm $(DIRTMP)/tp4.deps*
-	/bin/rm $(DIRTMP)/tp5.deps*
-	/bin/rm $(DIRTMP)/tp6.deps*
-	/bin/rm $(DIRTMP)/tp7.deps*
-	/bin/rm $(DIRTMP)/$(PRODUCT).deps
-	/bin/rm $(DIRTMP)/$(PRODUCT).png
-	/bin/rm $(DIRTMP)/$(PRODUCT).dot
-	/bin/rm $(DIRTMP)/ORCA2_LIM.deps
-	/bin/rm $(DIRTMP)/ECHAM.deps
-
-update_ref :
-	cp -i $(DIRTMP)/tp1.deps ./data/
-	cp -i $(DIRTMP)/tp2.deps ./data/
-	cp -i $(DIRTMP)/tp3.deps ./data/
-	cp -i $(DIRTMP)/tp4.deps ./data/
-	cp -i $(DIRTMP)/tp5.deps ./data/
-	cp -i $(DIRTMP)/tp6.deps ./data/
-	cp -i $(DIRTMP)/tp7.deps ./data/
-	cp -i $(DIRTMP)/$(PRODUCT).deps ./data/
-	cp -i $(DIRTMP)/$(PRODUCT).png ./data/
-	cp -i $(DIRTMP)/$(PRODUCT).dot ./data/
-	cp -i $(DIRTMP)/ORCA2_LIM.deps ./data/
-	cp -i $(DIRTMP)/ECHAM.deps ./data/
-
-test : \
-test_make2deps \
-$(DIRTMP)/$(PRODUCT).png
-
-test_ORCA2_LIM : \
-ORCA2_LIM_dot.png \
-ORCA2_LIM_neato.png \
-ORCA2_LIM_circo.png
-
-test_ECHAM : \
-ECHAM_dot.png \
-ECHAM_neato.png \
-ECHAM_circo.png
-
-test_make2deps : \
-$(DIRTMP)/tp1.deps \
-$(DIRTMP)/tp2.deps \
-$(DIRTMP)/tp3.deps \
-$(DIRTMP)/tp4.deps \
-$(DIRTMP)/tp5.deps \
-$(DIRTMP)/tp6.deps \
-$(DIRTMP)/tp7.deps
-
-$(DIRTMP)/tp1.deps : \
-./data/makefile_tp1
-	@make2deps.sh -i data/makefile_tp1 -o $@ -f
-
-$(DIRTMP)/tp2.deps : \
-./data/makefile_tp2
-	@make2deps.sh -i data/makefile_tp2 -o $@ -f
-
-$(DIRTMP)/tp3.deps : \
-./data/makefile_tp3
-	@make2deps.sh -i data/makefile_tp3 -o $@ -f
-
-$(DIRTMP)/tp4.deps : \
-./data/makefile_tp4
-	@make2deps.sh -i data/makefile_tp4 -o $@ -f
-
-$(DIRTMP)/tp5.deps : \
-./data/makefile_tp5
-	@make2deps.sh -i ./data/makefile_tp5 -o $@ -f
-
-$(DIRTMP)/tp6.deps : \
-./data/makefile_tp6
-	@make2deps.sh -i ./data/makefile_tp6 -o $@ -f
-
-$(DIRTMP)/tp7.deps : \
-./data/makefile_tp7
-	@make2deps.sh -i ./data/makefile_tp7 -o $@ -f
-
-$(DIRTMP)/$(PRODUCT).png : \
-$(DIRTMP)/$(PRODUCT).dot
-	@dot -Tpng -o $@ $(DIRTMP)/$(PRODUCT).dot
-
-$(DIRTMP)/$(PRODUCT).dot : \
-$(DIRTMP)/$(PRODUCT).deps
-	sfood-graph $(DIRTMP)/$(PRODUCT).deps > $@
-
-$(DIRTMP)/$(PRODUCT).deps : \
-./makefile
-	@make2deps.sh -i ./makefile -o $@ -f
-
-ORCA2_LIM_dot.png : \
-ORCA2_LIM.dot
-	@dot -Tpng -o $@ ORCA2_LIM.dot
-
-ORCA2_LIM_neato.png : \
-ORCA2_LIM.dot
-	@neato -Tpng -o $@ ORCA2_LIM.dot
-
-ORCA2_LIM_circo.png : \
-ORCA2_LIM.dot
-	@circo -Tpng -o $@ ORCA2_LIM.dot
-
-ORCA2_LIM.dot : \
-$(DIRTMP)/ORCA2_LIM.deps
-	sfood-graph $(DIRTMP)/ORCA2_LIM.deps > $@
-
-$(DIRTMP)/ORCA2_LIM.deps : \
-./data/Makefile_ORCA2_LIM
-	@make2deps.sh -i ./data/Makefile_ORCA2_LIM -o $@
-
-ECHAM_dot.png : \
-ECHAM.dot
-	@dot -Tpng -o $@ ECHAM.dot
-
-ECHAM_neato.png : \
-ECHAM.dot
-	neato -Tpng -o $@ ECHAM.dot
-
-ECHAM_circo.png : \
-ECHAM.dot
-	circo -Tpng -o $@ ECHAM.dot
-
-ECHAM.dot : \
-$(DIRTMP)/ECHAM.deps
-	sfood-graph $(DIRTMP)/ECHAM.deps > $@
-
-$(DIRTMP)/ECHAM.deps : \
-./data/Makefile_ECHAM
-	@make2deps.sh -i ./data/Makefile_ECHAM -o $@
