diff options
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | config/Makefile.am | 2 | ||||
-rwxr-xr-x | config/getlib.sh | 2 | ||||
-rwxr-xr-x | config/getver.pl | 45 | ||||
-rwxr-xr-x | config/getver.sh | 48 | ||||
-rw-r--r-- | configure.ac | 2 | ||||
-rwxr-xr-x | docs/naturaldocs/run_docs.sh | 2 |
7 files changed, 53 insertions, 50 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 57cd95d..377d397 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,7 +75,7 @@ else (USE_EXT_GD) MACRO(GV VER VAR) execute_process( - COMMAND perl ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.pl ${VER} + COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/config/getver.sh ${VER} OUTPUT_VARIABLE ${VAR} ) ENDMACRO(GV) diff --git a/config/Makefile.am b/config/Makefile.am index 6416dda..c5a8bb5 100644 --- a/config/Makefile.am +++ b/config/Makefile.am @@ -1,5 +1,5 @@ ## Process this file with automake to produce Makefile.in -*-Makefile-*- -EXTRA_DIST = gdlib.pc.cmake gdlib.pc.in getlib.sh getver.pl +EXTRA_DIST = gdlib.pc.cmake gdlib.pc.in getlib.sh getver.sh pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = gdlib.pc diff --git a/config/getlib.sh b/config/getlib.sh index 4835cf6..5070e30 100755 --- a/config/getlib.sh +++ b/config/getlib.sh @@ -1,6 +1,6 @@ #!/bin/sh -GETVER="${0%/*}/getver.pl" +GETVER="${0%/*}/getver.sh" GDLIB_MAJOR=$("${GETVER}" MAJOR) GDLIB_MINOR=$("${GETVER}" MINOR) GDLIB_REVISION=$("${GETVER}" RELEASE) diff --git a/config/getver.pl b/config/getver.pl deleted file mode 100755 index 52f1b58..0000000 --- a/config/getver.pl +++ /dev/null @@ -1,45 +0,0 @@ -#!/usr/bin/env perl - -# Simple script to extract the version number parts from src/gd.h. If -# called with the middle word of the version macro, it prints the -# value of that macro. If called with no argument, it outputs a -# human-readable version string. This must be run in the project -# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh. - -use strict; - -use FindBin; - -my $key = shift; -my @version_parts = (); -my $dir = $FindBin::Bin; - -open FH, "<$dir/../src/gd.h" # old-style filehandle for max. portability - or die "Unable to open 'gd.h' for reading.\n"; - -while(<FH>) { - next unless m{version605b5d1778}; - next unless /^#define\s+GD_([A-Z0-9]+)_VERSION+\s+(\S+)/; - my ($lk, $lv) = ($1, $2); - if ($lk eq $key) { - chomp $lv; - $lv =~ s/"//g; - - print $lv; # no newline - exit(0); # success! - } - - push @version_parts, $lv if (!$key); -} - -close(FH); - -if (scalar @version_parts == 4) { - my $result = join(".", @version_parts[0..2]); - $result .= $version_parts[3]; - $result =~ s/"//g; - print $result; - exit(0); -} - -exit(1); # failure diff --git a/config/getver.sh b/config/getver.sh new file mode 100755 index 0000000..589802f --- /dev/null +++ b/config/getver.sh @@ -0,0 +1,48 @@ +#!/bin/sh + +# Simple script to extract the version number parts from src/gd.h. If +# called with the middle word of the version macro, it prints the +# value of that macro. If called with no argument, it outputs a +# human-readable version string. This must be run in the project +# root. It is used by configure.ac and docs/naturaldocs/run_docs.sh. + +TOPDIR="${0%/*}/.." +HEADER="${TOPDIR}/src/gd.h" +SENTINEL="/*version605b5d1778*/" + +getpart() { + awk -vfield="GD_${1}_VERSION" -vsentinel="${SENTINEL}" ' + $1 == "#define" && $2 == field && $NF == sentinel { + gsub(/^"/, "", $3) + gsub(/"$/, "", $3) + print $3 + } + ' "${HEADER}" +} + +case $# in +0) + printf '%s.%s.%s%s\n' \ + $(getpart MAJOR) \ + $(getpart MINOR) \ + $(getpart RELEASE) \ + $(getpart EXTRA) + ;; +1) + case $1 in + MAJOR|MINOR|RELEASE|EXTRA) + part=$(getpart "$1") + if [ -n "${part}" ]; then + printf '%s' "${part}" + fi + ;; + *) + exit 1 + ;; + esac + ;; +*) + echo "$0: error: script takes at most 1 arg" + exit 1 + ;; +esac diff --git a/configure.ac b/configure.ac index 535db68..be49494 100644 --- a/configure.ac +++ b/configure.ac @@ -4,7 +4,7 @@ AC_PREREQ(2.64) # We extract version numbers from src/versions.h -define([gv],[perl config/getver.pl ]$1) +define([gv],[config/getver.sh ]$1) m4_define([gd_MAJOR],esyscmd(gv(MAJOR)))dnl m4_define([gd_MINOR],esyscmd(gv(MINOR)))dnl diff --git a/docs/naturaldocs/run_docs.sh b/docs/naturaldocs/run_docs.sh index 347d06f..05e29d0 100755 --- a/docs/naturaldocs/run_docs.sh +++ b/docs/naturaldocs/run_docs.sh @@ -49,7 +49,7 @@ fi echo "Found '$(nd)': $($(nd) -h | head -n1)" # Library version number. -VERSION=$(cd ../../; perl config/getver.pl) +VERSION=$(cd ../../; config/getver.sh) # Clear away old docs and ensure the doc dir. is present. rm -rf html |