$(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>)
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
. ../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"