lynx-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Lynx-dev] configure-script issue


From: Thorsten Glaser
Subject: Re: [Lynx-dev] configure-script issue
Date: Sat, 5 Feb 2022 12:21:09 +0000 (UTC)

Thomas Dickey dixit:

>I created the macro after dealing with users who would put C preprocessor
>options in $CC

I think that, if you even want to detect it, you should only warn for it.
We sell rope so the user can shoot himself into the foot, after all.

> (which for lynx will cause it to not build the configuration
>summary page as expected, for ncurses will cause interesting build failures,
>etc)

Directly inspecting the variables is error-prone anyway. Instead, you
should consider doing it like mksh’s configure script, which first
checks that the compiler works at all; in mksh’s example, this means
it successfully compiles and links…

        /* evil apo'stroph in comment test */
        #include <unistd.h>
        int main(void) { int t[2]; return (isatty(pipe(t))); }

… then checks that the compiler/linker fails correctly for… <<-EOF

        #include <unistd.h>
        extern int thiswillneverbedefinedIhope(void);
        int main(void) { return (isatty(0) +
        #$expr
            0
        #else
        /* force a failure: expr is false */
            thiswillneverbedefinedIhope()
        #endif
            ); }
EOF

… where $expr is 'if 0' in the first run, then uses this very
construct to test for the couple of CPPFLAGS that the configury
script needs to know about (e.g. to construct the regression
testsuite caller script’s list of categories to set).

“successfully compiles and links” means that…

| $CC $CFLAGS $Cg $CPPFLAGS $LDFLAGS $NOWARN conftest.c $LIBS

… succeeds and generates one of a.out, a.exe, conftest.exe or
conftest. (Here, $Cg is the configury-added "-g" or "-Og -g3"
or similar, $NOWARN is the empty string while this is being
tested.) For all compilers *except* “msc” it also means that
the errorlevel of the $CC command is 0.

I’ve so far found two compilers that fail it; “dec” may succeed
if adding ${ccpl}-non_shared to CFLAGS (should be LDFLAGS, now
that I see it), “dmc” if adding ${ccpl}/DELEXECUTABLE (where
ccpl is "-Wl," normally but "-Yl," on UWIN and "-Y " on Interix).

“msc” is ifdef _MSC_VER, “dmc” is ifdef __DMC__, “dec” is
if defined(__DECC) || (defined(__osf__) && !defined(__GNUC__)).

For mksh, isatty(3) is a required function; for lynx you’d maybe
use a different one.

> or would load up $CC with optimization/debugging options (similar

That’s the users’ problem.

In mksh/Build.sh I only add default optimisation/debugging options
if, at script entry, the result of doing…

allu=QWERTYUIOPASDFGHJKLZXCVBNM
alll=qwertyuiopasdfghjklzxcvbnm
alln=0123456789
i=`echo :"$orig_CFLAGS" | sed 's/^://' | tr -c -d $alll$allu$alln`

… is $i containing the empty string. (There’s a Build.sh flag to
explicitly enable debugging, which sets $Og (see above) to something
suitable for the compiler detected and adds -DDEBUG to CPPFLAGS, but
that’s orthogonal to this.) I am aware of GNU autotools liking to add
their own "-O2 -g" default flags, which is precisely why mksh’s does
not do that.

>problems, with complaints when it didn't evaluate in the expected order).

The order is somewhat canonical though.

${CPP:-$CC -E} $CPPFLAGS srcfn.c

$CC $CFLAGS $CPPFLAGS -c srcfn.c
$CC $CFLAGS $LDFLAGS -o tgtfn srcfn.o $LIBS

$CC $CFLAGS $CPPFLAGS $LDFLAGS -o tgtfn srcfn.c $LIBS

If $LDSTATIC is passed in (it’s usually either empty or "-static")
it’s folded into LDFLAGS (appended). I’m sure there’s a reason why
CPPFLAGS comes after CFLAGS here, but unless user errors are made
this should not matter.

Note that CPPFLAGS may *correctly* contain surprising (i.e. not -I,
-D, -U) flags, such as -Wdate-time which *is* a preprocessor option.

Having ported things to BSD ports (including autotools/libtool itself
to a BSD) as well as embedded buildsystems (multiple of them) I am
fully aware how difficult a task this is for GNU autotools. That’s why
I’m merely proposing this as a “please think about this”.

>> sketched above.  (I notice other examples of this, such as the way it
>> maps c[1-9][0-9] to clang with some option, if clang is detected;
>
>that's because clang's c89/c99 wrappers are broken (especially on MacOS)
>to the point that they've become unusable.  (I test-compile with c89,

Might be useful to replace this with a compile/link-time test for the
brokenness and failing instead (ofc with a suitable message) so the user
knows about it and can fix that, also for other uses of the compiler.

bye,
//mirabilos (fitting .sig this time ☺)
-- 
11:56⎜«liwakura:#!/bin/mksh» also, i wanted to add mksh to my own distro │
i was disappointed that there is no makefile │ but somehow the Build.sh is
the least painful built system i've ever seen │ honours CC, {CPP,C,LD}FLAGS
properly │ looks cleary like done by someone who knows what they are doing



reply via email to

[Prev in Thread] Current Thread [Next in Thread]