Menu

NCO Makefile problems

Developers
2005-11-09
2013-10-17
  • Harry Mangalam

    Harry Mangalam - 2005-11-09

    This is YACTTRTFM (yet another cautionary tale to RTFM)
    Some context:
    In modifying the make/configure system to support MPI, MacOSX, netcdf4, etc, I concentrated on the configure.in  file and ignored the prime directive - never touch the Makefile.in - only edit the Makefile.am.  I was allowed to live in this fantasy because I never regenerated the Makefile species with a automake.  When I finished with getting configure.in to behave I edited Makefile.in to support the MPI programs, checked it into cvs and thought all was well.  When Charlie regenerated the chain from scratch to release the latest version, all those changes disappeared. 

    In waiting for the wounds to heal,  I've read much of the Autoconf manual and browsed back in the nco cvs archives, and I can see what is supposed to happen, but there are a few things that I still do not understand - mostly about the errors reported when compiling the cvs version of Makefile.am and (relatedly) how to force the AM_CONDITIONAL in the configure.in.

    Without using the AM_CONDITIONAL token, I can get things to compile mostly by using the Makefile.am, but when they are required (both in the existing CVS version and when I introduce another to handle the MPI compilation, it looks like they aren't recognized.  You can see the result of this by executing the line given in the configure.in headers (another thing I conveniently overlooked) on the cvs Makefile.am:

    $ aclocal;autoheader;automake --foreign;autoconf
    configure.in:102: warning: AC_PROG_LEX invoked multiple times
    autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from...
    aclocal.m4:6130: AM_PROG_LEX is expanded from...
    configure.in:102: the top level
    src/nco/Makefile.am:124: variable `NCO_GETOPT' not defined
    src/nco/Makefile.am:25: variable `NCAP' not defined
    src/nco/Makefile.am:25: variable `NCWA' not defined
    src/nco/Makefile.am:25: variable `NCAP' not defined
    src/nco/Makefile.am:25: variable `NCWA' not defined
    src/nco/Makefile.am:74: invalid unused variable name: `ncwa_LDADD'
    src/nco/Makefile.am:29: invalid unused variable name: `ncap_SOURCES'
    src/nco/Makefile.am:73: invalid unused variable name: `ncwa_SOURCES'
    src/nco/Makefile.am:30: invalid unused variable name: `ncap_LDADD'
    configure.in:102: warning: AC_PROG_LEX invoked multiple times
    autoconf/programs.m4:438: AC_DECL_YYTEXT is expanded from...
    aclocal.m4:6130: AM_PROG_LEX is expanded from...
    configure.in:102: the top level

    This DOES result in a Makefile.in and Makefile that will build the base NCOs, but using a CONDITIONAL to test for MPI is apparently ignored (the same cause of the above errors - they are defined in another ignored CONDITIONAL clause) and generates many more such errors.

    harry

     
    • Harry Mangalam

      Harry Mangalam - 2005-11-09

      OK - a partial solution - the only thing I can come up with to explain it is that the automake system must have changed recently in its parsing rules. 

      The reason for the errors is that the Makefile.am (all the way back to Rorik's day) set up the conditionals like this to show the logic:

      if BUILD_YACC_SOURCE
        NCAP=ncap
      else
        NCAP=
      endif

      This is now illegal and if done this way, automake will refuse to convert the logic to a Makefile.in and thereon.

      All such conditional statements CANNOT have any leading spaces OR TABS in the stanza or it will be ignored.

      So it needs to look like this:
      if BUILD_YACC_SOURCE
      NCAP=ncap
      else
      NCAP=
      endif

      Correcting this leads to the correct generation of a Makefile.in and thence the compilation of the binaries, serial as well as MPI.

      &(#*&(&@%^)(@*$&+@$(*#%^(*@^)(*#&$#($^(*&##)($&

      (while it sounds like swearing, I'm only screaming my PGP key)

      hjm

       
      • Charlie Zender

        Charlie Zender - 2005-11-09

        This makes some sense give the sensitivity to space/tab issues
        in make for historical reasons.

        I just added -*-make-*- mode to all Makefile.am's in the distribution
        so Emacs users will see appropriate syntax highlighting when
        editing Makefile.am's.

        Charlie

         
    • Harry Mangalam

      Harry Mangalam - 2005-11-09

      And a few more words of discovery.
      Ubuntu/Kubuntu by default installs (and maintains thru apt-get install of later versions via symlinks to /etc/alternatives/automake) an old and krufty version of automake - 1.4p6.  the current version is 1.9.  If you manually re-symlink to the later versions, you will get many fewer errors (altho now you get warnings that the earlier version is expected).

      The joys of make.

      hjm

       
    • Harry Mangalam

      Harry Mangalam - 2005-11-09

      and (maybe a final coda to this annoying music)
      you have to re-symlink aclocal to the same version as automake.  Other more intelligent (?) distros may do this for you, but kubuntu does not.

      when this is done, all errors from the:

      aclocal;autoheader;automake --foreign;autoconf

      command disappear.

      !!

      hjm

       

Log in to post a comment.