libp7/tools/write-header-config

60 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
#******************************************************************************#
# Arguments #
#******************************************************************************#
# Initialize the variables
gint=
no_file=
version=
# Read the arguments
for arg ; do case "$arg" in
--gint) gint=y ;;
--no-file) no_file=y ;;
--version=*) version="${arg#*=}" ;;
*) echo "'${arg}': Did not read." ;;
esac; done
# Make version as a number
vnum=$(echo ${version} | cut -d- -f1)
version_major=$(echo ${vnum} | cut -d. -f1)
version_minor=$(echo ${vnum} | cut -d. -f2)
version_num=$(printf "0x%02X%02X0000" ${version_major} ${version_minor})
#******************************************************************************#
# Write the file #
#******************************************************************************#
# Beginning
cat <<_EOF
#ifndef LIBP7_CONFIG_H
# define LIBP7_CONFIG_H
# define LIBP7_VERSION "${version}"
# define LIBP7_VERNUM ${version_num}
# define LIBP7_MAJOR ${version_major}
# define LIBP7_MINOR ${version_minor}
_EOF
# Gint part
if [ "$gint" ]; then cat <<_EOF
/* Gint is enabled */
# ifndef __gint__
# define __gint__
# endif
_EOF
fi
# File part
if [ "$no_file" ]; then cat <<_EOF
/* FILE interface is disabled */
# define P7_DISABLED_FILE 1
_EOF
fi
# End of the file.
cat <<_EOF
#endif /* LIBP7_CONFIG_H */
_EOF