aboutsummaryrefslogtreecommitdiff
path: root/sunrpc
diff options
context:
space:
mode:
authorMaxim Kuvyrkov <maxim@codesourcery.com>2012-05-10 17:07:45 +0000
committerJoseph Myers <joseph@codesourcery.com>2012-05-10 17:08:40 +0000
commit28e725016266de6cc18f7aef5c675c57b7a42a89 (patch)
treefaa9cfd5e7df63e7b4cfcfcab28af614f97f75c8 /sunrpc
parentc8c59454eac603f75e8e037d290e595abeda2af5 (diff)
downloadglibc-28e725016266de6cc18f7aef5c675c57b7a42a89.zip
glibc-28e725016266de6cc18f7aef5c675c57b7a42a89.tar.gz
glibc-28e725016266de6cc18f7aef5c675c57b7a42a89.tar.bz2
Build rpcgen-generated files when cross compiling.
Diffstat (limited to 'sunrpc')
-rw-r--r--sunrpc/Makefile32
-rw-r--r--sunrpc/proto.h16
2 files changed, 40 insertions, 8 deletions
diff --git a/sunrpc/Makefile b/sunrpc/Makefile
index b4548d5..e61efd0 100644
--- a/sunrpc/Makefile
+++ b/sunrpc/Makefile
@@ -97,15 +97,12 @@ ifeq ($(have-thread-library),yes)
xtests += thrsvc
endif
-ifeq (no,$(cross-compiling))
-# We can only build this library if we can run the rpcgen we build.
headers += $(rpcsvc:%.x=rpcsvc/%.h)
extra-libs := librpcsvc
extra-libs-others := librpcsvc # Make it in `others' pass, not `lib' pass.
librpcsvc-routines = $(rpcsvc:%.x=x%)
librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
omit-deps = $(librpcsvc-routines)
-endif
ifeq (yes,$(build-shared))
rpc-compat-routines = $(addprefix compat-,$(need-export-routines))
@@ -143,7 +140,9 @@ CFLAGS-pmap_rmt.c = -fexceptions
CFLAGS-clnt_perr.c = -fexceptions
CFLAGS-openchild.c = -fexceptions
-CPPFLAGS += -D_RPC_THREAD_SAFE_
+sunrpc-CPPFLAGS = -D_RPC_THREAD_SAFE_
+CPPFLAGS += $(sunrpc-CPPFLAGS)
+BUILD_CPPFLAGS += $(sunrpc-CPPFLAGS)
$(objpfx)tst-getmyaddr: $(common-objpfx)linkobj/libc.so
$(objpfx)tst-xdrmem: $(common-objpfx)linkobj/libc.so
@@ -151,13 +150,30 @@ $(objpfx)tst-xdrmem2: $(common-objpfx)linkobj/libc.so
$(objpfx)rpcgen: $(addprefix $(objpfx),$(rpcgen-objs))
+cross-rpcgen-objs := $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+extra-objs += $(cross-rpcgen-objs)
+
+# When generic makefile support for build system programs is
+# available, it should replace this code. See
+# <http://sourceware.org/bugzilla/show_bug.cgi?id=14087>.
+$(cross-rpcgen-objs): $(objpfx)cross-%.o: %.c
+ $(make-target-directory)
+ $(BUILD_CC) $($(basename $(<F))-CFLAGS) $(ALL_BUILD_CFLAGS) $< \
+ $(OUTPUT_OPTION) $(compile-mkdep-flags) -c
+
+$(objpfx)cross-rpcgen: $(cross-rpcgen-objs)
+ $(BUILD_CC) $^ $(BUILD_LDFLAGS) -o $@
+
# This makes sure -DNOT_IN_libc is passed for all these modules.
cpp-srcs-left := $(rpcgen-objs:.o=.c)
lib := nonlib
include $(patsubst %,$(..)cppflags-iterator.mk,$(cpp-srcs-left))
-# Tell rpcgen where to find the C preprocessor.
-rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-cmd) -Y ../scripts
+# How we run rpcgen to generate sources and headers in the rules below.
+# Setting CPP tells it how to run the C preprocessor correctly. Note
+# that $(built-program-file) requires that the just-built cross-rpcgen
+# binary be the second dependency listed in each rule using rpcgen-cmd.
+rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-file) -Y ../scripts
# Install the rpc data base file.
$(inst_sysconfdir)/rpc: etc.rpc $(+force)
@@ -168,7 +184,7 @@ $(inst_sysconfdir)/rpc: etc.rpc $(+force)
# relinked.
$(rpcsvc:%.x=$(objpfx)rpcsvc/%.h): $(objpfx)rpcsvc/%.h: $(objpfx)rpcsvc/%.stmp
@:
-$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+$(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
$(make-target-directory)
-@rm -f ${@:stmp=T} $@
$(rpcgen-cmd) -h $< -o ${@:stmp=T}
@@ -178,7 +194,7 @@ $(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(objpfx)rpcgen
# Generate the rpcsvc XDR functions with rpcgen.
$(rpcsvc:%.x=$(objpfx)x%.c): $(objpfx)x%.c: $(objpfx)x%.stmp
@:
-$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)rpcgen
+$(objpfx)x%.stmp: rpcsvc/%.x $(objpfx)cross-rpcgen
-@rm -f ${@:stmp=T} $@
$(rpcgen-cmd) -c $< -o ${@:stmp=T}
$(move-if-change) $(@:stmp=T) $(@:stmp=c)
diff --git a/sunrpc/proto.h b/sunrpc/proto.h
index 3e1ecd1..0ba9cd6 100644
--- a/sunrpc/proto.h
+++ b/sunrpc/proto.h
@@ -50,3 +50,19 @@ void crash(void) __attribute__ ((noreturn));
void tabify(FILE *f, int tab);
char *make_argname(const char *pname, const char *vname);
void add_type(int len, const char *type);
+
+/* This header is the last one included in all rpc_*.c files,
+ so we define stuff for cross-rpcgen here to avoid conflicts with
+ $build's C library and $host's glibc. */
+
+#ifdef IS_IN_build
+
+/* Disable translated messages when built for $build and used in
+ building glibc. */
+#define _(X) (X)
+#define textdomain(X) ((void) 0)
+
+/* This is used in the definition of PACKAGE for --version output. */
+#define _libc_intl_domainname "libc"
+
+#endif