Skip to content

Commit

Permalink
Merge pull request #132 from oetiker/be-good
Browse files Browse the repository at this point in the history
behave more autotooly
  • Loading branch information
oetiker committed Jan 21, 2015
2 parents 4cdbcde + 1830bce commit 9b96e7e
Show file tree
Hide file tree
Showing 10 changed files with 178 additions and 129 deletions.
25 changes: 11 additions & 14 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,17 @@ perl:
install:
- true

before_script:
- ./setup/build-devel.sh $HOME/znapzend/thirdparty

script:
- ./configure --prefix=$HOME/znapzend || true
- make get-thirdparty-modules
- ./configure --prefix=$HOME/znapzend
- make install
- perl -I$HOME/znapzend/thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzend.t $HOME/znapzend || test $? == 1
- perl -I$HOME/znapzend/thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzendzetup.t $HOME/znapzend || test $? == 1
- perl -I$HOME/znapzend/thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzendztatz.t $HOME/znapzend || test $? == 1
- perl -I$HOME/znapzend/thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/autoscrub.t $HOME/znapzend || test $? == 1
- env PERL5LIB=$HOME/znapzend/thirdparty/lib/perl5 $HOME/znapzend/thirdparty/bin/cover -report coveralls
- PERL_CPANM_HOME=`pwd`/thirdparty PERL_CPANM_OPT="--notest --local-lib "`pwd`/thirdparty perl ./thirdparty/bin/cpanm Devel::Cover::Report::Coveralls
- perl -I./thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzend.t ./bin/znapzend || test $? == 1
- perl -I./thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzendzetup.t ./bin/znapzend || test $? == 1
- perl -I./thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/znapzendztatz.t ./bin/znapzend || test $? == 1
- perl -I./thirdparty/lib/perl5
-MDevel::Cover=+ignore,thirdparty ./t/autoscrub.t ./bin/znapzend || test $? == 1
- perl -I./thirdparty/lib/perl5 thirdparty/bin/cover -report coveralls

27 changes: 14 additions & 13 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ POD = doc/znapzend.pod doc/znapzendzetup.pod doc/znapzendztatz.pod
THIRDPARTY_DIR := $(shell pwd)/thirdparty


THIRDPARTY := $(shell test -d thirdparty && find thirdparty/lib/perl5 -type f)


GENERATED_EXTRADIST = $(MAN)
EXTRA_DIST = VERSION COPYRIGHT README.md LICENSE CHANGES AUTHORS PERL_MODULES setup/sdbs.inc $(BIN) $(PM) $(GENERATED_EXTRADIST) init/znapzend.xml.in t/autoscrub.t t/ssh t/znapzend.t t/znapzendztatz.t t/mbuffer t/zfs t/znapzendzetup.t t/zpool

Expand All @@ -47,9 +44,6 @@ svc_DATA = init/znapzend.xml

endif

thirdpartydir = $(prefix)
nobase_thirdparty_DATA = $(THIRDPARTY)

dist_bin_SCRIPTS = $(BIN)

imandir = $(mandir)/man1
Expand All @@ -66,18 +60,25 @@ README.md COPYRIGHT: configure

CHANGES: configure
git log --simplify-merges --full-history --no-merges --pretty=format:'%ai %d %s -- %an' > CHANGES

install-exec-hook:
$(AM_V_GEN)[ "$(PERL5LIB)" != "" ] && cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# PERL5LIB}{use lib qw($(PERL5LIB)); # PERL5LIB}' $(BIN) || true
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN)

all-local:
$(AM_V_GEN)[ "$(MISSING_PERL_MODULES)" == "" ] || $(GMAKE) get-thirdparty-modules

install-exec-hook:
$(AM_V_GEN)[ "$(PERL5LIB)" == "" ] || cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# PERL5LIB}{use lib qw($(PERL5LIB)); # PERL5LIB}' $(BIN)
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# LIBDIR}{use lib qw($(libdir)); # LIBDIR}' $(BIN)
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN)
$(AM_V_GEN)cp -fr $(THIRDPARTY_DIR)/lib/perl5/* $(DESTDIR)$(libdir)

dist-hook: $(POD) $(MAN) CHANGES
$(AM_V_GEN)cd $(distdir) && $(PERL) -i -p -e '"$(PACKAGE_VERSION)" =~ /(\d+)\.(\d+)\.(\d+)/ and $$v = sprintf("%d.%03d%03d",$$1,$$2,$$3) and s/^\$$VERSION\s+=\s+".+?"/\$$VERSION = "$$d"/;' $(BIN)
$(AM_V_GEN)cd $(distdir) && $(PERL) -i -p -e '"$(PACKAGE_VERSION)" =~ /(\d+)\.(\d+)\.(\d+)/ and $$v = sprintf("%d.%03d%03d",$$1,$$2,$$3) and s/^\$$VERSION\s+=\s+".+?"/\$$VERSION = "$$d"/;' $(BIN)
$(GMAKE) $(MAN)

get-thirdparty-modules:
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || mkdir -p $(THIRDPARTY_DIR)/bin && wget --no-check-certificate -O $(THIRDPARTY_DIR)/bin/cpanm cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm
echo $(PERL_MODULES) | PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL_CPANM_OPT="--notest --local-lib $(THIRDPARTY_DIR)" xargs $(PERL) $(THIRDPARTY_DIR)/bin/cpanm
[ -d $(THIRDPARTY_DIR)/bin ] || mkdir -p $(THIRDPARTY_DIR)/bin
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || ( [ -x $(CURL) ] && $(CURL) --location --insecure https://cpanmin.us > $(THIRDPARTY_DIR)/bin/cpanm cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm )
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || ( [ -x $(WGET) ] && $(WGET) --no-check-certificate -O $(THIRDPARTY_DIR)/bin/cpanm https://cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm )
echo $(MISSING_PERL_MODULES) | PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL_CPANM_OPT="--notest --local-lib $(THIRDPARTY_DIR)" xargs $(PERL) $(THIRDPARTY_DIR)/bin/cpanm

test:
$(PERL) "-MExtUtils::Command::MM" "-e" "test_harness(1, 'lib','thirdparty/lib/perl5')" t/*.t
Expand Down
80 changes: 30 additions & 50 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ am__uninstall_files_from_dir = { \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(imandir)" \
"$(DESTDIR)$(thirdpartydir)" "$(DESTDIR)$(svcdir)"
"$(DESTDIR)$(svcdir)"
SCRIPTS = $(dist_bin_SCRIPTS)
AM_V_P = $(am__v_P_@AM_V@)
am__v_P_ = $(am__v_P_@AM_DEFAULT_V@)
Expand Down Expand Up @@ -169,7 +169,7 @@ am__can_run_installinfo = \
n|no|NO) false;; \
*) (install-info --version) >/dev/null 2>&1;; \
esac
DATA = $(iman_DATA) $(nobase_thirdparty_DATA) $(svc_DATA)
DATA = $(iman_DATA) $(svc_DATA)
RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive \
distclean-recursive maintainer-clean-recursive
am__recursive_targets = \
Expand Down Expand Up @@ -248,6 +248,7 @@ AUTOCONF = @AUTOCONF@
AUTOHEADER = @AUTOHEADER@
AUTOMAKE = @AUTOMAKE@
AWK = @AWK@
CURL = @CURL@
CYGPATH_W = @CYGPATH_W@
DEFS = @DEFS@
ECHO_C = @ECHO_C@
Expand All @@ -264,6 +265,7 @@ LIBS = @LIBS@
LTLIBOBJS = @LTLIBOBJS@
MAINT = @MAINT@
MAKEINFO = @MAKEINFO@
MISSING_PERL_MODULES = @MISSING_PERL_MODULES@
MKDIR_P = @MKDIR_P@
PACKAGE = @PACKAGE@
PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
Expand All @@ -275,13 +277,13 @@ PACKAGE_VERSION = @PACKAGE_VERSION@
PATH_SEPARATOR = @PATH_SEPARATOR@
PERL = @PERL@
PERL5LIB = @PERL5LIB@
PERL_MODULES = @PERL_MODULES@
POD2MAN = @POD2MAN@
SET_MAKE = @SET_MAKE@
SHELL = @SHELL@
STRIP = @STRIP@
SVCINSTALLDIR = @SVCINSTALLDIR@
VERSION = @VERSION@
WGET = @WGET@
abs_builddir = @abs_builddir@
abs_srcdir = @abs_srcdir@
abs_top_builddir = @abs_top_builddir@
Expand Down Expand Up @@ -330,15 +332,12 @@ PM := $(shell find lib/ -name "*.pm")
MAN = man/znapzend.1 man/znapzendzetup.1 man/znapzendztatz.1
POD = doc/znapzend.pod doc/znapzendzetup.pod doc/znapzendztatz.pod
THIRDPARTY_DIR := $(shell pwd)/thirdparty
THIRDPARTY := $(shell test -d thirdparty && find thirdparty/lib/perl5 -type f)
GENERATED_EXTRADIST = $(MAN)
EXTRA_DIST = VERSION COPYRIGHT README.md LICENSE CHANGES AUTHORS PERL_MODULES setup/sdbs.inc $(BIN) $(PM) $(GENERATED_EXTRADIST) init/znapzend.xml.in t/autoscrub.t t/ssh t/znapzend.t t/znapzendztatz.t t/mbuffer t/zfs t/znapzendzetup.t t/zpool
YEAR := $(shell date +%Y)
DATE := $(shell date +%Y-%m-%d)
@ENABLE_SVCINSTALL_TRUE@svcdir = @SVCINSTALLDIR@
@ENABLE_SVCINSTALL_TRUE@svc_DATA = init/znapzend.xml
thirdpartydir = $(prefix)
nobase_thirdparty_DATA = $(THIRDPARTY)
dist_bin_SCRIPTS = $(BIN)
imandir = $(mandir)/man1
iman_DATA = $(MAN)
Expand Down Expand Up @@ -438,30 +437,6 @@ uninstall-imanDATA:
@list='$(iman_DATA)'; test -n "$(imandir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(imandir)'; $(am__uninstall_files_from_dir)
install-nobase_thirdpartyDATA: $(nobase_thirdparty_DATA)
@$(NORMAL_INSTALL)
@list='$(nobase_thirdparty_DATA)'; test -n "$(thirdpartydir)" || list=; \
if test -n "$$list"; then \
echo " $(MKDIR_P) '$(DESTDIR)$(thirdpartydir)'"; \
$(MKDIR_P) "$(DESTDIR)$(thirdpartydir)" || exit 1; \
fi; \
$(am__nobase_list) | while read dir files; do \
xfiles=; for file in $$files; do \
if test -f "$$file"; then xfiles="$$xfiles $$file"; \
else xfiles="$$xfiles $(srcdir)/$$file"; fi; done; \
test -z "$$xfiles" || { \
test "x$$dir" = x. || { \
echo " $(MKDIR_P) '$(DESTDIR)$(thirdpartydir)/$$dir'"; \
$(MKDIR_P) "$(DESTDIR)$(thirdpartydir)/$$dir"; }; \
echo " $(INSTALL_DATA) $$xfiles '$(DESTDIR)$(thirdpartydir)/$$dir'"; \
$(INSTALL_DATA) $$xfiles "$(DESTDIR)$(thirdpartydir)/$$dir" || exit $$?; }; \
done

uninstall-nobase_thirdpartyDATA:
@$(NORMAL_UNINSTALL)
@list='$(nobase_thirdparty_DATA)'; test -n "$(thirdpartydir)" || list=; \
$(am__nobase_strip_setup); files=`$(am__nobase_strip)`; \
dir='$(DESTDIR)$(thirdpartydir)'; $(am__uninstall_files_from_dir)
install-svcDATA: $(svc_DATA)
@$(NORMAL_INSTALL)
@list='$(svc_DATA)'; test -n "$(svcdir)" || list=; \
Expand Down Expand Up @@ -783,10 +758,10 @@ distcleancheck: distclean
exit 1; } >&2
check-am: all-am
check: check-recursive
all-am: Makefile $(SCRIPTS) $(DATA)
all-am: Makefile $(SCRIPTS) $(DATA) all-local
installdirs: installdirs-recursive
installdirs-am:
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(imandir)" "$(DESTDIR)$(thirdpartydir)" "$(DESTDIR)$(svcdir)"; do \
for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(imandir)" "$(DESTDIR)$(svcdir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-recursive
Expand Down Expand Up @@ -840,8 +815,7 @@ info: info-recursive

info-am:

install-data-am: install-imanDATA install-nobase_thirdpartyDATA \
install-svcDATA
install-data-am: install-imanDATA install-svcDATA

install-dvi: install-dvi-recursive

Expand Down Expand Up @@ -889,12 +863,12 @@ ps: ps-recursive
ps-am:

uninstall-am: uninstall-dist_binSCRIPTS uninstall-imanDATA \
uninstall-nobase_thirdpartyDATA uninstall-svcDATA
uninstall-svcDATA

.MAKE: $(am__recursive_targets) install-am install-exec-am \
install-strip

.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am all-local \
am--refresh check check-am clean clean-cscope clean-generic \
cscope cscopelist-am ctags ctags-am dist dist-all dist-bzip2 \
dist-gzip dist-hook dist-lzip dist-shar dist-tarZ dist-xz \
Expand All @@ -904,14 +878,13 @@ uninstall-am: uninstall-dist_binSCRIPTS uninstall-imanDATA \
install-data-am install-dist_binSCRIPTS install-dvi \
install-dvi-am install-exec install-exec-am install-exec-hook \
install-html install-html-am install-imanDATA install-info \
install-info-am install-man install-nobase_thirdpartyDATA \
install-pdf install-pdf-am install-ps install-ps-am \
install-strip install-svcDATA installcheck installcheck-am \
installdirs installdirs-am maintainer-clean \
maintainer-clean-generic mostlyclean mostlyclean-generic pdf \
pdf-am ps ps-am tags tags-am uninstall uninstall-am \
uninstall-dist_binSCRIPTS uninstall-imanDATA \
uninstall-nobase_thirdpartyDATA uninstall-svcDATA
install-info-am install-man install-pdf install-pdf-am \
install-ps install-ps-am install-strip install-svcDATA \
installcheck installcheck-am installdirs installdirs-am \
maintainer-clean maintainer-clean-generic mostlyclean \
mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
uninstall-am uninstall-dist_binSCRIPTS uninstall-imanDATA \
uninstall-svcDATA


doc/%.pod: bin/% configure
Expand All @@ -926,17 +899,24 @@ README.md COPYRIGHT: configure
CHANGES: configure
git log --simplify-merges --full-history --no-merges --pretty=format:'%ai %d %s -- %an' > CHANGES

install-exec-hook:
$(AM_V_GEN)[ "$(PERL5LIB)" != "" ] && cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# PERL5LIB}{use lib qw($(PERL5LIB)); # PERL5LIB}' $(BIN) || true
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN)
all-local:
$(AM_V_GEN)[ "$(MISSING_PERL_MODULES)" == "" ] || $(GMAKE) get-thirdparty-modules

install-exec-hook:
$(AM_V_GEN)[ "$(PERL5LIB)" == "" ] || cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# PERL5LIB}{use lib qw($(PERL5LIB)); # PERL5LIB}' $(BIN)
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{.*# LIBDIR}{use lib qw($(libdir)); # LIBDIR}' $(BIN)
$(AM_V_GEN)cd "$(DESTDIR)$(exec_prefix)" && $(PERL) -i -p -e 's{^#!.*perl.*}{#!$(PERL)};' $(BIN)
$(AM_V_GEN)cp -fr $(THIRDPARTY_DIR)/lib/perl5/* $(DESTDIR)$(libdir)

dist-hook: $(POD) $(MAN) CHANGES
$(AM_V_GEN)cd $(distdir) && $(PERL) -i -p -e '"$(PACKAGE_VERSION)" =~ /(\d+)\.(\d+)\.(\d+)/ and $$v = sprintf("%d.%03d%03d",$$1,$$2,$$3) and s/^\$$VERSION\s+=\s+".+?"/\$$VERSION = "$$d"/;' $(BIN)
$(AM_V_GEN)cd $(distdir) && $(PERL) -i -p -e '"$(PACKAGE_VERSION)" =~ /(\d+)\.(\d+)\.(\d+)/ and $$v = sprintf("%d.%03d%03d",$$1,$$2,$$3) and s/^\$$VERSION\s+=\s+".+?"/\$$VERSION = "$$d"/;' $(BIN)
$(GMAKE) $(MAN)

get-thirdparty-modules:
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || mkdir -p $(THIRDPARTY_DIR)/bin && wget --no-check-certificate -O $(THIRDPARTY_DIR)/bin/cpanm cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm
echo $(PERL_MODULES) | PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL_CPANM_OPT="--notest --local-lib $(THIRDPARTY_DIR)" xargs $(PERL) $(THIRDPARTY_DIR)/bin/cpanm
[ -d $(THIRDPARTY_DIR)/bin ] || mkdir -p $(THIRDPARTY_DIR)/bin
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || ( [ -x $(CURL) ] && $(CURL) --location --insecure https://cpanmin.us > $(THIRDPARTY_DIR)/bin/cpanm cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm )
[ -x $(THIRDPARTY_DIR)/bin/cpanm ] || ( [ -x $(WGET) ] && $(WGET) --no-check-certificate -O $(THIRDPARTY_DIR)/bin/cpanm https://cpanmin.us && chmod 755 $(THIRDPARTY_DIR)/bin/cpanm )
echo $(MISSING_PERL_MODULES) | PERL_CPANM_HOME=$(THIRDPARTY_DIR) PERL_CPANM_OPT="--notest --local-lib $(THIRDPARTY_DIR)" xargs $(PERL) $(THIRDPARTY_DIR)/bin/cpanm

test:
$(PERL) "-MExtUtils::Command::MM" "-e" "test_harness(1, 'lib','thirdparty/lib/perl5')" t/*.t
Expand Down
5 changes: 3 additions & 2 deletions PERL_MODULES
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
[email protected]
Mojo::IOLoop::[email protected]
[email protected]
Mojo::IOLoop::[email protected]

12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,13 @@ tar zxvf znapzend-0.14.0.tar.gz
cd znapzend-0.14.0
./configure --prefix=/opt/znapzend-0.14.0
```
if configure complains about missing perl modules, run

```sh
make get-thirdparty-modules
```

to install the missing modules. NOTE: This will NOT messup your local perl installation!

Now you can run configure again and then
If configure finds anything noteworthy, it will tell you about it. If any
perl modules are found to be missing, they get installed locally into the znapzend
installation. Your perl installation will not get modified!

```sh
make
make install
```

Expand Down
4 changes: 1 addition & 3 deletions bin/znapzend
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env perl

use FindBin;
# PERL5LIB
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../thirdparty/lib/perl5";
use FindBin; use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../thirdparty/lib/perl5"; # LIBDIR

use Getopt::Long qw(:config posix_default no_ignore_case);
use Pod::Usage;
Expand Down
4 changes: 1 addition & 3 deletions bin/znapzendzetup
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env perl

use FindBin;
# PERL5LIB
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../thirdparty/lib/perl5";
use FindBin; use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../thirdparty/lib/perl5"; # LIBDIR

use Getopt::Long qw(:config posix_default no_ignore_case pass_through);
use Pod::Usage;
Expand Down
6 changes: 2 additions & 4 deletions bin/znapzendztatz
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/usr/bin/env perl

use FindBin;
# PERL5LIB
use lib "$FindBin::Bin/../lib";
use lib "$FindBin::Bin/../thirdparty/lib/perl5";
# PERL5LIB
use FindBin; use lib "$FindBin::Bin/../lib", "$FindBin::Bin/../thirdparty/lib/perl5"; # LIBDIR

use Getopt::Long qw(:config posix_default no_ignore_case);
use Pod::Usage;
Expand Down
Loading

0 comments on commit 9b96e7e

Please sign in to comment.