Index: Makefile =================================================================== RCS file: /home/cvsroot/gentoo-src/portage/src/sandbox-1.1/Makefile,v retrieving revision 1.5 diff -u -p -r1.5 Makefile --- Makefile 27 Jul 2003 12:31:06 -0000 1.5 +++ Makefile 12 Nov 2003 01:17:01 -0000 @@ -15,29 +15,58 @@ CC = gcc LD = ld CFLAGS = -OBJ_DEFINES = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT +ARCH_CFLAGS = +OBJ_CFLAGS = -D_GNU_SOURCE -DPIC -fPIC -D_REENTRANT LIBS = LDFLAGS = DESTDIR = -TARGETS = libsandbox.so sandbox +HAVE_64BIT_ARCH = + +HAVE_64BIT_FS = $(shell ls -ld $(ROOT)/lib32 2>/dev/null) +ifneq ($(HAVE_64BIT_FS),) + HAVE_32BIT_GCC = $(shell $(CC) -m32 -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo "yes") + ifneq ($(HAVE_32BIT_GCC),) + HAVE_64BIT_GCC = $(shell $(CC) -m64 -S -o /dev/null -xc /dev/null > /dev/null 2>&1 && echo "yes") + ifneq ($(HAVE_64BIT_GCC),) + HAVE_64BIT_ARCH = yes + endif + endif +endif + +ifneq ($(HAVE_64BIT_ARCH),) + TARGETS = libsandbox.so libsandbox32.so sandbox + ARCH_CFLAGS += -m64 + OBJ_CFLAGS += -DSB_HAVE_64BIT_ARCH +else + TARGETS = libsandbox.so sandbox +endif all: $(TARGETS) sandbox: sandbox.o sandbox_futils.o getcwd.c - $(CC) $^ -ldl -lc -o $@ + $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall $^ -ldl -lc -o $@ sandbox.o: sandbox.c sandbox.h - $(CC) $(CFLAGS) -Wall -c sandbox.c + $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c sandbox.c -o $@ sandbox_futils.o: sandbox_futils.c sandbox.h - $(CC) $(CFLAGS) -Wall -c $(OBJ_DEFINES) sandbox_futils.c + $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c sandbox_futils.c -o $@ libsandbox.so: libsandbox.o sandbox_futils.o - $(CC) $^ -shared -fPIC -ldl -lc -o $@ -nostdlib -lgcc + $(CC) $^ -shared $(ARCH_CFLAGS) -fPIC -ldl -lc -nostdlib -lgcc -o $@ libsandbox.o: libsandbox.c localdecls.h canonicalize.c getcwd.c - $(CC) $(CFLAGS) -Wall -c $(OBJ_DEFINES) libsandbox.c + $(CC) $(CFLAGS) $(ARCH_CFLAGS) $(OBJ_CFLAGS) -Wall -c libsandbox.c + +sandbox_futils32.o: sandbox_futils.c sandbox.h + $(CC) $(CFLAGS) -m32 $(OBJ_CFLAGS) -Wall -c sandbox_futils.c -o $@ + +libsandbox32.so: libsandbox32.o sandbox_futils32.o + $(CC) $^ -shared -m32 -fPIC -ldl -lc -nostdlib -lgcc -o $@ + +libsandbox32.o: libsandbox.c localdecls.h canonicalize.c getcwd.c + $(CC) $(CFLAGS) -m32 $(OBJ_CFLAGS) -Wall -c libsandbox.c -o $@ localdecls.h: create-localdecls libctest.c ./create-localdecls @@ -45,9 +74,11 @@ localdecls.h: create-localdecls libctest install: all install -d -m 0755 $(DESTDIR)/lib + $(if $(HAVE_64BIT_ARCH),install -d -m 0755 $(DESTDIR)/lib32) install -d -m 0755 $(DESTDIR)/usr/lib/portage/bin install -d -m 0755 $(DESTDIR)/usr/lib/portage/lib install -m 0755 libsandbox.so $(DESTDIR)/lib + $(if $(HAVE_64BIT_ARCH),install -m 0755 libsandbox32.so $(DESTDIR)/lib32/libsandbox.so) install -m 0755 sandbox $(DESTDIR)/usr/lib/portage/bin install -m 0644 sandbox.bashrc $(DESTDIR)/usr/lib/portage/lib Index: sandbox.c =================================================================== RCS file: /home/cvsroot/gentoo-src/portage/src/sandbox-1.1/sandbox.c,v retrieving revision 1.12 diff -u -p -r1.12 sandbox.c --- sandbox.c 12 Oct 2003 22:36:58 -0000 1.12 +++ sandbox.c 12 Nov 2003 01:17:01 -0000 @@ -14,7 +14,7 @@ ** $Header: /home/cvsroot/gentoo-src/portage/src/sandbox-1.1/sandbox.c,v 1.12 2003/10/12 22:36:58 carpaski Exp $ */ -#define _GNU_SOURCE +/* #define _GNU_SOURCE */ #include #include Index: sandbox_futils.c =================================================================== RCS file: /home/cvsroot/gentoo-src/portage/src/sandbox-1.1/sandbox_futils.c,v retrieving revision 1.5 diff -u -p -r1.5 sandbox_futils.c --- sandbox_futils.c 28 Sep 2003 08:37:19 -0000 1.5 +++ sandbox_futils.c 12 Nov 2003 01:17:01 -0000 @@ -57,10 +57,14 @@ get_sandbox_lib(char *sb_path) { char path[255]; +#ifdef SB_HAVE_64BIT_ARCH + snprintf(path, 254, "%s", LIB_NAME); +#else snprintf(path, 254, "/lib/%s", LIB_NAME); if (file_exist(path, 0) <= 0) { snprintf(path, 254, "%s%s", sb_path, LIB_NAME); } +#endif return (strdup(path)); }