diff --git a/.gitignore b/.gitignore index 0ecdfc21..31f9ad3e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,4 @@ -Makefile +/Makefile Makefile.old Build Build.bat diff --git a/MANIFEST b/MANIFEST index dfbe6830..27632379 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,6 +3,7 @@ docs/Installation.md inc/Module/Install.pm inc/Module/Install/Base.pm inc/Module/Install/Can.pm +inc/Module/Install/External.pm inc/Module/Install/Fetch.pm inc/Module/Install/Makefile.pm inc/Module/Install/Metadata.pm @@ -18,6 +19,7 @@ META.yml README.md script/zonemaster-cli script/zonemaster-info +share/GNUmakefile share/Makefile share/locale/da/LC_MESSAGES/Zonemaster-CLI.mo share/locale/fr/LC_MESSAGES/Zonemaster-CLI.mo diff --git a/Makefile.PL b/Makefile.PL index 41944ad5..43971622 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -23,13 +23,28 @@ requires( 'Zonemaster::LDNS' => 2.0, ); +# Make all platforms include inc/Module/Install/External.pm +requires_external_bin 'find'; +if ($^O eq "freebsd") { + requires_external_bin 'gmake'; +}; + sub MY::postamble { - return <<'MAKE_FRAG'; - $(MYEXTLIB): share/Makefile - cd share && $(MAKE) all -MAKE_FRAG + my $sharemakefile = 'share/GNUmakefile'; + if ($^O eq "freebsd") { + # Make FreeBSD use gmake for share + return "GMAKE ?= \"gmake\"\n" + . "pure_all :: $sharemakefile\n" + . "\tcd share && \$(GMAKE) all\n"; + } else { + # Here Linux and GNU Make is assumed + return "pure_all :: $sharemakefile\n" + . "\tcd share && \$(MAKE) all\n"; + }; }; + + install_script 'zonemaster-cli'; install_share; diff --git a/docs/Installation.md b/docs/Installation.md index b67e29b3..5bafb471 100644 --- a/docs/Installation.md +++ b/docs/Installation.md @@ -97,7 +97,7 @@ This instruction covers the following operating systems: 2) Install dependencies available from binary packages: ```sh - pkg install p5-JSON-XS p5-Locale-libintl p5-MooseX-Getopt p5-Text-Reflow + pkg install devel/gmake p5-JSON-XS p5-Locale-libintl p5-MooseX-Getopt p5-Text-Reflow ``` 3) Install Zonemaster::CLI: diff --git a/share/GNUmakefile b/share/GNUmakefile new file mode 100644 index 00000000..c600ebad --- /dev/null +++ b/share/GNUmakefile @@ -0,0 +1,39 @@ +# This is the main Makefile in this directory and should be kept +# GNU Make compatible. + +.POSIX: +.SUFFIXES: .po .mo +.PHONY: all dist touch-po update-po extract-pot + +DISTNAME = Zonemaster-CLI +POFILES := $(shell find . -maxdepth 1 -type f -name '*.po' -exec basename {} \;) +MOFILES := $(POFILES:%.po=%.mo) +POTFILE = $(DISTNAME).pot +PMFILES := $(shell find ../lib -type f -name '*.pm' | sort) + +all: $(MOFILES) + @echo + @echo Remember to make sure all of the above names are in the + @echo MANIFEST file, or they will not be installed. + @echo + +touch-po: + @touch $(POTFILE) $(POFILES) + +update-po: extract-pot $(POFILES) + +extract-pot: + @xgettext --output $(POTFILE) --sort-by-file --add-comments --language=Perl --from-code=UTF-8 -k__ -k\$$__ -k%__ -k__x -k__n:1,2 -k__nx:1,2 -k__xn:1,2 -kN__ -kN__n:1,2 -k__p:1c,2 -k__np:1c,2,3 -kN__p:1c,2 -kN__np:1c,2,3 $(PMFILES) + +$(POTFILE): extract-pot + +%.po: $(POTFILE) + @msgmerge --update --backup=none --quiet --no-location $(MSGMERGE_OPTS) $@ $(POTFILE) + +.po.mo: + @msgfmt -o $@ $< + @mkdir -p locale/`basename $@ .mo`/LC_MESSAGES + @ln -vf $@ locale/`basename $@ .mo`/LC_MESSAGES/$(DISTNAME).mo + +show-fuzzy: + @for f in $(POFILES) ; do msgattrib --only-fuzzy $$f ; done diff --git a/share/Makefile b/share/Makefile index dbfa91ba..a883f892 100644 --- a/share/Makefile +++ b/share/Makefile @@ -1,36 +1,15 @@ -.POSIX: -.SUFFIXES: .po .mo -.PHONY: all dist touch-po update-po extract-pot +# This is a wrapper for BSD Make (FreeBSD) to execute +# GNU Make (gmake) and the primary makefile GNUmakefile. -DISTNAME = Zonemaster-CLI -POFILES != find . -maxdepth 1 -type f -name '*.po' -MOFILES := $(POFILES:%.po=%.mo) -POTFILE = $(DISTNAME).pot -PMFILES != find ../lib -type f -name '*.pm' | sort +GNUMAKE?= gmake +FILES != ls * -all: $(MOFILES) - @echo - @echo Remember to make sure all of the above names are in the - @echo MANIFEST file, or they will not be installed. - @echo +# File targets should be evaluated by gmake. +.PHONY: all $(FILES) -touch-po: - @touch $(POTFILE) $(POFILES) +all: + @${GNUMAKE} $@ -update-po: extract-pot $(POFILES) +.DEFAULT: + @${GNUMAKE} $@ -extract-pot: - @xgettext --output $(POTFILE) --sort-by-file --add-comments --language=Perl --from-code=UTF-8 -k__ -k\$$__ -k%__ -k__x -k__n:1,2 -k__nx:1,2 -k__xn:1,2 -kN__ -kN__n:1,2 -k__p:1c,2 -k__np:1c,2,3 -kN__p:1c,2 -kN__np:1c,2,3 $(PMFILES) - -$(POTFILE): extract-pot - -%.po: $(POTFILE) - @msgmerge --update --backup=none --quiet --no-location $(MSGMERGE_OPTS) $@ $(POTFILE) - -.po.mo: - @msgfmt -o $@ $< - @mkdir -p locale/`basename $@ .mo`/LC_MESSAGES - @ln -vf $@ locale/`basename $@ .mo`/LC_MESSAGES/$(DISTNAME).mo - -show-fuzzy: - @for f in $(POFILES) ; do msgattrib --only-fuzzy $$f ; done