#! /bin/bash # Takes a config file and generates the corresponding ".h" header file. if [ $# -lt 3 ] then echo "Usage: $0 input_config_file output_header_file header_guard" exit 1 fi # The input config file config="$1" # The path and name of the output header file. header="$2" # The name of the macro to use as a guard for the output header file. guard="$3" echo \ "#ifndef ${guard} #define ${guard} " > "${header}" sed -r \ -e "/^#/d" \ -e "s/^CONFIG_(.*)=y/#define CONFIG_\1 1/" \ -e "/^CONFIG_(.*)=n/d" \ -e "s/^CONFIG_(.*)=(.*)/#define CONFIG_\1 \2/" \ "${config}" >> "${header}" echo " #endif /* ${guard} */" >> ${header}