iproute: Support cross-compiling.
Subsystems (3)
RFC 1/1 iproute: Support cross-compiling.
From: Ben Greear <[email protected]>
This lets users use their own compiler instead of
hard-coding to use gcc.
Also adds tests to disable some things that were not supported in my ARM cross-compile toolchain.
---
:100644 100644 c6e4943... 3b00076... M Makefile
:100755 100755 f5c3d40... 680fdcb... M configure
:100644 100644 8d03993... 5c91e18... M ip/Makefile
:100644 100644 e41a598... 773f7cb... M ip/ipnetns.c
:100644 100644 8c25381... d04358d... M misc/Makefile
Makefile | 2 +- configure | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- ip/Makefile | 8 +++++ ip/ipnetns.c | 17 +++++++++++ misc/Makefile | 5 +++ 5 files changed, 114 insertions(+), 6 deletions(-)
Makefile +1 -1
@@ -27,7 +27,7 @@ ADDLIB+=dnet_ntop.o dnet_pton.o #options for ipx ADDLIB+=ipx_ntop.o ipx_pton.o -CC = gcc +CC ?= gcc HOSTCC = gcc CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall CFLAGS = $(CCOPTS) -I../include $(DEFINES)
configure +83 -5
133 lines not on this page · raw message
ip/Makefile +8 -0
@@ -13,6 +13,14 @@ ifeq ($(IP_CONFIG_SETNS),y) CFLAGS += -DHAVE_SETNS endif +ifeq ($(IP_CONFIG_DISABLE_INOTIFY),y) + CFLAGS += -DDISABLE_INOTIFY +endif + +ifeq ($(IP_CONFIG_DISABLE_UNSHARE),y) + CFLAGS += -DCONFIG_IP_NO_UNSHARE +endif + ALLOBJ=$(IPOBJ) $(RTMONOBJ) SCRIPTS=ifcfg rtpr routel routef TARGETS=ip rtmon
ip/ipnetns.c +17 -0
@@ -2,7 +2,9 @@#include <sys/types.h> #include <sys/stat.h> #include <sys/wait.h> +#ifndef DISABLE_INOTIFY #include <sys/inotify.h> +#endif #include <sys/mount.h> #include <sys/param.h> #include <sys/syscall.h>
@@ -118,6 +120,10 @@ static void bind_etc(const char *name)static int netns_exec (int argc,char **argv) { +#ifdef CONFIG_IP_NO_UNSHARE +fprintf (stderr,"No unshare on this platform, cannod do netns_exec\n" ); +return -1 ; +#else /* Setup the proper environment for apps that are not netns * aware, and execute a program in that environment. */
@@ -169,6 +175,7 @@ static int netns_exec(int argc, char **argv)fprintf (stderr,"exec of %s failed: %s\n" , cmd,strerror (errno));exit (-1 ); +#endif }static int netns_delete (int argc,char **argv)
@@ -194,6 +201,10 @@ static int netns_delete(int argc, char **argv)static int netns_add (int argc,char **argv) { +#ifdef CONFIG_IP_NO_UNSHARE +fprintf (stderr,"No unshare on this platform, cannod do netns_add\n" ); +return -1 ; +#else /* This function creates a new network namespace and * a new mount namespace and bind them into a well known * location in the filesystem based on the name provided.
@@ -242,11 +253,16 @@ out_delete:netns_delete (argc, argv);exit (-1 );return -1 ; +#endif }static int netns_monitor (int argc,char **argv) { +#ifdef DISABLE_INOTIFY +fprintf (stderr,"inotify not supported (compiled out)\n" ); +return -1 ; +#else char buf[4096 ];struct inotify_event *event;int fd;
@@ -278,6 +294,7 @@ static int netns_monitor(int argc, char **argv) } }return 0 ; +#endif }int do_netns (int argc,char **argv)
misc/Makefile +5 -0
@@ -18,8 +18,13 @@ ifstat: ifstat.c rtacct: rtacct.c $(CC) $(CFLAGS) $(LDFLAGS) -o rtacct rtacct.c $(LIBNETLINK) -lm +ifeq ($(IP_CONFIG_DISABLE_DB185),y) +arpd: + @echo "Cannot build arpd on this system, no db_185.h file." +else arpd: arpd.c $(CC) $(CFLAGS) -I$(DBM_INCLUDE) $(LDFLAGS) -o arpd arpd.c $(LIBNETLINK) -ldb -lpthread +endif ssfilter.c: ssfilter.y bison ssfilter.y -o ssfilter.c
Signature · 1 line
1.7.3.4
Quoted 9 lines · On Tue, 15 Nov 2011 17:04:42 -0800 [email protected] wrote:
From: Ben Greear <[email protected]>
This lets users use their own compiler instead of
hard-coding to use gcc.Also adds tests to disable some things that were not supported in my ARM cross-compile toolchain.
Signed-off-by Ben Greear <[email protected]>
Can't you do this by setting up the compile environment better? I would rather have the tools work with all features and handle errors from kernel rather than neutering it.
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Tue, 15 Nov 2011 17:04:42 -0800 [email protected] wrote:
From: Ben Greear<[email protected]>
This lets users use their own compiler instead of
hard-coding to use gcc.
Quoted 8 lines
Quoted 4 lines
Also adds tests to disable some things that were not supported in my ARM cross-compile toolchain.
Signed-off-by Ben Greear<[email protected]>Can't you do this by setting up the compile environment better? I would rather have the tools work with all features and handle errors from kernel rather than neutering it.
At the least, the parts that let you use your own CC could be split out and applied?
I've no interest in trying to fix whatever is wrong with my tool chain..just not worth the effort since I don't need network namespaces and I don't need the arp daemon.
Thanks,
Ben
Signature · 2 lines
Ben Greear <[email protected]> Candela Technologies Inc http://www.candelatech.com
Quoted 8 lines · Stephen Hemminger
Quoted 5 lines · On Tue, 15 Nov 2011 17:04:42 -0800 [email protected] wrote:
From: Ben Greear <[email protected]>
This lets users use their own compiler instead of
hard-coding to use gcc.
Quoted 8 lines
Quoted 4 lines
Also adds tests to disable some things that were not supported in my ARM cross-compile toolchain.
Signed-off-by Ben Greear <[email protected]>Can't you do this by setting up the compile environment better? I would rather have the tools work with all features and handle errors from kernel rather than neutering it.
I have roughly same errors when compiling on RHEL4
glibc-2.3.4-2.36 doesnt contain unshare() call, but my dev kernel certainly have it ;)
Quoted 27 lines · On 11/16/2011 01:04 AM, [email protected] wrote:
From: Ben Greear <[email protected]>
This lets users use their own compiler instead of
hard-coding to use gcc.Also adds tests to disable some things that were not supported in my ARM cross-compile toolchain.
Signed-off-by Ben Greear <[email protected]>---
:100644 100644 c6e4943... 3b00076... MMakefile
:100755 100755 f5c3d40... 680fdcb... M configure
:100644 100644 8d03993... 5c91e18... M ip/Makefile
:100644 100644 e41a598... 773f7cb... Mip/ipnetns.c
:100644 100644 8c25381... d04358d... M misc/MakefileMakefile | 2 +- configure | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++--- ip/Makefile | 8 +++++ ip/ipnetns.c | 17 +++++++++++ misc/Makefile | 5 +++ 5 files changed, 114 insertions(+), 6 deletions(-)Makefile +0
-0
Makefile ADDLIB+=dnet_ntop.o dnet_pton.o · line 30
Quoted 5 lines
Makefile +1
-1@@ -27,7 +27,7 @@ ADDLIB+=dnet_ntop.o dnet_pton.o #options for ipx ADDLIB+=ipx_ntop.o ipx_pton.o -CC = gcc +CC ?= gcc
Right that allows one to override at build time, supporting clang, ccache, ...
Quoted 8 lines
Makefile +0
-0HOSTCC = gcc CCOPTS = -D_GNU_SOURCE -O2 -Wstrict-prototypes -Wall CFLAGS = $(CCOPTS) -I../include $(DEFINES)configure +0
-0
configure line 9
Quoted 7 lines
configure +4
-0@@ -3,6 +3,11 @@ # INCLUDE=${1:-"$PWD/include"} +if [ "_$CC" == "_" ] +then + CC=gcc +fi
Ditto at configure time.
Note the shell idiom for this is
: ${var:="value"}
Note the leading : is required for portability. Not applicable here, but if you want to set only if unset (rather than the above which also handles empty), do:
: ${var="value"}
cheers,
Pádraig.