Re: awk in the makefile

From: Henrik Nordstrom <hno@dont-contact.us>
Date: Sun, 04 Mar 2001 10:17:54 +0100

Hmm... You should have the same problem on the perl scripts also then...

and no, it is not a pipe, only redirection.

To cut down on the number of tools used, perhaps this script
should be converted to perl? Or should perhaps the perl scripts be
converted to awk?

perl conversion of cf_gen_defines attached.

/Henrik

Robert Collins wrote:
>
> Is there some reason why awk is called with a pipe from and to, rather
> than the input on the command line and an output pipe?
>
> ie why do we use
> awk -f $(srcdir)/cf_gen_defines <$(srcdir)/cf.data.pre >cf_gen_defines.h
> rather than
> awk -f $(srcdir)/cf_gen_defines $(srcdir)/cf.data.pre >cf_gen_defines.h
>
> I ask because the above can cause problems building on cygwin when
> cf.data.pre is in DOS style (CRLF at eol). And that will happen if
> someone edits cf.data.pre with a windows editor.
>
> by default pipes on cygwin are binary in nature - no CRLF translation
> occurs (for fairly obvious reasons :] ). If we can change the awk
> command to the second syntax above, the problem goes away because awk
> opens cf.data.pre in textmode, so the \r's are filtered. Otherwise we
> get \r's in the variables in the cf_defines.h file.
>
> Rob

%option = (
    'DELAY_POOLS' => '--enable-delaypools',
    'HEAP_REPLACEMENT' => '--enable-heap-replacement',
    'HTTP_VIOLATIONS' => '--enable-http-violations',
    'SQUID_SNMP' => '--enable-snmp',
    'USE_CACHE_DIGESTS' => '--enable-cache-digests',
    'USE_DNSSERVERS' => '--disable-internal-dns',
    '!USE_DNSSERVERS' => '--enable-internal-dns',
    'USE_HTCP' => '--enable-htcp',
    'USE_ICMP' => '--enable-icmp',
    'USE_IDENT' => '--enable-ident-lookups',
    'USE_USERAGENT_LOG' => '--enable-useragent-log',
    'USE_WCCP' => '--enable-wccp',
    'USE_UNLINKD' => '--enable-unlinkd',
    'USE_REFERER_LOG' => '--enable-referer-log',
);

# Scan for other IFDEF / IFNDEF defines
while (<>) {
    ($junk,$define) = split(' ', $_, 9999);
    if (/^IFDEF:/) {
        if (!defined $option{$define}) {
            $option{$define} = '-D' . $define;
        }
    }
}

# Generate output

# header
print <<EOF;
/* Generated automatically from cf.data.pre
 * DO NOT EDIT
 */

struct {
  char *name;
  char *enable;
  int defined;
} defines[] = {
EOF

# defines
foreach $define (sort keys %option) {
    print <<EOF;
    {"$define", "$option{$define}",
#if $define
        1
#else
        0
#endif
    },
EOF
}

# trailer
print <<EOF;
    {(void *)0L, (void *)0L, 0}
};
EOF
Received on Sun Mar 04 2001 - 02:18:41 MST

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:13:36 MST