linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] nfs-utils: Run rpcgen using the cpp found by configure.
@ 2015-04-21 17:31 Calvin Walton
  2015-05-06 20:23 ` Steve Dickson
  0 siblings, 1 reply; 3+ messages in thread
From: Calvin Walton @ 2015-04-21 17:31 UTC (permalink / raw)
  To: linux-nfs; +Cc: Calvin Walton

rpcgen normally runs with a hardcoded cpp path of e.g. /lib/cpp,
but not all Linux distributions install a cpp there.

Grab a trick from glibc, and run rpcgen with a cpp-path pointing at
a script; the script then runs the cpp specified in the CPP
environment variable - which we set to $CC -E with appropriate
options.

Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
---
 support/export/Makefile.am   | 13 +++++++------
 support/nsm/Makefile.am      | 17 +++++++++--------
 tests/nsm_client/Makefile.am | 17 +++++++++--------
 tools/rpcgen/cpp             |  6 ++++++
 utils/statd/Makefile.am      | 17 +++++++++--------
 5 files changed, 40 insertions(+), 30 deletions(-)
 create mode 100755 tools/rpcgen/cpp

diff --git a/support/export/Makefile.am b/support/export/Makefile.am
index 1ea1539..a6de641 100644
--- a/support/export/Makefile.am
+++ b/support/export/Makefile.am
@@ -22,22 +22,23 @@ dist-hook:
 	done
 
 if CONFIG_RPCGEN
-RPCGEN		= $(top_builddir)/tools/rpcgen/rpcgen
-$(RPCGEN):
+RPCGEN_DEP = $(top_builddir)/tools/rpcgen/rpcgen
+$(RPCGEN_DEP):
 	make -C $(top_srcdir)/tools/rpcgen all
+RPCGEN = CPP='$(CC) -E -x c-header' $(RPCGEN_DEP) -Y $(top_srcdir)/tools/rpcgen
 else
-RPCGEN = @RPCGEN_PATH@
+RPCGEN = CPP='$(CC) -E -x c-header' @RPCGEN_PATH@ -Y $(top_srcdir)/tools/rpcgen
 endif
 
-$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN)
+$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -l -o $@ $<
 
-$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN)
+$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -c -o $@ $<
 
-$(GENFILES_H): %.h: %.x $(RPCGEN)
+$(GENFILES_H): %.h: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -h -o $@ $<
 	rm -f $(top_builddir)/support/include/mount.h
diff --git a/support/nsm/Makefile.am b/support/nsm/Makefile.am
index 2038e68..30fce80 100644
--- a/support/nsm/Makefile.am
+++ b/support/nsm/Makefile.am
@@ -15,26 +15,27 @@ libnsm_a_SOURCES = $(GENFILES) file.c rpc.c
 BUILT_SOURCES = $(GENFILES)
 
 if CONFIG_RPCGEN
-RPCGEN	= $(top_builddir)/tools/rpcgen/rpcgen
-$(RPCGEN):
-	make -C ../../tools/rpcgen all
+RPCGEN_DEP = $(top_builddir)/tools/rpcgen/rpcgen
+$(RPCGEN_DEP):
+	make -C $(top_srcdir)/tools/rpcgen all
+RPCGEN = CPP='$(CC) -E -x c-header' $(RPCGEN_DEP) -Y $(top_srcdir)/tools/rpcgen
 else
-RPCGEN = @RPCGEN_PATH@
+RPCGEN = CPP='$(CC) -E -x c-header' @RPCGEN_PATH@ -Y $(top_srcdir)/tools/rpcgen
 endif
 
-$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN)
+$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -l -o $@ $<
 
-$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -m -o $@ $<
 
-$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN)
+$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -c -o $@ $<
 
-$(GENFILES_H): %.h: %.x $(RPCGEN)
+$(GENFILES_H): %.h: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -h -o $@ $<
 	rm -f $(top_builddir)/support/include/sm_inter.h
diff --git a/tests/nsm_client/Makefile.am b/tests/nsm_client/Makefile.am
index a8fc131..88e1679 100644
--- a/tests/nsm_client/Makefile.am
+++ b/tests/nsm_client/Makefile.am
@@ -17,26 +17,27 @@ nsm_client_LDADD = ../../support/nfs/libnfs.a \
 		   ../../support/nsm/libnsm.a $(LIBCAP) $(LIBTIRPC)
 
 if CONFIG_RPCGEN
-RPCGEN	= $(top_builddir)/tools/rpcgen/rpcgen
-$(RPCGEN):
-	make -C ../../tools/rpcgen all
+RPCGEN_DEP = $(top_builddir)/tools/rpcgen/rpcgen
+$(RPCGEN_DEP):
+	make -C $(top_srcdir)/tools/rpcgen all
+RPCGEN = CPP='$(CC) -E -x c-header' $(RPCGEN_DEP) -Y $(top_srcdir)/tools/rpcgen
 else
-RPCGEN = @RPCGEN_PATH@
+RPCGEN = CPP='$(CC) -E -x c-header' @RPCGEN_PATH@ -Y $(top_srcdir)/tools/rpcgen
 endif
 
-$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN)
+$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -l -o $@ $<
 
-$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -m -o $@ $<
 
-$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN)
+$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -c -o $@ $<
 
-$(GENFILES_H): %.h: %.x $(RPCGEN)
+$(GENFILES_H): %.h: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -h -o $@ $<
 
diff --git a/tools/rpcgen/cpp b/tools/rpcgen/cpp
new file mode 100755
index 0000000..73a5522
--- /dev/null
+++ b/tools/rpcgen/cpp
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# This script is use solely by rpcgen when run during the build.
+# It allows using CPP from the environment rather than a hardcoded path.
+
+exec ${CPP} "$@"
diff --git a/utils/statd/Makefile.am b/utils/statd/Makefile.am
index 152b680..b2e13d7 100644
--- a/utils/statd/Makefile.am
+++ b/utils/statd/Makefile.am
@@ -23,26 +23,27 @@ sm_notify_LDADD = ../../support/nsm/libnsm.a \
 EXTRA_DIST = sim_sm_inter.x $(man8_MANS) simulate.c
 
 if CONFIG_RPCGEN
-RPCGEN	= $(top_builddir)/tools/rpcgen/rpcgen
-$(RPCGEN):
-	make -C ../../tools/rpcgen all
+RPCGEN_DEP = $(top_builddir)/tools/rpcgen/rpcgen
+$(RPCGEN_DEP):
+	make -C $(top_srcdir)/tools/rpcgen all
+RPCGEN = CPP='$(CC) -E -x c-header' $(RPCGEN_DEP) -Y $(top_srcdir)/tools/rpcgen
 else
-RPCGEN = @RPCGEN_PATH@
+RPCGEN = CPP='$(CC) -E -x c-header' @RPCGEN_PATH@ -Y $(top_srcdir)/tools/rpcgen
 endif
 
-$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN)
+$(GENFILES_CLNT): %_clnt.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -l -o $@ $<
 
-$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN)
+$(GENFILES_SVC): %_svc.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -m -o $@ $<
 
-$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN)
+$(GENFILES_XDR): %_xdr.c: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -c -o $@ $<
 
-$(GENFILES_H): %.h: %.x $(RPCGEN)
+$(GENFILES_H): %.h: %.x $(RPCGEN_DEP)
 	test -f $@ && rm -rf $@ || true
 	$(RPCGEN) -h -o $@ $<
 
-- 
2.3.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nfs-utils: Run rpcgen using the cpp found by configure.
  2015-04-21 17:31 [PATCH v2] nfs-utils: Run rpcgen using the cpp found by configure Calvin Walton
@ 2015-05-06 20:23 ` Steve Dickson
  2015-05-06 20:34   ` Calvin Walton
  0 siblings, 1 reply; 3+ messages in thread
From: Steve Dickson @ 2015-05-06 20:23 UTC (permalink / raw)
  To: Calvin Walton, linux-nfs



On 04/21/2015 01:31 PM, Calvin Walton wrote:
> rpcgen normally runs with a hardcoded cpp path of e.g. /lib/cpp,
> but not all Linux distributions install a cpp there.
> 
> Grab a trick from glibc, and run rpcgen with a cpp-path pointing at
> a script; the script then runs the cpp specified in the CPP
> environment variable - which we set to $CC -E with appropriate
> options.
> 
> Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
I'm getting the following errors when I apply this patch:

test -f mount.h && rm -rf mount.h || true
CPP='gcc -E -x c-header' /usr/bin/rpcgen -Y ../../tools/rpcgen -l -o mount_clnt.c mount.x
CPP='gcc -E -x c-header' /usr/bin/rpcgen -Y ../../tools/rpcgen -c -o mount_xdr.c mount.x
CPP='gcc -E -x c-header' /usr/bin/rpcgen -Y ../../tools/rpcgen -h -o mount.h mount.x
execvp: Permission denied
/usr/bin/rpcgen: C preprocessor failed with exit code 1
make[2]: *** [mount_clnt.c] Error 1
make[2]: *** Waiting for unfinished jobs....
Makefile:693: recipe for target 'mount_clnt.c' failed
execvp: Permission denied
execvp: Permission denied
/usr/bin/rpcgen: C preprocessor failed with exit code 1
make[2]: *** [mount.h] Error 1
Makefile:701: recipe for target 'mount.h' failed
/usr/bin/rpcgen: C preprocessor failed with exit code 1
make[2]: *** [mount_xdr.c] Error 1
Makefile:697: recipe for target 'mount_xdr.c' failed
make[2]: Leaving directory '/home/src/up/nfs-utils/support/export'
make[1]: *** [all-recursive] Error 1
Makefile:420: recipe for target 'all-recursive' failed
make[1]: Leaving directory '/home/src/up/nfs-utils/support'
make: *** [all-recursive] Error 1
Makefile:463: recipe for target 'all-recursive' failed

steved.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] nfs-utils: Run rpcgen using the cpp found by configure.
  2015-05-06 20:23 ` Steve Dickson
@ 2015-05-06 20:34   ` Calvin Walton
  0 siblings, 0 replies; 3+ messages in thread
From: Calvin Walton @ 2015-05-06 20:34 UTC (permalink / raw)
  To: Steve Dickson; +Cc: linux-nfs

On Wed, 2015-05-06 at 16:23 -0400, Steve Dickson wrote:
> On 04/21/2015 01:31 PM, Calvin Walton wrote:
> > rpcgen normally runs with a hardcoded cpp path of e.g. /lib/cpp,
> > but not all Linux distributions install a cpp there.
> > 
> > Grab a trick from glibc, and run rpcgen with a cpp-path pointing at
> > a script; the script then runs the cpp specified in the CPP
> > environment variable - which we set to $CC -E with appropriate
> > options.
> > 
> > Signed-off-by: Calvin Walton <calvin.walton@kepstin.ca>
> I'm getting the following errors when I apply this patch:
> 
> test -f mount.h && rm -rf mount.h || true
> CPP='gcc -E -x c-header' /usr/bin/rpcgen -Y ../../tools/rpcgen -l -o 
> mount_clnt.c mount.x
> execvp: Permission denied
> /usr/bin/rpcgen: C preprocessor failed with exit code 1

This probably means that the script at tools/rpcgen/cpp failed to get 
the executable permission added during patch application. I'm not sure 
why this happens; the patch header includes "new file mode 100755" as 
git should be expecting.

Doing a chmod +x tools/rpcgen/cpp after applying the patch should fix 
the issue.

-- 
Calvin Walton <calvin.walton@kepstin.ca>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-06 20:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-21 17:31 [PATCH v2] nfs-utils: Run rpcgen using the cpp found by configure Calvin Walton
2015-05-06 20:23 ` Steve Dickson
2015-05-06 20:34   ` Calvin Walton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).