summaryrefslogtreecommitdiffstats
path: root/build-aux
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2014-04-28 14:18:50 +0000
committerJeff Darcy <jdarcy@redhat.com>2014-04-28 14:18:50 +0000
commite139b4d0ba2286c0d4d44ba81260c2b287016019 (patch)
tree0a21f0761528e0f79da0a9f67106eb128ace0cf7 /build-aux
parent73b60c87ca7f62517a8466431f5a8cf167589c8c (diff)
parentf2bac9f9d5b9956969ddd25a54bc636b82f6923e (diff)
Merge branch 'upstream'HEADmaster
Conflicts: rpc/xdr/src/glusterfs3-xdr.c rpc/xdr/src/glusterfs3-xdr.h xlators/features/changelog/src/Makefile.am xlators/features/changelog/src/changelog-helpers.h xlators/features/changelog/src/changelog.c xlators/mgmt/glusterd/src/glusterd-sm.c Change-Id: I9972a5e6184503477eb77a8b56c50a4db4eec3e2
Diffstat (limited to 'build-aux')
-rwxr-xr-xbuild-aux/xdrgen97
1 files changed, 97 insertions, 0 deletions
diff --git a/build-aux/xdrgen b/build-aux/xdrgen
new file mode 100755
index 000000000..e826111b9
--- /dev/null
+++ b/build-aux/xdrgen
@@ -0,0 +1,97 @@
+#!/bin/bash
+
+append_licence_header ()
+{
+ local src_file=$1;
+ local dst_file=$2;
+
+ cat >$dst_file <<EOF
+/*
+ Copyright (c) 2007-2014 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"
+#include "xdr-common.h"
+#include "xdr-nfs3.h"
+
+#if defined(__GNUC__)
+#if __GNUC__ >= 4
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+#pragma GCC diagnostic ignored "-Wunused-variable"
+#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 -i -e 's/-/_/g' $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 "$@";