[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[patches] cross-rpcgen
- To: patches@xxxxxxxxxx
- Subject: [patches] cross-rpcgen
- From: Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
- Date: Fri, 25 Apr 2008 13:19:35 +0400
Hello,
Here is patch to cross-compile rpcgen when building EGLIBC. OK to apply
to trunk and 2_8 branch?
Thanks,
Maxim
2008-04-25 Maxim Kuvyrkov <maxim@xxxxxxxxxxxxxxxx>
* sunrpc/Makefile: Make librpcsvc.a built when cross-building.
Build cross-rpcgen for $build when cross-building.
* sunrpc/proto.h: Define stuff for cross-building.
Index: sunrpc/proto.h
===================================================================
--- sunrpc/proto.h (revision 6046)
+++ sunrpc/proto.h (working copy)
@@ -50,3 +50,24 @@ void crash(void) __attribute__ ((noretur
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 _CROSS_RPCGEN_
+
+/* Rather then defining _GNU_SOURCE before including $build's <string.h>
+ we just declare stpcpy here. */
+extern char *stpcpy (char *, const char *);
+
+/* Use $build's i18n support as we can't use $host's. */
+#define _(X) (gettext (X))
+
+/* rpcgen sources check for __GNU_LIBRARY__ to tweak for GLIBC code
+ that rpcgen generates. The proper fix would be to rename all those checks
+ to something like '#if defined(TWEAK_FOR_GLIBC) || 1'. */
+#ifndef __GNU_LIBRARY__
+#define __GNU_LIBRARY__
+#endif
+
+#endif
Index: sunrpc/Makefile
===================================================================
--- sunrpc/Makefile (revision 6046)
+++ sunrpc/Makefile (working copy)
@@ -105,9 +105,7 @@ otherlibs += $(nssobjdir)/libnss_files.a
$(resolvobjdir)/libresolv.a
endif
-ifeq (no,$(cross-compiling))
ifneq (yes,$(install-bootstrap-headers))
-# We can only build this library if we can run the rpcgen we build.
headers += $(rpcsvc:%.x=rpcsvc/%.h)
extra-libs-$(OPTION_EGLIBC_SUNRPC) += librpcsvc
# Make it in `others' pass, not `lib' pass.
@@ -116,7 +114,6 @@ librpcsvc-routines = $(rpcsvc:%.x=x%)
librpcsvc-inhibit-o = .os # Build no shared rpcsvc library.
omit-deps = $(librpcsvc-routines)
endif
-endif
CFLAGS-xbootparam_prot.c = -Wno-unused $(PIC-ccflag)
CFLAGS-xnlm_prot.c = -Wno-unused $(PIC-ccflag)
@@ -146,13 +143,30 @@ $(objpfx)rpcgen: $(addprefix $(objpfx),$
$(addprefix $(csu-objpfx),start.o) $(+preinit) $(+postinit)
$(+link)
+$(addprefix $(objpfx)cross-,$(rpcgen-objs)): $(objpfx)cross-%.o: %.c
+ gcc $< -c -D_RPC_THREAD_SAFE_ -D_CROSS_RPCGEN_ \
+ $(OUTPUT_OPTION) $(compile-mkdep-flags)
+
+$(objpfx)cross-rpcgen: $(addprefix $(objpfx)cross-,$(rpcgen-objs))
+ gcc $^ -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))
+ifeq (no,$(cross-compiling))
# Tell rpcgen where to find the C preprocessor.
rpcgen-cmd = CPP='$(CC) -E -x c-header' $(built-program-cmd) -Y ../scripts
+# Depend rpcsvc headers and sources on rpcgen.
+rpcgen-dep = $(objpfx)rpcgen
+else
+# Tell rpcgen where to find the C preprocessor.
+rpcgen-cmd = CPP='$(CC) -E -x c-header' $(objpfx)cross-rpcgen -Y ../scripts
+# Depend rpcsvc headers and sources on cross-rpcgen and rpcgen (to trigger
+# its build).
+rpcgen-dep = $(objpfx)rpcgen $(objpfx)cross-rpcgen
+endif
# Install the rpc data base file.
$(inst_sysconfdir)/rpc: etc.rpc $(+force)
@@ -163,7 +177,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 $(rpcgen-dep)
$(make-target-directory)
-@rm -f ${@:stmp=T} $@
$(rpcgen-cmd) -h $< -o ${@:stmp=T}
@@ -173,7 +187,7 @@ $(objpfx)rpcsvc/%.stmp: rpcsvc/%.x $(obj
# 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 $(rpcgen-dep)
-@rm -f ${@:stmp=T} $@
$(rpcgen-cmd) -c $< -o ${@:stmp=T}
$(move-if-change) $(@:stmp=T) $(@:stmp=c)