Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ olddoc/Makefile
olddoc/Makefile.in
.deps/
src/lha
src/version.h
src/Makefile
src/Makefile.in
stamp-h1
Expand Down
9 changes: 8 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## Process this file with automake to produce Makefile.in

AUTOMAKE_OPTIONS = foreign
EXTRA_DIST = README.md README.jp.md header.doc.md header.doc.jp Hacking_of_LHa
EXTRA_DIST = README.md README.jp.md header.doc.md header.doc.jp Hacking_of_LHa autogen.sh build-aux/gen-build-version.sh
SUBDIRS= man olddoc src tests

## Re-run autoconf to regenerate configure and update PACKAGE_VERSION via .tarball-version
dist-hook:
cd $(top_srcdir) && \
build-aux/gen-build-version.sh --package --check-clean -o .tarball-version && \
$(AUTOCONF) --force
mv $(top_srcdir)/.tarball-version $(distdir)
17 changes: 17 additions & 0 deletions autogen.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Exit on error
set -e

# Check for dependencies
if ! command -v git &>/dev/null; then
echo "git is required but not found. Exiting."
exit 1
fi

# Run autoreconf to generate configure script
autoreconf --force --install --symlink

# Run configure
mkdir build 2>/dev/null || true
cd build && ../configure "$@"
80 changes: 80 additions & 0 deletions build-aux/gen-build-version.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/bin/sh
# Print version string derived from Git or .tarball-version
# If called with --package, output a simplified package version string (written to file if -o is used)

set -e

top_srcdir=$(dirname $0)/..

VERSION_PREFIX="1.14i-ac"
OUTPUT_FOR_PACKAGE=false
OUTPUT_FILE=

while [ $# -gt 0 ]; do
case "$1" in
--package)
OUTPUT_FOR_PACKAGE=true
shift
;;
--check-clean)
CHECK_CLEAN=true
shift
;;
-o)
OUTPUT_FILE="$2"
shift 2
;;
*)
echo "Usage: $0 [--package] [-o <output-file>]" >&2
exit 1
;;
esac
done

# Ensure we are inside a clean Git work tree for --package
check_git_clean_for_package() {
if test x"$DIRTY" != x; then
echo "Error: working tree is dirty; commit or stash changes before running with packaging" >&2
exit 1
fi

if test "$IS_INSIDE_WORK_TREE" != true; then
echo "Error: not inside a Git repository" >&2
exit 1
fi
}

output_version() {
if test x"$OUTPUT_FILE" = x && test -f $top_srcdir/.tarball-version; then
version=$(cat $top_srcdir/.tarball-version)
elif test "$OUTPUT_FOR_PACKAGE" = true; then
version="${VERSION_PREFIX}${DATE}"
else
version="${VERSION_PREFIX}${DATE}-${HASH}${DIRTY}"
fi

if test x"$OUTPUT_FILE" != x; then
echo $version > $OUTPUT_FILE
else
echo $version
fi
}

# Use Git info to generate full version
if git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
IS_INSIDE_WORK_TREE=true
set -- $(git log -1 --date=format:"%Y%m%d" --pretty=format:"%cd %h")
DATE=$1 HASH=$2

DIRTY=""
if ! git diff --quiet || ! git diff --cached --quiet; then
DIRTY="-dirty"
echo "Warning: repository is dirty (has uncommitted changes)" >&2
fi
fi

if test "$CHECK_CLEAN" = true; then
check_git_clean_for_package
fi

output_version
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Process this file with autoconf to produce a configure script.
AC_INIT([LHa for UNIX], 1.14i-ac20220213, jca02266@gmail.com, lha)
m4_define([VERSION_STRING], m4_esyscmd_s([build-aux/gen-build-version.sh --package]))
AC_INIT([LHa for UNIX], VERSION_STRING, [jca02266@gmail.com], [lha])
AC_DEFINE_UNQUOTED(LHA_CONFIGURE_OPTIONS, "$ac_configure_args",
[specified options for the configure script.])
AC_CANONICAL_HOST
Expand Down
13 changes: 12 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,18 @@ lha_SOURCES = append.c bitio.c crcio.c dhuf.c extract.c header.c huf.c \
lhext.c lhlist.c maketbl.c maketree.c patmatch.c shuf.c slide.c \
util.c getopt_long.c getopt_long.h \
pm2.c pm2hist.c pm2tree.c \
support_utf8.c
support_utf8.c version.h.in
lha_LDADD = @LIBOBJS@
EXTRA_DIST = lhdir.h fnmatch.h
AM_CPPFLAGS=$(DEF_KCODE) $(SUPPORT_LZHUFF_METHOD)

BUILT_SOURCES = version.h
CLEANFILES = version.h

version.h: FORCE
@echo "Generating version.h..."
@BUILD_VERSION=`sh $(top_srcdir)/build-aux/gen-build-version.sh`; \
sed "s|@BUILD_VERSION@|$$BUILD_VERSION|" $(srcdir)/version.h.in > $@.tmp
@if cmp -s $@.tmp $@; then rm -f $@.tmp; else mv $@.tmp $@; fi

FORCE:
6 changes: 4 additions & 2 deletions src/lharc.c
Original file line number Diff line number Diff line change
Expand Up @@ -726,14 +726,16 @@ main(argc, argv)


/* ------------------------------------------------------------------------ */
#include "version.h"

static void
print_version()
{
/* macro PACKAGE_NAME, PACKAGE_VERSION and PLATFORM are
defined in config.h by configure script */
fprintf(stdout, "%s version %s (%s)\n",
PACKAGE_NAME, PACKAGE_VERSION, PLATFORM);
PACKAGE_NAME, BUILD_VERSION, PLATFORM);

if (strlen(LHA_CONFIGURE_OPTIONS) != 0)
fprintf(stdout, " configure options: %s\n", LHA_CONFIGURE_OPTIONS);
}
Expand Down
1 change: 1 addition & 0 deletions src/version.h.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#define BUILD_VERSION "@BUILD_VERSION@"