summaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorKaleb S KEITHLEY <kkeithle@redhat.com>2016-04-26 17:04:04 -0400
committerNiels de Vos <ndevos@redhat.com>2016-09-18 09:34:37 -0700
commite38dff5b4e0f0a25db664810fc3617eac44673ce (patch)
tree5f8f8d62051c145c271bf76c55bac41f116c0a9c /build-aux
parent09ce988ad6d8e0576f1fc23abf71b43ac4b7514e (diff)
build: out-of-tree builds generates files in the wrong directory
And minor cleanup of a few of the Makefile.am files while we're at it. Rewrite the make rules to do what xdrgen does. Now we can get rid of xdrgen. Note 1. netbsd6's sed doesn't do -i. Why are we still running smoke tests on netbsd6 and not netbsd7? We barely support netbsd7 as it is. Note 2. Why is/was libgfxdr.so (.../rpc/xdr/src/...) linked with libglusterfs? A cut-and-paste mistake? It has no references to symbols in libglusterfs. Note3. "/#ifndef\|#define\|#endif/" (note the '\'s) is a _basic_ regex that matches the same lines as the _extended_ regex "/#(ifndef|define|endif)/". To match the extended regex sed needs to be run with -r on Linux; with -E on *BSD. However NetBSD's and FreeBSD's sed helpfully also provide -r for compatibility. Using a basic regex avoids having to use a kludge in order to run sed with the correct option on OS X. Note 4. Not copying the bit of xdrgen that inserts copyright/license boilerplate. AFAIK it's silly to pretend that machine generated files like these can be copyrighted or need license boilerplate. The XDR source files have their own copyright and license; and their copyrights are bound to be more up to date than old boilerplate inserted by a script. From what I've seen of other Open Source projects -- e.g. gcc and its C parser files generated by yacc and lex -- IIRC they don't bother to add copyright/license boilerplate to their generated files. It appears that it's a long-standing feature of make (SysV, BSD, gnu) for out-of-tree builds to helpfully pretend that the source files it can find in the VPATH "exist" as if they are in the $cwd. rpcgen doesn't work well in this situation and generates files with "bad" #include directives. E.g. if you `rpcgen ../../../../$srcdir/rpc/xdr/src/glusterfs3-xdr.x`, you get an #include directive in the generated .c file like this: ... #include "../../../../$srcdir/rpc/xdr/src/glusterfs3-xdr.h" ... which (obviously) results in compile errors on out-of-tree build because the (generated) header file doesn't exist at that location. Compared to `rpcgen ./glusterfs3-xdr.x` where you get: ... #include "glusterfs3-xdr.h" ... Which is what we need. We have to resort to some Stupid Make Tricks like the addition of various .PHONY targets to work around the VPATH "help". Warning: When doing an in-tree build, -I$(top_builddir)/rpc/xdr/... looks exactly like -I$(top_srcdir)/rpc/xdr/... Don't be fooled though. And don't delete the -I$(top_builddir)/rpc/xdr/... bits Change-Id: Iba6ab96b2d0a17c5a7e9f92233993b318858b62e BUG: 1330604 Signed-off-by: Kaleb S KEITHLEY <kkeithle@redhat.com> Reviewed-on: http://review.gluster.org/14085 Tested-by: Niels de Vos <ndevos@redhat.com> Smoke: Gluster Build System <jenkins@build.gluster.org> NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org> CentOS-regression: Gluster Build System <jenkins@build.gluster.org> Reviewed-by: Niels de Vos <ndevos@redhat.com>
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/xdrgen105
1 files changed, 0 insertions, 105 deletions
diff --git a/build-aux/xdrgen b/build-aux/xdrgen
deleted file mode 100755
index 010df65..0000000
--- a/build-aux/xdrgen
+++ /dev/null
@@ -1,105 +0,0 @@
-#!/bin/sh
-
-# error out if an error occurs
-set -e
-
-append_licence_header ()
-{
- local src_file=$1;
- local dst_file=$2;
-
- cat >$dst_file <<EOF
-/*
- Copyright (c) 2007-2016 Red Hat, Inc. <http://www.redhat.com>
- This file is part of GlusterFS.
-
- This file is licensed to you under your choice of the GNU Lesser
- General Public License, version 3 or any later version (LGPLv3 or
- later), or the GNU General Public License, version 2 (GPLv2), in all
- cases as published by the Free Software Foundation.
-*/
-
-#include "compat.h"
-
-#if defined(__GNUC__)
-#if __GNUC__ >= 4
-#if !defined(__clang__)
-#if !defined(__NetBSD__)
-#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
-#pragma GCC diagnostic ignored "-Wunused-variable"
-#endif
-#else
-#pragma clang diagnostic ignored "-Wunused-variable"
-#pragma clang diagnostic ignored "-Wunused-value"
-#endif
-#endif
-#endif
-
-EOF
-
- cat $src_file >> $dst_file;
-
-}
-
-gen_sources ()
-{
- local xfile="$1";
-
- local cfile="${1%.x}.c";
- local hfile="${1%.x}.h";
-
- local tmp_cfile="$1.c.tmp";
- local tmp_hfile="$1.h.tmp";
-
- rm -f $cfile;
- rpcgen -c -o $cfile $xfile;
- append_licence_header $cfile $tmp_cfile;
- mv $tmp_cfile $cfile;
- # remove unwanted temporary files (if any)
- rm -f $tmp_cfile;
- echo "Generated $cfile"
- return
-}
-
-gen_headers ()
-{
- local xfile="$1";
-
- local cfile="${1%.x}.c";
- local hfile="${1%.x}.h";
-
- local tmp_cfile="$1.c.tmp";
- local tmp_hfile="$1.h.tmp";
-
- # no need for a temporary file here as there are no changes from glusterfs
- rm -f $hfile;
- rpcgen -h -o $hfile $xfile;
- # the '#ifdef' part of file should be fixed
- sed -r -e '/#(ifdef|ifndef|define)/s/-/_/g' $hfile > ${hfile}.new && mv ${hfile}.new $hfile;
- # Gen header to temp file and append generated file
- append_licence_header $hfile $tmp_hfile;
- # now move the destination file to actual original file
- mv $tmp_hfile $hfile;
- rm -f $tmp_hfile;
- echo "Generated $hfile";
- return
-}
-
-main ()
-{
- if [ $# -ne 2 ]; then
- echo "wrong number of arguments given"
- echo " $0 [header|source] <XDR-definition-file>.x"
- exit 1;
- fi
-
- if [ $1 = "header" ]; then
- gen_headers $2
- fi
-
- if [ $1 = "source" ]; then
- gen_sources $2
- fi
-}
-
-main "$@";