See for_cmetric_config.c file for usage details.
Thanks to Pavel Němeček for implementation.
$(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` && exit $$$$status
- $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
$(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` && exit $$$$status
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+ $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+ | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+ | sort >>$$@.tmp` && exit $$$$status
$(Q)mv $$@.tmp $$@
endef
fi
endef
+NM ?= nm
# Syntax: $(call CMETRIC_o_h_template,<object_file>,<target_header>)
define CMETRIC_o_h_template
$(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` && exit $$$$status
- $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols */'
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in hexadecimal format */'
$(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` && exit $$$$status
+ $(Q)echo >>$$@.tmp '/* Defines from the values defined to symbols in decimal format */'
+ $(Q)exec 3>&1; status=`exec 4>&1 >&3; { $(NM) -td $$<; echo $$$$? >&4; }\
+ | sed -n 's/^ *0*\(0\|[1-9][0-9]*\) *A *_cmetric2defdec_\([A-Za-z_0-9]*\) */#define \2 \1/p' \
+ | sort >>$$@.tmp` && exit $$$$status
$(Q)mv $$@.tmp $$@
endef
/* Automatically generated from for_cmetric_config.o */
/* Conditionals to control compilation */
-/* Defines from the values defined to symbols */
+/* Defines from the values defined to symbols in hexadecimal format */
#define FLAG_BAR_b 0x01
#define FLAG_BAR_m 0x02
#define FLAG_FOO_b 0x0
#define s_blah_field1 0x04
#define s_blah_field2 0x01
#define s_blah_flags 0x04
+#define VALUE_HEX 0x07b
+/* Defines from the values defined to symbols in decimal format */
+#define VALUE_DEC_ZERO 0
+#define VALUE_DEC 123
#define VALUE2ASM(value_name,value) \
NUM2ASM(_cmetric2def_##value_name,value)
+#define DEC_VALUE2ASM(value_name,value) \
+ NUM2ASM(_cmetric2defdec_##value_name,value)
void pxmc_public2asm(void)
{
VALUE2ASM(CMETRIC_TEST_OPTION6,1);
#endif
+VALUE2ASM(VALUE_HEX, 123);
+DEC_VALUE2ASM(VALUE_DEC, 123);
+DEC_VALUE2ASM(VALUE_DEC_ZERO, 0);
+
MASKBIT2ASM(FLAG_FOO);
MASKBIT2ASM(FLAG_BAR);