From eeed6ddbf5456e78c51e5d9bfded20e310b34c72 Mon Sep 17 00:00:00 2001 From: Geoff Levand Date: Wed, 2 Jun 2021 19:39:35 -0700 Subject: [PATCH] Add Makefile Signed-off-by: Geoff Levand --- Makefile.am | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++ bootstrap | 20 ++++++++++++++++++ configure.ac | 23 ++++++++++++++++++++ version.sh | 57 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 160 insertions(+) create mode 100644 Makefile.am create mode 100755 bootstrap create mode 100644 configure.ac create mode 100755 version.sh diff --git a/Makefile.am b/Makefile.am new file mode 100644 index 00000000..5b29e54c --- /dev/null +++ b/Makefile.am @@ -0,0 +1,60 @@ +AUTOMAKE_OPTIONS = foreign + +ACLOCAL_AMFLAGS = -I m4 + +edit = sed \ + -e 's|@PACKAGE\@|$(PACKAGE)|g' \ + -e 's|@PACKAGE_BUGREPORT\@|$(PACKAGE_BUGREPORT)|g' \ + -e 's|@PACKAGE_NAME\@|$(PACKAGE_NAME)|g' \ + -e 's|@PACKAGE_URL\@|$(PACKAGE_URL)|g' \ + -e 's|@PACKAGE_VERSION\@|$(PACKAGE_VERSION)|g' \ + -e 's|@datadir\@|$(pkgdatadir)|g' \ + -e 's|@libexecdir\@|$(libexecdir)|g' \ + -e 's|@prefix\@|$(prefix)|g' + +composed_bin_scripts = scripts/start-qemu.sh + +bin_SCRIPTS = $(composed_bin_scripts) + +composed_nobase_bin_scripts = tdd-lib/util.sh + +nobase_bin_SCRIPTS = $(composed_nobase_bin_scripts) + +$(composed_bin_scripts): % : Makefile $(srcdir)/%.in + rm -f '$(@)' '$(@).tmp' + mkdir -p '$(@D)' + $(edit) '$(srcdir)/$(@).in' > '$(@).tmp' + chmod +x '$(@).tmp' + mv '$(@).tmp' '$(@)' + +$(composed_nobase_bin_scripts): % : Makefile $(srcdir)/scripts/% + rm -f '$(@)' '$(@).tmp' + mkdir -p '$(@D)' + $(edit) '$(srcdir)/scripts/$(@)' > '$(@).tmp' + chmod +x '$(@).tmp' + mv '$(@).tmp' '$(@)' + +# mkdir -p '$(@D)' +# cp -av '$(srcdir)/scripts/$(@)' '$(@)' + +EXTRA_DIST = bootstrap configure.ac COPYING m4 mit-plus-license.txt README.md \ + tests/* version.sh $(addsuffix .in, $(composed_bin_scripts)) \ + $(nobase_bin_SCRIPTS) + +CLEANFILES = $(bin_SCRIPTS) + +MAINTAINERCLEANFILES = aclocal.m4 compile config.h* configure depcomp \ + install-sh Makefile.in missing $(PACKAGE)-*.gz + +maintainer-clean-local: + rm -rf m4 .deps + +.PHONY: help + +help: + @echo "Targets:" + @echo " make install" + @echo " make dist" + @echo " make distcheck" + @echo " make distclean" + @echo " make maintainer-clean" diff --git a/bootstrap b/bootstrap new file mode 100755 index 00000000..1507fcbb --- /dev/null +++ b/bootstrap @@ -0,0 +1,20 @@ +#!/usr/bin/env bash + +script_name="${0##*/}" + +echo "${script_name}: '$(pwd)'" + +progs="bash" +for p in ${progs}; do + if ! test -x "$(command -v ${p})"; then + echo "${script_name}: ERROR: Please install '${p}'." >&2 + result=1 + fi +done + +if [[ ${result} ]]; then + exit 1 +fi + +mkdir -p m4 +exec autoreconf --force --install ${@} diff --git a/configure.ac b/configure.ac new file mode 100644 index 00000000..8bb5bc5d --- /dev/null +++ b/configure.ac @@ -0,0 +1,23 @@ +## configure.ac -- Process this file with autoconf to produce configure + +AC_INIT([tdd-project], + [m4_esyscmd_s([./version.sh])], + [Geoff Levand ], + [tdd-project], + [https://github.com/glevand/tdd-project]) + +AC_USE_SYSTEM_EXTENSIONS +AC_CONFIG_MACRO_DIR([m4]) +AC_PREFIX_DEFAULT([/usr/local]) +AC_PROG_INSTALL + +AM_INIT_AUTOMAKE +AC_GNU_SOURCE + +AM_SILENT_RULES([yes]) + +AC_SUBST([DESTDIR]) +AC_CONFIG_HEADERS([config.h]) +AC_CONFIG_FILES([Makefile]) + +AC_OUTPUT diff --git a/version.sh b/version.sh new file mode 100755 index 00000000..6c730804 --- /dev/null +++ b/version.sh @@ -0,0 +1,57 @@ +#!/usr/bin/env bash +# +# version.sh: Create a version string for use by configure.ac +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; version 2 of the License. +# +# This program 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 General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + +version= +datefmt='%Y.%m.%d' + +GIT_DIR=$(dirname "${0}")/.git/ +export GIT_DIR + +if head="$(git rev-parse --short=8 --verify HEAD 2>/dev/null)"; then + suffix='' + # Add a '-dirty' suffix for uncommitted changes. + if git diff-index HEAD | read -r dummy; then + suffix='-dirty' + fi + + if tag="$(git describe --tags --exact-match 2>/dev/null)"; then + # use a tag; remove any 'v' prefix from v tags + tag="${tag#v}" + version="$(printf "%s%s" "${tag}" "${suffix}")" + else + # Use the git commit revision for the package version, and add + # a date prefix for easy comparisons. + date="$(git log --pretty=format:"%ct" -1 HEAD)" + version="$(printf "%($datefmt)T.g%s%s" "${date}" "${head}" "${suffix}")" + fi +else + # Check if a specific version is set, eg: by buildroot + if [ -n "${PACKAGE_VERSION}" ]; then + # Full git hash + len="$(echo -n "${PACKAGE_VERSION}" | wc -c)" + if [[ ${len} == 40 ]]; then + version="$(echo -n "${PACKAGE_VERSION}" | sed 's/^\([0-9a-f]\{7\}\).*/\1/;')" + else + version="${PACKAGE_VERSION}" + fi + else + # Default to current date and time. + version="$(date +dev.${datefmt})" + fi +fi + +echo "${version}"