cake
/
libp7
Archived
1
0
Fork 1
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.
libp7/tools/write-header-config

93 lines
3.2 KiB
Bash
Executable File

#!/bin/sh
#******************************************************************************#
# Arguments #
#******************************************************************************#
# Initialize the variables
no_file=
no_libusb=
version=
maintainer='anon <anon@localhost>'
# Read the arguments
for arg ; do case "$arg" in
--no-file) no_file=y ;;
--no-libusb) no_libusb=y ;;
--version=*) version="${arg#*=}" ;;
--maintainer=*) maintainer="${arg#*=}" ;;
*) echo "'${arg}': Did not read." >&2 ;;
esac; done
# Make version as a number
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
/* *****************************************************************************
* libp7/config.h -- libp7 configuration header.
* Copyright (C) 2017 Thomas "Cakeisalie5" Touhey <thomas@touhey.fr>
*
* This file is part of libp7.
* libp7 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.
*
* libp7 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 libp7; 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 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}
# define LIBP7_REV ${version_rev}
# define LIBP7_INDEV ${version_indev}
# define LIBP7_MAINTAINER \\
"${maintainer}"
_EOF
# File part
if [ "$no_file" ]; then cat <<_EOF
/* FILE interface is disabled */
# define P7_DISABLED_FILE 1
_EOF
fi
# libusb part
if [ "$no_libusb" ]; then cat <<_EOF
/* libusb is disabled */
# define P7_DISABLED_LIBUSB 1
_EOF
fi
# End of the file.
cat <<_EOF
#endif /* LIBP7_CONFIG_H */
_EOF