]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
Better(?) detection for 64bit kernel / 32bit userspace.
authorMartin Josefsson <gandalf@wlug.westbo.se>
Wed, 26 May 2004 15:46:27 +0000 (15:46 +0000)
committerMartin Josefsson <gandalf@wlug.westbo.se>
Wed, 26 May 2004 15:46:27 +0000 (15:46 +0000)
Add some ld-flags for sparc64.

Makefile
Rules.make

index dd4c82b5524d35cdaf2163ae885b9fd2fcbb5fed..2166923854ea76222a78d2cbf27c20c7a875e36d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -38,21 +38,6 @@ ifdef NO_SHARED_LIBS
 CFLAGS += -DNO_SHARED_LIBS=1
 endif
 
-ifndef NO_SHARED_LIBS
-DEPFILES = $(SHARED_LIBS:%.so=%.d)
-SH_CFLAGS:=$(CFLAGS) -fPIC
-STATIC_LIBS  =
-STATIC6_LIBS =
-LDFLAGS      = -rdynamic
-LDLIBS       = -ldl -lnsl
-else
-DEPFILES = $(EXT_OBJS:%.o=%.d)
-STATIC_LIBS  = extensions/libext.a
-STATIC6_LIBS = extensions/libext6.a
-LDFLAGS      = -static
-LDLIBS       =
-endif
-
 EXTRAS+=iptables iptables.o iptables.8
 EXTRA_INSTALLS+=$(DESTDIR)$(BINDIR)/iptables $(DESTDIR)$(MANDIR)/man8/iptables.8
 
@@ -69,20 +54,56 @@ endif
 
 # Sparc64 hack
 ifeq ($(shell uname -m),sparc64)
-# The kernel is 64-bit, even though userspace is 32.
-CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+       POINTERTEST:=1
+       32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__sparcv9) && !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
+       ifdef 32bituser
+               # The kernel is 64-bit, even though userspace is 32.
+               CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+       else
+               EXT_LDFLAGS=-m elf64_sparc
+       endif
+endif
+
+# Alpha only has 64bit userspace and fails the test below
+ifeq ($(shell uname -m), alpha)
+       POINTERTEST:=1
 endif
 
-# HPPA hack
-ifeq ($(shell uname -m),parisc64)
-# The kernel is 64-bit, even though userspace is 32.
-CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+# Generic test if arch wasn't found above
+ifneq ($(POINTERTEST),1)
+       # Try to determine if kernel is 64bit and we are compiling for 32bit
+       ifeq ($(shell [ -a $(KERNEL_DIR)/include/asm ] && echo YES), YES)
+               64bitkernel := $(shell echo -e "\#include <asm/types.h>\n\#if BITS_PER_LONG == 64\nkernel_is_64bits\n\#endif" | $(CC) $(CFLAGS) -D__KERNEL__ -E - | grep kernel_is_64bits)
+               ifdef 64bitkernel
+                       32bituser := $(shell echo -e "\#include <stdio.h>\n\#if !defined(__arch64__) && !defined(_LP64)\nuserspace_is_32bit\n\#endif" | $(CC) $(CFLAGS) -E - | grep userspace_is_32bit)
+                       ifdef 32bituser
+                               CFLAGS+=-DIPT_MIN_ALIGN=8 -DKERNEL_64_USERSPACE_32
+                       endif
+               endif
+       else
+               CFLAGS+=-D_UNKNOWN_KERNEL_POINTER_SIZE
+       endif
 endif
 
 ifndef IPT_LIBDIR
 IPT_LIBDIR:=$(LIBDIR)/iptables
 endif
 
+ifndef NO_SHARED_LIBS
+DEPFILES = $(SHARED_LIBS:%.so=%.d)
+SH_CFLAGS:=$(CFLAGS) -fPIC
+STATIC_LIBS  =
+STATIC6_LIBS =
+LDFLAGS      = -rdynamic
+LDLIBS       = -ldl -lnsl
+else
+DEPFILES = $(EXT_OBJS:%.o=%.d)
+STATIC_LIBS  = extensions/libext.a
+STATIC6_LIBS = extensions/libext6.a
+LDFLAGS      = -static
+LDLIBS       =
+endif
+
 .PHONY: default
 default: print-extensions all
 
index 8c04caf229340156340bc162a6cce1b85e9bda66..c0c50103834c40964a194f24588b20301f55761c 100644 (file)
@@ -31,7 +31,7 @@ $(SHARED_LIBS:%.so=%.d): %.d: %.c
            sed -e 's@^.*\.o:@$*.d $*_sh.o:@' > $@
 
 $(SHARED_LIBS): %.so : %_sh.o
-       $(LD) -shared -o $@ $<
+       $(LD) -shared $(EXT_LDFLAGS) -o $@ $<
 
 %_sh.o : %.c
        $(CC) $(SH_CFLAGS) -o $@ -c $<