9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: Tim Goodwin tjg@star.le.ac.uk
Subject: [9fans] 9libs, new sam release, experimental wily release
Date: Fri, 11 Jun 1999 15:11:55 +0100	[thread overview]
Message-ID: <19990611141155.3ptX92gmZR300-sa892Yor4DWNs6G2bkN55f4B_fflw@z> (raw)

In article <199906111008.GAA08404@cse.psu.edu>,  <forsyth@vitanuova.COM> wrote:
>it would be nice if someone did a general but sane configuration method for the gnu software
>to replace the existing configure crud.

Yup.  It's effective, but not pretty.  In the rc-1.6 distribution,
`configure' is the largest file by a factor of more than 2; it is over 9
times larger than any C source file except the yacc-generated parse.c.
Both Makefile.in and aclocal.m4 are also larger than any source files;
between the three of them, they make up over 25% over the distribution.
Still, they probably compress better than most of the other files :-).

I think the approach taken by some of Dan Bernstein's software is
probably along the right lines.  Here's a snippet from the Makefile of
his clockspeed package.

    hasrdtsc.h: \
    tryrdtsc.c compile load
            ( ( ./compile tryrdtsc.c && ./load tryrdtsc && ./tryrdtsc \
            ) >/dev/null 2>&1 \
            && echo \#define HASRDTSC 1 || exit 0 ) > hasrdtsc.h
            rm -f tryrdtsc.o tryrdtsc

In case it's not obvious, this attempts to compile, load, and run
the program tryrdtsc.c.  If it can be built, and runs successfully,
hasrdtsc.h will contain the single line `#define HASRDTSC 1'; otherwise
it will be empty.

The autoconf equivalent would be something along these lines.

    AC_DEFUN(TRY_RDTSC, [
        AC_CACHE_CHECK(for Pentium RTDSC instruction, try_rdtsc,
            AC_TRY_RUN([
    <text of tryrdtsc.c goes here>
             ], try_rdtsc=yes, try_rdtsc=no, try_rdtsc=yes))
             case "$try_rdtsc" in
             yes) AC_DEFINE(HASRDTSC) ;;
             esac
     ])

It's obvious how to make the trivial changes to Bernstein's Makefile
to produce the equivalent of autoconf's AC_TRY_LINK or AC_TRY_COMPILE.
With AC_TRY_RUN, the three macros form the basis of almost all sensible
autoconf checks.

How do the two systems compare?

The autoconf version is longer, even in the configure.in version.  It
expands to about 40 lines of even more impenetrable shell script after
processing.

For all that extra code, the only extra features I can see in the
autoconf version are: i) it tells the user what it is doing, and
ii) there is "support" for cross-compiling.  Well, most users don't
have a clue what the Pentium RDTSC instruction is anyway; a comment
in tryrtdsc.c would be as helpful to those that do care.  As for
cross-compilation: autoconf knows when you're cross-compiling, and
substitutes a default value.  If there is a useful default value, why
would we bother with autoconf in the first place?  Bernstein's system
encourages the savvy installer to run the test program on the target
machine, and create the *correct* hasrdtsc.h.

Both systems feature caching.  The configure script builds a
config.cache; Bernstein simply uses make's dependency rules.  When
you are developing feature tests, config.cache is at completely the
wrong granularity.  With autoconf, I'd have to fire up an editor on
config.cache, find the line that mentions try_rdtsc, remove it, then
rerun the *entire* configure script.  With Bernstein, it's just `rm
hasrdtsc.h; make'.

Speaking of granularity, autoconf dumps all its discoveries about
the system into a single config.h.  Any C source file that needs a
feature test depends on config.h; changing the result of one test means
recompiling all of them.  (In rc's case, this turns out to be *every*
C file; I'm afraid I was a bit lazy here.)  This, of course, is why
autoconf must go through hoops to avoid replacing config.h with a newly
generated, but identical, one.

I'm seriously considering dumping autoconf / automake as the build
engine for rc(the next generation), and using something more like
Bernstein's system.  (Unfortunately, I don't think he's made the
framework generally available; I gather that his Makefiles are
automatically generated.  Still, I could probably reimplement the whole
lot in about the time it takes to get the quoting right on one autoconf
macro.)

Apologies for the length...

Tim.




             reply	other threads:[~1999-06-11 14:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-06-11 14:11 Tim [this message]
  -- strict thread matches above, loose matches on Subject: below --
1999-07-03 14:20 Mark
1999-06-16  4:15 okamoto
1999-06-11 10:10 forsyth
1999-06-10 23:04 Mark

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19990611141155.3ptX92gmZR300-sa892Yor4DWNs6G2bkN55f4B_fflw@z \
    --to=9fans@9fans.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).