-[AC_DEFINE_UNQUOTED(DICTIONARY, "$withval")],
-[AC_DEFINE(DICTIONARY, "/usr/dict/words")])
-AC_OUTPUT(Makefile)
+[DICTIONARY=$withval],
+[AC_CACHE_CHECK([dictionary], [mdw_cv_dictionary],
+ [for mdw_cv_dictionary in \
+ /usr/share/dict/words \
+ /usr/dict/words; do
+ test -r "$i" && break
+ done])
+ DICTIONARY=$mdw_cv_dictionary])
+AC_DEFINE_UNQUOTED([DICTIONARY], ["$DICTIONARY"],
+ [Define this to be your default wordlist location.])
+AC_SUBST([DICTIONARY])
+
+mdw_DEFINE_PATHS([
+ ANAG=mdw_PATH([${bindir}])/mdw_PROG([anag])
+])
+
+AC_SUBST([ANAG])
+AC_OUTPUT(Makefile anag-gui)