[libvirt] GNU awk vs BSD awk?

Eric Blake eblake at redhat.com
Thu Dec 2 17:29:16 UTC 2010


On 12/01/2010 09:08 PM, Justin Clift wrote:
> Hi Eric,
> 
> One of the OSX Homebrew guys, CC'd, has asked (casually) whether our dependency on GNU awk is very deeply ingrained, or if we could be convinced to allow usage of other make's instead (ie BSD).

GNU awk, or GNU make?  There's a difference :)

With regards to make, libvirt is firmly in the camp of GNU make and
nothing else.  We use too many extensions specific to gmake that just
aren't present in other implementations, and it is too difficult to
figure out how to rewrite those in the lowest-common-denominator of
POSIX make syntax.  (Side note - the Austin Group, which is in charge of
updating the POSIX standard, is currently reviewing several proposals to
increase the lowest-common-denominator, such as by standardizing
something similar to gmake's $(shell) or BSD makes != assignment, but
that is a lengthy process, and you can't expect it to make a difference
overnight).

With regards to awk, libvirt should be able to get by with any
POSIX-compliant awk; if you find a counter-example where things are
broken while using BSD awk, it should be relatively easy to patch things
to get it working again.  Note, however, that there are multiple awk
flavors out there; oawk (called awk on some systems) is NOT
posix-compliant, and is inadequate for libvirt's needs; while mawk,
nawk, BSD awk, and gawk should all be interchangeable given a script
that sticks only to POSIX features.  In fact, autoconf requires a decent
awk just for running ./configure, and substitutes $AWK appropriately.  I
see several uses where libvirt is hard-coded to awk (for example,
tools/virt-pki-validate), but most of those are portable even to oawk,
because they avoid POSIX features that were not present in older awk;
but I have not audited all of libvirt's awk usages.

http://www.gnu.org/software/autoconf/manual/autoconf.html#index-g_t_0040command_007bawk_007d-1731
gives a good overview of features to look for when auditing awk scripts
for POSIX vs. oawk compliance, as well as some common bugs in
almost-POSIX-compliant implementations and how to work around those bugs.

-- 
Eric Blake   eblake at redhat.com    +1-801-349-2682
Libvirt virtualization library http://libvirt.org

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 619 bytes
Desc: OpenPGP digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20101202/9a660e6d/attachment-0001.sig>


More information about the libvir-list mailing list