-## -*-makefile-*-
-##
-## $Id: Makefile.am,v 1.12 2004/04/08 01:36:19 mdw Exp $
-##
-## Makefile for Anag
-##
-## (c) 2001 Mark Wooding
-##
-
-##----- Licensing notice ----------------------------------------------------
-##
-## This file is part of Anag: a simple wordgame helper.
-##
-## Anag 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; either version 2 of the License, or
-## (at your option) any later version.
-##
-## Anag 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 Anag; if not, write to the Free Software Foundation,
-## Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-AUTOMAKE_OPTIONS = foreign
-javadir = $(datadir)/java
+### -*-makefile-*-
+###
+### Build script for `anag'
+###
+### (c) 2001, 2016 Mark Wooding
+###
+
+###----- Licensing notice ---------------------------------------------------
+###
+### This file is part of Anag: a simple wordgame helper.
+###
+### Anag 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; either version 2 of the License, or
+### (at your option) any later version.
+###
+### Anag 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 Anag; if not, write to the Free Software Foundation,
+### Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+EXTRA_DIST =
+CLEANFILES =
+SUFFIXES =
+
+bin_PROGRAMS =
+bin_SCRIPTS =
+
+LDADD =
+if HAVE_PCRE2
+ LDADD += $(PCRE2_LIBS)
+else
+if HAVE_PCRE
+ LDADD += $(PCRE_LIBS)
+endif
+endif
+
+###--------------------------------------------------------------------------
+### Making substitutions.
+
+confsubst = $(top_srcdir)/config/confsubst
+V_SUBST = $(V_SUBST_$(V))
+V_SUBST_ = $(V_SUBST_$(AM_DEFAULT_VERBOSITY))
+V_SUBST_0 = @echo " SUBST $@";
+SUBST = $(V_SUBST)$(confsubst)
+SUBSTITUTIONS = \
+ PACKAGE=$(PACKAGE) VERSION=$(VERSION) \
+ DICTIONARY=$(DICTIONARY) \
+ WISH=$(WISH) \
+ ANAG=$(bindir)/anag
+
+EXTRA_DIST += config/confsubst
+
+###--------------------------------------------------------------------------
+### Main program.
+
+bin_PROGRAMS += anag
+anag_SOURCES = anag.c anag.h util.c
+anag_SOURCES += anagram.c
+anag_SOURCES += longest.c
+anag_SOURCES += mono.c
+if HAVE_PCRE2
+ anag_SOURCES += pcre.c
+else
+if HAVE_PCRE
+ anag_SOURCES += pcre.c
+endif
+endif
+if HAVE_REGCOMP
+ anag_SOURCES += regexp.c
+endif
+anag_SOURCES += trackword.c
+anag_SOURCES += wildcard.c
+
+###--------------------------------------------------------------------------
+### Java frontend.
JAVAC = @JAVAC@
+SUFFIXES += .java .class
+CLEANFILES += *.class *.jar
+V_JAVAC = $(V_JAVAC_$(V))
+V_JAVAC_ = $(V_JAVAC_$(AM_DEFAULT_VERBOSITY))
+V_JAVAC_0 = @echo " JAVAC $@";
+V_JAR = $(V_JAR_$(V))
+V_JAR_ = $(V_JAR_$(AM_DEFAULT_VERBOSITY))
+V_JAR_0 = @echo " JAR $@";
+.java.class:; $(V_JAVAC)$(JAVAC) -d . $(JAVACFLAGS) $<
-SUFFIXES = .java .class
-.java.class:; $(JAVAC) -d . $<
+javadir = $(datadir)/java
-bin_PROGRAMS = anag
-bin_SCRIPTS = @TKPROGS@
-EXTRA_SCRIPTS = anag-gui
-java_DATA = @JARFILES@
+if HAVE_JAVAC
+java_DATA = anag.jar
+endif
-anag_SOURCES = \
- anag.c anag.h util.c \
- wildcard.c anagram.c mono.c trackword.c regexp.c pcre.c
-EXTRA_anag_SOURCES = regexp.c
+EXTRA_DIST += anag.manifest
+EXTRA_DIST += AnagGUI.java
anag.jar: AnagGUI.class
- jar cfm anag.jar $(srcdir)/anag.manifest Anag*.class Whinge*.class
+ $(V_JAR)jar cfm $@ $(srcdir)/anag.manifest *.class
+
+###--------------------------------------------------------------------------
+### Tcl/Tk frontend.
+
+if HAVE_WISH
+bin_SCRIPTS += anag-gui
+endif
+
+EXTRA_DIST += anag-gui.in
+CLEANFILES += anag-gui
+
+anag-gui: anag-gui.in Makefile
+ $(SUBST) $(srcdir)/anag-gui.in >$@.new $(SUBSTITUTIONS) && \
+ chmod +x $@.new && mv $@.new $@
+###--------------------------------------------------------------------------
+### Distribution arrangements.
+
+## Version number tracking.
+dist-hook:
+ echo $(VERSION) >$(distdir)/RELEASE
+
+EXTRA_DIST += config/auto-version
+
+## Zip file for DOSish platforms.
doszip: distdir
rm -f $(PACKAGE).zip
zip -qlr $(PACKAGE).zip $(distdir)
rm -rf $(distdir)
-EXTRA_DIST = \
- AnagGUI.java anag-gui.in anag.manifest \
- debian/control debian/changelog debian/copyright debian/rules \
- debian/anag-gui-java.postinst debian/anag-gui-java.prerm \
- debian/anag-gui-tk.postinst debian/anag-gui-tk.prerm
-
-CLEANFILES = *.class *.jar
+## Debian packaging.
+EXTRA_DIST += debian/control debian/changelog debian/copyright
+EXTRA_DIST += debian/rules debian/compat debian/source/format
+EXTRA_DIST += debian/anag.install
+EXTRA_DIST += debian/anag-gui-java.install
+EXTRA_DIST += debian/anag-gui-java.postinst
+EXTRA_DIST += debian/anag-gui-java.prerm
+EXTRA_DIST += debian/anag-gui.java
+EXTRA_DIST += debian/anag-gui-tk.install
+EXTRA_DIST += debian/anag-gui-tk.postinst
+EXTRA_DIST += debian/anag-gui-tk.prerm
##----- That's all, folks ---------------------------------------------------