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

83 lines
3.0 KiB
Bash
Executable File

#!/bin/sh
#******************************************************************************#
# Arguments #
#******************************************************************************#
# Initialize the variables
no_file=
version=
maintainer='anon <anon@localhost>'
# Read the arguments
for arg ; do case "$arg" in
--no-file) no_file=y ;;
--version=*) version="${arg#*=}" ;;
--maintainer=*) maintainer="${arg#*=}" ;;
*) echo "'${arg}': Did not read." ;;
esac; done
# Make version as numbers
vnum=$(echo ${version} | cut -d- -f1)
version_major=$(printf "%d" "$(echo ${vnum} | cut -d. -f1)")
version_minor=$(printf "%d" "$(echo ${vnum} | cut -s -d. -f2)")
version_rev=$(printf "%d" "$(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}")
#******************************************************************************#
# Write the file #
#******************************************************************************#
# Beginning
cat <<_EOF
/* *****************************************************************************
* libg1m/config.h -- libg1m configuration header.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libg1m.
* libg1m is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 3.0 of the License,
* or (at your option) any later version.
*
* libg1m is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with libg1m; if not, see <http://www.gnu.org/licenses/>.
*
* This file is generated from the options you pass to the configure script.
* It shall not be modified by the user after its generation, as this could
* lead to unresolved symbols! If you want another configuration, then you
* will have to build the library again, with your different configuration.
* ************************************************************************** */
#ifndef LIBG1M_CONFIG_H
# define LIBG1M_CONFIG_H
# 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}
# define LIBG1M_MAINTAINER \\
"${maintainer}"
_EOF
# File part
if [ "$no_file" ]; then cat <<_EOF
/* FILE interface is disabled */
# define G1M_DISABLED_FILE 1
_EOF
fi
# End of the file
cat <<_EOF
#endif /* LIBG1M_CONFIG_H */
_EOF