john.levon(a)sun.com wrote:
# HG changeset patch
# User john.levon(a)sun.com
# Date 1230005985 28800
# Node ID 9621540df10095ea8b0cdc83cdd3d17a68509a64
# Parent 60090fd4e447795742265241b39f2759d9530514
Split out version script into multiple files
...
diff --git a/src/Makefile.am b/src/Makefile.am
...
+libvirt.syms: libvirt_public.syms $(PRIVSYMFILES)
+ rm -f $@-tmp
+ cat $(srcdir)/libvirt_public.syms >$@-tmp
+ printf "\n\n# Private symbols\n\n" >>$@-tmp
+ printf "LIBVIRT_PRIVATE_@VERSION@ {\n\n" >>$@-tmp
+ printf "global:\n\n" >>$@-tmp
+ for file in $(PRIVSYMFILES); do \
+ cat $(srcdir)/$${file} >>$@-tmp ; \
+ done
+ printf "\n\nlocal:\n*;\n\n};" >>$@-tmp
+ mv $@-tmp libvirt.syms
This all looks fine, but I'd prefer to retain the WARNING in the generated
file, so that people are less likely to modify it directly. Along the
same lines, I find that making generated files read-only often saves
me from wasting time modifying it, since I don't always see the top few
lines of a file.
Here's a proposed replacement for the above:
libvirt.syms: libvirt_public.syms $(PRIVSYMFILES)
rm -f $@-tmp $@
printf '# WARNING: generated from the following:\n# $^\n\n' >$@-tmp
cat $(srcdir)/libvirt_public.syms >>$@-tmp
printf '\n\n# Private symbols\n\n' >>$@-tmp
printf 'LIBVIRT_PRIVATE_$(VERSION) {\n\n' >>$@-tmp
printf 'global:\n\n' >>$@-tmp
for file in $(PRIVSYMFILES); do \
cat $(srcdir)/$$file >>$@-tmp; \
done
printf '\n\nlocal:\n*;\n\n};' >>$@-tmp
chmod a-w $@-tmp
mv $@-tmp libvirt.syms
I.e., unlink $@ up front,
emit the WARNING comment
use $(VERSION) rather than obsolescent @VERSION@ syntax
run chmod a-w $@-tmp just before renaming
in shell code, use single quotes unless you require double, so that
the reader doesn't have to wonder if there are expandable constructs
use $$file, rather than $${file} (less syntax)
Note that using $^ is a GNU-make'ism, but it's ok, because there are
already uses like that in this file, as well as plenty of other constructs
that are specific to GNU make.