I have been updating my build tools to optionally use autotools (autoconfig/automake/libtool etc.).

As part of this change I have written a couple of M4 macros. This not being something I have done before, any input is appreciated on style or if things can be done better.

This macro checks to see if the YAML libraries are installed:

        AS_HELP_STRING([--with-yamlroot=<location>], [Directory of YAML_ROOT])
        AS_HELP_STRING([--disable-yaml], [Disable yaml serializsation])
        [test "x$enable_yaml" != "xno"],

        if test "${with_yamlroot}" != ""; then
            LDFLAGS="$LDFLAGS -L$with_yamlroot/lib"

                AC_DEFINE([HAVE_YAML], 1, [When on Yaml Serialization code will be compiled])

Error: Could not find libyaml

You can solve this by installing libyaml
    see http://pyyaml.org/wiki/LibYAML

Alternately specify install location with:
    --with-yamlroot=<location of yaml installation>

If you do not want to use yaml serialization then it
can be disabled with:

                ], [1])]


If YAML is detected, then no problems. If the configure script cannot find them, the error message is generated with three options:

  1. Disable the use of YAML
  2. Provide the location where YAML is installed (not default)
  3. Instructions on how to install

I only have some comments about the shell scripting elements.

This is a very archaic (and silly) way of testing flags:

    [test "x$enable_yaml" != "xno"],

You can write simpler as:

    [test "$enable_yaml" != no],

This can be simplified:

    if test "${with_yamlroot}" != ""; then

To just:

    if test "${with_yamlroot}"; then

I also find it odd to use sometimes $this_style and sometimes ${that_style}. I prefer less typing (especially the shift key for }), so the first, simpler style. The only time I use braces is when appending some text directly after the variable would break the script, for example in situations like this:

authtype=...  # something
# broken, not using the $authtype variable
# good
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.