cake
/
libg1m
Archived
1
0
Fork 0
This repository has been archived on 2024-03-16. You can view files and clone it, but cannot push or open issues or pull requests.
libg1m/tools/write-header-config

56 lines
1.6 KiB
Plaintext
Raw Normal View History

2017-01-27 21:49:04 +01:00
#!/bin/sh
#******************************************************************************#
# Arguments #
#******************************************************************************#
# Initialize the variables
no_file=
2017-02-19 23:31:46 +01:00
version=
2017-01-27 21:49:04 +01:00
# Read the arguments
for arg ; do case "$arg" in
--no-file) no_file=y ;;
2017-02-19 23:31:46 +01:00
--version=*) version="${arg#*=}" ;;
2017-01-27 21:49:04 +01:00
*) echo "'${arg}': Did not read." ;;
esac; done
2017-02-19 23:31:46 +01:00
# Make version as numbers
vnum=$(echo ${version} | cut -d- -f1)
version_major=$(( $(echo ${vnum} | cut -d. -f1) ))
version_minor=$(( $(echo ${vnum} | cut -s -d. -f2) ))
version_rev=$(( $(echo ${vnum} | cut -s -d. -f3) ))
version_indev=$(echo ${version} | cut -s -d- -f2)
version_indev=$([ ${version_indev} ] && echo 1 || echo 0)
# Constitute version thingies
version_num=$(printf "0x%02X%02X%04X" \
${version_major} ${version_minor} ${version_rev})
2017-01-27 21:49:04 +01:00
#******************************************************************************#
# Write the file #
#******************************************************************************#
2017-02-19 23:31:46 +01:00
# Beginning
2017-01-27 21:49:04 +01:00
cat <<_EOF
#ifndef LIBG1M_CONFIG_H
# define LIBG1M_CONFIG_H
2017-02-19 23:31:46 +01:00
# define LIBG1M_VERSION "${version}"
# define LIBG1M_VERNUM ${version_num}
# define LIBG1M_MAJOR ${version_major}
# define LIBG1M_MINOR ${version_minor}
# define LIBG1M_REV ${version_rev}
# define LIBG1M_INDEV ${version_indev}
_EOF
2017-01-27 21:49:04 +01:00
2017-02-19 23:31:46 +01:00
# File part
if [ "$no_file" ]; then cat <<_EOF
/* FILE interface is disabled */
# define G1M_DISABLED_FILE 1
2017-01-27 21:49:04 +01:00
2017-02-19 23:31:46 +01:00
_EOF
fi
# End of the file
cat <<_EOF
2017-01-27 21:49:04 +01:00
#endif /* LIBG1M_CONFIG_H */
_EOF