]> rtime.felk.cvut.cz Git - omk.git/commitdiff
cmetric: Fixed for shells without "set -o pipefail" (dash)
authorMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Sep 2009 13:41:31 +0000 (15:41 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Fri, 25 Sep 2009 13:42:18 +0000 (15:42 +0200)
snippets/gcc.omk
snippets/linux.omk
tests/cmetric/runtest

index f438cfd9de558a72fe359becdd3fdc35272dce2a..89dc45d7d860525a5b80e397b1186702130b581b 100644 (file)
@@ -125,15 +125,18 @@ $(2): $(1)
        $(Q)if [ -n `dirname $$@` ] ; then \
              if [ ! -e `dirname $$@` ] ; then \
                mkdir -p `dirname $$@` ; fi ; fi
-       $(Q)echo >$$@ '/* Automatically generated from $$< */'
-       $(Q)echo >>$$@ '/* Conditionals to control compilation */'
-       $(Q)set -o pipefail ; $(NM) $$< \
+       $(Q)echo >$$@.tmp '/* Automatically generated from $$< */'
+       $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */'
+# Bellow, the tricks with redirection are for shells without set -o pipefail
+# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html)
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
-       $(Q)echo >>$$@ '/* Defines from the values defined to symbols */'
-       $(Q)set -o pipefail ; $(NM) $$< \
+               | sort >>$$@.tmp` && exit $$$$status
+       $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@
+               | sort >>$$@.tmp` && exit $$$$status
+       $(Q)mv $$@.tmp $$@
 endef
 
 # Syntax: $(call PROGRAM_template,<executable-name>,<dir>,<link-variant>)
index f45e230267684ec6a6c2bb859544a00909b7a81e..ac3d7c031cf3ae9b8c496780f021417670421ad8 100644 (file)
@@ -241,14 +241,15 @@ $(2): $(1)
                mkdir -p `dirname $$@` ; fi ; fi
        $(Q)echo >$$@.tmp '/* Automatically generated from $$< */'
        $(Q)echo >>$$@.tmp '/* Conditionals to control compilation */'
-
-       $(Q)set -o pipefail ; $(NM) $$< \
+# Bellow, the tricks with redirection are for shells without set -o pipefail
+# (see http://www.mail-archive.com/dash@vger.kernel.org/msg00149.html)
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2cond_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@.tmp
+               | sort >>$$@.tmp` && exit $$$$status
        $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
-       $(Q)set -o pipefail ; $(NM) $$< \
+       $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) $$<; echo $$$$? >&4; }\
                | sed -n 's/^ *0*\(0[0-9A-Fa-f]*\) *A *_cmetric2def_\([A-Za-z_0-9]*\) */#define \2 0x\1/p' \
-               | sort >>$$@.tmp
+               | sort >>$$@.tmp` && exit $$$$status
        $(Q)mv $$@.tmp $$@
 endef
 
index 7222982d58c2503a30db46db5c4fac497ab519e4..69a9e9ca78d4ba5ecbb46791c2b3aa295811b84f 100755 (executable)
@@ -3,6 +3,7 @@
 . ../functions.sh
 
 touch config.omk-default
+make NM=false && error "cmetric error was not correctly detected"
 make || error "compilation error"
 cmp correct_cmetric_config.h _compiled/include/test/cmetric_config.h || \
     error "produced file differs"