[Omake] Should we provide AC_MSG_* and other autoconf-style
functions?
Aleksey Nogin
nogin at metaprl.org
Wed Feb 14 15:21:50 PST 2007
I am thinking that we should provide more helper functions in the
lib/configure - perhaps making it easier for people to migrate off
autoconf in the same way we are trying to make it easier for people to
migrate off make.
So I am wondering - would it be reasonable to try to provide
autoconf-style functions, perhaps even with autoconf-style names?
My first initial small step is to introduce the AC_MSG_* functions
similar to autoconf's and change our own static. sections to use them in
a consistent manner in place of ad-hoc print/println combinations.
A preliminary patch is attached.
What would you guys think about this?
Aleksey
P.S. I've added a documentation chapter that describes the stuff that is
already available - see http://omake.metaprl.org/omake-autoconf.html
-------------- next part --------------
Index: doc/src/omake-language.tex
===================================================================
--- doc/src/omake-language.tex (revision 10047)
+++ doc/src/omake-language.tex (working copy)
@@ -666,8 +666,21 @@
println($'(disabled)')
\end{verbatim}
+The \OMake standard library provides a number of useful functions for
+programming the \verb+static.+ tests, as described in
+Chapter~\ref{chapter:autoconf}. Using the standard library, the above can
+be rewritten as
+
+\begin{verbatim}
+ open configure/Configure
+ static. =
+ LATEX_ENABLED = $(CheckProg latex)
+\end{verbatim}
+
As a matter of style, a \verb+static.+ section that is used for configuration should print what it
-is doing, using \verb+---+ as a print prefix.
+is doing, using the \hyperfunxn{AC_MSG_CHECKING}{AC\_MSG\_CHECKING} and
+\hyperfunxn{AC_MSG_RESULT}{AC\_MSG\_RESULT} functions (of couse, most of helper functions
+in the standard library would do that automatically).
\section{Short syntax for scoping objects}
Index: doc/src/omake-doc.tex
===================================================================
--- doc/src/omake-doc.tex (revision 10047)
+++ doc/src/omake-doc.tex (working copy)
@@ -59,6 +59,8 @@
\newcommand\hyperfun[1]{\hyperlink{fun:#1}{\texttt{#1} function}}
\newcommand\hyperfunn[1]{\hyperlink{fun:#1}{\texttt{#1}}}
+\newcommand\hyperfunx[2]{\hyperlink{fun:#1}{\texttt{#2} function}}
+\newcommand\hyperfunxn[2]{\hyperlink{fun:#1}{\texttt{#2}}}
\newcommand\hypervar[1]{\hyperlink{var:#1}{\texttt{#1} variable}}
\newcommand\hypervarn[1]{\hyperlink{var:#1}{\texttt{#1}}}
\newcommand\hypervarx[2]{\hyperlink{var:#1}{\texttt{#2} variable}}
Index: doc/OMakefile
===================================================================
--- doc/OMakefile (revision 10047)
+++ doc/OMakefile (working copy)
@@ -165,16 +165,11 @@
HEVEA_DIR =
HEVEA_OK = $(and $(CheckProg $(HEVEA)), $(CheckProg $(HACHA)))
if $(HEVEA_OK)
- print($"--- Looking for $(HEVEA) configs... ")
+ AC_MSG_CHECKING(for $(HEVEA) configs)
HEVEA_DIR = $(last $(shell $(HEVEA) -version))
- println($"($(HEVEA_DIR))")
- print($"--- Checking if $(HEVEA_DIR) exists... ")
- if $(test -d $(HEVEA_DIR))
- println($"(yes)")
- else
- println($"(no)")
- HEVEA_OK = false
- export
+ AC_MSG_RESULT($(HEVEA_DIR))
+ AC_MSG_CHECKING(if $(HEVEA_DIR) exists)
+ HEVEA_OK = $(AC_MSG_YES_NO $(test -d $(HEVEA_DIR)))
export
HEVEA_OPTIONS = -fix -I $(dir src) -I $(dir tex) -pedantic
Index: lib/build/OCaml.om
===================================================================
--- lib/build/OCaml.om (revision 10047)
+++ lib/build/OCaml.om (working copy)
@@ -103,15 +103,13 @@
OCAMLC_EXISTS = $(or $(OCAMLC_OPT_EXISTS), $(CheckProg ocamlc))
OCAMLOPT_OPT_EXISTS = $(CheckProg ocamlopt.opt)
OCAMLOPT_EXISTS = $(or $(OCAMLOPT_OPT_EXISTS), $(CheckProg ocamlopt))
- print(--- Testing whether ocamlc understands the "z" warnings... )
+ AC_MSG_CHECKING(whether ocamlc understands the "z" warnings)
OCAML_ACCEPTS_Z_WARNING =
if $(OCAMLC_EXISTS)
- private.res = $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -w Az)
- println($"($(if $(res), yes, no))")
- value $(res)
+ value $(AC_MSG_YES_NO $(shell-success-null ocamlc$(if $(OCAMLC_OPT_EXISTS), .opt) -w Az))
else
- println($"(FAILED - ocamlc not found)")
- value $(not true)
+ AC_MSG_RESULT($"FAILED - ocamlc not found")
+ value false
public.USE_OCAMLFIND = false
public.OCAMLFIND = $`(if $(USE_OCAMLFIND), ocamlfind)
@@ -276,33 +274,25 @@
# \end{doc}
#
static. =
- print($"--- Testing if ocamldep understands -modules... ")
- OCAMLDEP_MODULES_AVAILABLE = false
OCAMLDEP_MODULES =
- if $(shell-success-null ocamldep -modules)
- println($"(yes)")
- OCAMLDEP_MODULES_AVAILABLE = true
+ AC_MSG_CHECKING(if ocamldep understands -modules)
+ OCAMLDEP_MODULES_AVAILABLE = $(AC_MSG_YES_NO $(shell-success-null ocamldep -modules))
+ if $(OCAMLDEP_MODULES_AVAILABLE)
OCAMLDEP_MODULES = ocamldep
export
else
- println($"(no)")
- print($"--- Looking for ocamldep-omake bytecode file... ")
+ AC_MSG_CHECKING(for ocamldep-omake bytecode file)
OCAMLDEP_OMAKE = $(find-in-path-optional $(PATH), ocamldep-omake)
if $(OCAMLDEP_OMAKE)
OCAMLDEP_OMAKE = $(file $(OCAMLDEP_OMAKE))
- println($"(found $(absname $(OCAMLDEP_OMAKE)))")
+ AC_MSG_RESULT(found $(absname $(OCAMLDEP_OMAKE)))
- print($"--- Testing if ocamldep-omake runs... ")
- if $(shell-success-null ocamlrun $(OCAMLDEP_OMAKE) -modules)
- println($"(yes)")
- OCAMLDEP_MODULES_AVAILABLE = true
- OCAMLDEP_MODULES = ocamlrun $(OCAMLDEP_OMAKE)
- export
- else
- println($"(no)")
+ AC_MSG_CHECKING(if ocamldep-omake runs)
+ OCAMLDEP_MODULES_AVAILABLE = $(AC_MSG_YES_NO $(shell-success-null ocamlrun $(OCAMLDEP_OMAKE) -modules))
+ OCAMLDEP_MODULES = $(if $(OCAMLDEP_MODULES_AVAILABLE), ocamlrun $(OCAMLDEP_OMAKE))
export
else
- println($"(NOT FOUND)")
+ AC_MSG_RESULT(NOT FOUND)
export OCAMLDEP_MODULES_AVAILABLE OCAMLDEP_MODULES
public.OCAMLDEP_MODULES_ENABLED = false
@@ -590,9 +580,8 @@
MENHIR_AVAILABLE = $(CheckProg $(MENHIR))
MENHIR_RAW_DEPEND = false
if $(MENHIR_AVAILABLE)
- print($"--- Checking if $(MENHIR) supports the --raw-depend option... ")
- MENHIR_RAW_DEPEND = $(shell-success-null $(MENHIR) -help | grep $'^ *--raw-depend')
- println($(if $(MENHIR_RAW_DEPEND), $'(yes)', $'(no)'))
+ AC_MSG_CHECKING(if $(MENHIR) supports the --raw-depend option)
+ MENHIR_RAW_DEPEND = $(AC_MSG_YES_NO $(shell-success-null $(MENHIR) -help | grep $'^ *--raw-depend'))
export
# Menhir is being requested. Check that it is installed.
Index: lib/build/LaTeX.om
===================================================================
--- lib/build/LaTeX.om (revision 10047)
+++ lib/build/LaTeX.om (working copy)
@@ -100,17 +100,17 @@
if $(and $(LATEX_USABLE), $(not $(FORCE_WIN32_LATEX)), $(equal $(OSTYPE), Win32), $(CheckProg uname))
match($(shell uname))
case CYGWIN
- println($"--- You seem to be trying to use Cygwin LaTeX on a Win32 machine.")
- println($"--- This usually doesn't work, but if you really want to")
- println($"--- use it, add the following definition to your OMakeroot.")
- println($"--- FORCE_WIN32_LATEX = true")
- println($"--- (latex disabled)")
+ AC_MSG_WARN($""" You seem to be trying to use Cygwin LaTeX on a Win32 machine.
+ This usually doesn't work, but if you really want to
+ use it, add the following definition to your OMakeroot.
+ FORCE_WIN32_LATEX = true
+(latex disabled)""")
LATEX_USABLE = false
export
export
if $(and $(LATEX_USABLE), $(shell-success-null latex -help))
- print(--- Configuring LaTeX defaults... )
+ AC_MSG_CHECKING(LaTeX capabilities)
#
# Various versions of LaTeX use different options
@@ -156,10 +156,7 @@
#
RECORDER_ENABLED = $(and $(RECORDER_ENABLED), $(not $(BROKEN_MIKTEX)))
TETEX2_ENABLED = $(and $(RECORDER_ENABLED), $(ERROR_ENABLED))
- if $(TETEX2_ENABLED)
- println($'(tetex2 enabled)')
- else
- println($'(tetex2 disabled)')
+ AC_MSG_RESULT(tetex2 mode $(if $(TETEX2_ENABLED), enabled, disabled))
rm $(TETEX_CONFIG_TMP)
export FILE_LINE_ERROR TETEX2_ENABLED OUTPUT_COMMENT_SUPPORTED
Index: lib/configure/Configure.om
===================================================================
--- lib/configure/Configure.om (revision 10047)
+++ lib/configure/Configure.om (working copy)
@@ -23,6 +23,72 @@
# \end{doc}
#
+# A number of helper functions, using the autoconf names, when appropriate.
+#
+# \begin{doc}
+# \idsection{AC\_MSG\_CHECKING, AC\_MSG\_RESULT}\funref{AC_MSG_CHECKING}\funref{AC_MSG_RESULT}
+# \begin{verbatim}
+# AC_MSG_CHECKING(<msg>)
+# ...
+# AC_MSG_RESULT(<msg>)
+# \end{verbatim}
+# The \verb+AC_MSG_CHECKING+ function output message of the form \verb+--- Checking <msg>... +
+# \emph{without} any trailing newline. After the test advertized by \verb+AC_MSG_CHECKING+ is
+# performed, the \verb+AC_MSG_RESULT+ function should be used to output the result.
+#
+# In certain cases users may want to redefine these function --- for example, to use a different
+# output formatting and/or to copy the messages to a log file.
+#
+# Example:
+# \begin{verbatim}
+# static. =
+# AC_MSG_CHECKING(which foo to use)
+# foo = ...
+# AC_MSG_RESULT($(foo))
+# \end{verbatim}
+# \end{doc}
+#
+AC_MSG_CHECKING(msg) =
+ print($"--- Checking $(msg)... ")
+
+AC_MSG_RESULT(msg) =
+ println($"($(msg))")
+
+# \begin{doc}
+# \idsection{AC\_MSG\_WARN}\funref{AC_MSG_WARN}
+# \verb+AC_MSG_WARN(<msg>)+
+#
+# Prints a warning message.
+# \end{doc}
+AC_MSG_WARN(msg) =
+ msg[] = $(split $(nl), $"$(msg)")
+ print($(concat $(EMPTY), $(add-wrapper $'--- ', $(nl), $(msg))))
+
+#
+# \begin{doc}
+# \idsection{AC\_MSG\_YES\_NO, AC\_MSG\_FOUND}\funref{AC_MSG_FOUND}\funref{AC_MSG_YES_NO}
+# \begin{verbatim}
+# flag = $(AC_MSG_YES_NO <bool expr>
+# flag = $(AC_MSG_FOUND <bool expr>
+# \end{verbatim}
+#
+# The \verb+AC_MSG_FOUND+ function expects to receive a boolean flag describing whether a test
+# previously announced using the \hyperfunx{AC_MSG_CHECKING}{AC\_MSG\_CHECKING} found what it
+# was looking for. \verb+AC_MSG_FOUND+ will output the appropriate result (``found'' or ``NOT found'')
+# using the \hyperfunx{AC_MSG_RESULT}{AC\_MSG\_RESULT} and return its argument back.
+#
+# The \verb+AC_MSG_YES_NO+ function is similar, outputting a simple (``yes'' or ``NO'').
+# \end{doc}
+#
+AC_MSG_FOUND(found) =
+ AC_MSG_RESULT($(if $(found), found, NOT found))
+ return $(found)
+
+AC_MSG_YES_NO(found) =
+ AC_MSG_RESULT($(if $(found), yes, NO))
+ return $(found)
+
+#
# Check whether a header file exists.
# We call the C compiler.
#
@@ -38,7 +104,8 @@
# to run the compiler. Will incude \verb+<stdio.h>+ before including the specified header files.
#
# Both functions return a boolean value. The \verb+CheckHeader+ function is silent; the
-# \verb+VerboseCheckHeader+ function will output a line describing the test and the outcome.
+# \verb+VerboseCheckHeader+ function will use the \hyperfunxn{AC_MSG_CHECKING}{AC\_MSG\_CHECKING} and
+# \hyperfunxn{AC_MSG_RESULT}{AC\_MSG\_RESULT} functions to describe the test and the outcome.
#
# Example:
# \begin{verbatim}
@@ -77,13 +144,8 @@
return $(success)
public.VerboseCheckHeader(files) =
- print(--- Testing for $(files)... )
- protected.success = $(CheckHeader $(files))
- if $(success)
- println($'(found)')
- else
- println($'(NOT found)')
- return $(success)
+ AC_MSG_CHECKING(for $(files))
+ return $(AC_MSG_FOUND $(CheckHeader $(files)))
#
# Check whether the libraries have the given functions
@@ -101,7 +163,8 @@
# to run the compiler. Will pass the \verb+<libs>+ to the compiler using the \verb+-l+ flag.
#
# Both functions return a boolean value. The \verb+CheckLib+ function is silent; the
-# \verb+VerboseCheckLib+ function will output a line describing the test and the outcome.
+# \verb+VerboseCheckHeader+ function will use the \hyperfunxn{AC_MSG_CHECKING}{AC\_MSG\_CHECKING} and
+# \hyperfunxn{AC_MSG_RESULT}{AC\_MSG\_RESULT} functions to describe the test and the outcome.
#
# Example:
# \begin{verbatim}
@@ -143,16 +206,14 @@
return $(success)
public.VerboseCheckLib(libs, funs) =
- print($"""--- Testing for function$(if $(gt $(length $(funs)), 1), s) $(concat $", ", $(funs))""")
- if $(libs)
- print($""" in librar$(if $(gt $(length $(libs)), 1), ies, y) $(concat $", ", $(libs))""")
- print($"... ")
- if $(CheckLib $(libs), $(funs))
- println($"(found)")
- return true
- else
- println($"(NOT found)")
- return false
+ msg = $"""function$(if $(gt $(length $(funs)), 1), s) $(concat $", ", $(funs))"""
+ msg =
+ if $(libs)
+ value $"""$(msg) in librar$(if $(gt $(length $(libs)), 1), ies, y) $(concat $", ", $(libs))"""
+ else
+ value $(msg)
+ AC_MSG_CHECKING(for $(msg))
+ return $(AC_MSG_FOUND $(CheckLib $(libs), $(funs)))
#
# Check whether a program exists in the PATH
@@ -161,19 +222,20 @@
# \fun{CheckProg}
# \verb+success = $(CheckProg <prog>)+
#
-# Checks whether the program \verb+<prog>+ exists in your path. Will output a line describing the
-# test and the outcome.
+# Checks whether the program \verb+<prog>+ exists in your path. Will use the
+# \hyperfunxn{AC_MSG_CHECKING}{AC\_MSG\_CHECKING} and
+# \hyperfunxn{AC_MSG_RESULT}{AC\_MSG\_RESULT} functions to describe the test and the outcome.
#
# \end{doc}
#
public.CheckProg(prog) =
- print($"--- Testing for $(prog)... ")
+ AC_MSG_CHECKING(for $(prog))
WHERE = $(where $(prog))
if $(WHERE)
- println($"(found $(nth 0, $(WHERE)))")
+ AC_MSG_RESULT(found $(nth 0, $(WHERE)))
return true
else
- println($"(FAILED - no $(prog) found)")
+ AC_MSG_RESULT(FAILED - no $(prog) found)
return false
#
Index: lib/configure/ncurses.om
===================================================================
--- lib/configure/ncurses.om (revision 10047)
+++ lib/configure/ncurses.om (working copy)
@@ -18,11 +18,7 @@
NCURSES_AVAILABLE = false
NCURSES_TERMH_IN_NCURSES = false
if $(not $(equal $(OSTYPE), Win32))
- print(--- Testing for ncurses... )
+ AC_MSG_CHECKING(for ncurses)
NCURSES_TERMH_IN_NCURSES = $(CheckHeader ncurses/term.h)
- NCURSES_AVAILABLE = $(and $(CheckHeader ncurses.h), $(or $(NCURSES_TERMH_IN_NCURSES), $(CheckHeader term.h)), $(CheckLib ncurses, initscr setupterm tigetstr))
- if $(NCURSES_AVAILABLE)
- println($'(enabled)')
- else
- println($'(disabled)')
+ NCURSES_AVAILABLE = $(AC_MSG_FOUND $(and $(CheckHeader ncurses.h), $(or $(NCURSES_TERMH_IN_NCURSES), $(CheckHeader term.h)), $(CheckLib ncurses, initscr setupterm tigetstr)))
export
Index: lib/configure/fam.om
===================================================================
--- lib/configure/fam.om (revision 10047)
+++ lib/configure/fam.om (working copy)
@@ -13,7 +13,7 @@
export
else
# Unix
- print(--- Testing for FAM... )
+ AC_MSG_CHECKING(for FAM)
# See if the FamOpen function exists
FAM_AVAILABLE = $(and $(CheckHeader fam.h), $(CheckLib fam, FAMOpen))
@@ -22,17 +22,14 @@
if $(FAM_AVAILABLE)
FAM_CLIBS = -lfam
FAM_CFLAGS = -DFAM_ENABLED
- println($'(enabled)')
- print($"--- Testing whether FAM supports Gamin's extensions... ")
- if $(CheckLib fam, FAMNoExists)
- println($'(yes)')
+ AC_MSG_RESULT(found)
+ AC_MSG_CHECKING($"whether FAM supports Gamin's extensions")
+ if $(AC_MSG_YES_NO $(CheckLib fam, FAMNoExists))
FAM_CFLAGS += -DHAVE_FAMNOEXISTS
export
- else
- println($'(no)')
export
elseif $(CheckHeader sys/event.h)
- println($'(using kqueue)')
+ AC_MSG_RESULT(using kqueue)
FAM_AVAILABLE = true
FAM_CFLAGS = -DFAM_ENABLED -DFAM_PSEUDO -DFAM_KQUEUE
FAM_CLIBS =
@@ -44,6 +41,6 @@
export
export
else
- println($'(disabled)')
+ AC_MSG_RESULT(NOT found)
export
Index: lib/configure/readline.om
===================================================================
--- lib/configure/readline.om (revision 10047)
+++ lib/configure/readline.om (working copy)
@@ -30,7 +30,7 @@
READLINE_CFLAGS =
READLINE_GNU = false
if $(and $(NCURSES_AVAILABLE), $(not $(equal $(OSTYPE), Win32)))
- print(--- Testing for readline... )
+ AC_MSG_CHECKING(for readline)
# Test that readline exists
if $(and $(CheckHeader readline/readline.h readline/history.h), $(CheckLib ncurses readline, tgetent tgetstr readline))
@@ -46,12 +46,6 @@
export
- if $(READLINE_AVAILABLE)
- if $(READLINE_GNU)
- println($'(enabled) (GNU)')
- else
- println($'(enabled) (non-GNU)')
- else
- println($'(disabled)')
+ AC_MSG_RESULT($(if $(READLINE_AVAILABLE), $"found, $(if $(not $(READLINE_GNU)), non-)GNU", NOT found))
export
More information about the Omake
mailing list