Cross Compiling "make programs" patch
Ken Bantoft <[email protected]> Wed, 19 Feb 2003 22:45:27 -0500 (EST)
| Newsgroups | gmane.network.freeswan.devel |
|---|---|
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Note: this focuses on "make programs" and not the kernel patches. That will be in a seperate email sometime later. Attached is a patch, but I don't expect the complete thing to go in unchanged. But it should at least make us think about how we're doing things in the Makefiles, and hopefully end up improving the current system so future cross compiling is easier. Compared to 1.99, 2.00 is remarkably easier to cross compile. Most of this is due to centralizing all of the programs under programs/, and using a (mostly) centralized Makefile for them - programs/Makefile.program. A few subdirectories still use thier own Makefile, and suffer to the flaws discussed below. There are a few things that need fixing - all of which are the hardcoding of some compilers, linkers, assemblers and binutils. Specifically, there's hardcoded references to gcc, ar, as, ld and ranlib in some of the subdirectory Makefile's that should be fixed. This patch does this by changing them all to references like $(CC) (which existed already, so there is precedent for this) Now, to cross compile, I just export the conventional environment variables like so: export CC=/opt/Embedix/tools/bin/arm-linux-gcc export LD=/opt/Embedix/tools/bin/arm-linux-ld export RANLIB=/opt/Embedix/tools/bin/arm-linux-ranlib export AR=/opt/Embedix/tools/bin/arm-linux-ar export AS=/opt/Embedix/tools/bin/arm-linux-as export LD_LIBRARYPATH=/z/zeeswan-2.00/zaurus/libs export KERNEL_SRC=/z/bk-buildroot/build/linux And "make programs" now builds using the correct gcc, ld, etc... and links against binary Zaurus libs I place in /z/zeeswan-2.00/zaurus/libs (currently, this is libgmp.so) Thoughts? - -- Ken Bantoft The Unoffical FreeS/WAN Site: [email protected] http://www.freeswan.ca PGP Key: finger [email protected] I'd rather run Unix than Windows or MacOS any day, because Unix sucks less. -- jwz -----BEGIN PGP SIGNATURE----- Version: 2.6.3ia Charset: noconv iQCVAwUBPlRPWViWUusaxGxpAQHOfAP9FB9FiP55V8Awe3fwq9/gbxsWMaOIGIgx fWokYk4JcrDiQUgBFFy+P6d4qImfqc1OH7WsZp/YkBSZNlQ41Usi24unXu3uELwd eKpgmcdZ4y+O8V4UZYvheNpdhcB2QZ/b7NMOxGNO+y8b4+YtwypGi2Y0VvI37aGT aROLG+BvXKA= =Eo9n -----END PGP SIGNATURE-----
crosscompmakefiles.diff
(text/plain, 2.5 KB)
diff -uNr freeswan-2.00-pre8/lib/libdes/Makefile zeeswan-2.00/lib/libdes/Makefile
--- freeswan-2.00-pre8/lib/libdes/Makefile 2002-09-16 14:24:43.000000000 -0400
+++ zeeswan-2.00/lib/libdes/Makefile 2003-02-19 22:16:34.000000000 -0500
@@ -62,7 +62,7 @@
CFLAGS=$(OPTS) $(CFLAG)
CPP=$(CC) -E
-AS=as
+#AS=as
# Assember version of des_encrypt*().
DES_ENC=des_enc.o fcrypt_b.o # normal C version
@@ -190,7 +190,7 @@
$(DLIB): $(OBJ)
/bin/rm -f $(DLIB)
ar cr $(DLIB) $(OBJ)
- -if test -s /bin/ranlib; then /bin/ranlib $(DLIB); \
+ -if test -s $(RANLIB); then $(RANLIB) $(DLIB); \
else if test -s /usr/bin/ranlib; then /usr/bin/ranlib $(DLIB); \
else exit 0; fi; fi
diff -uNr freeswan-2.00-pre8/lib/libfreeswan/Makefile zeeswan-2.00/lib/libfreeswan/Makefile
--- freeswan-2.00-pre8/lib/libfreeswan/Makefile 2002-06-02 17:51:41.000000000 -0400
+++ zeeswan-2.00/lib/libfreeswan/Makefile 2003-02-19 22:14:40.000000000 -0500
@@ -95,7 +95,7 @@
done
$(LIB): $(OBJS)
- ar $(ARFLAGS) $(LIB) $(OBJS)
+ $(AR) $(ARFLAGS) $(LIB) $(OBJS)
$(OBJS): $(HDRS)
@@ -121,7 +121,7 @@
# developer-only stuff
l:
$(MAKE) $(LIB) ARFLAGS=crv CFLAGS=-O
- ranlib $(LIB)
+ $(RANLIB) $(LIB)
t: $(LIB)
cp atosubnet.c try.c
diff -uNr freeswan-2.00-pre8/programs/Makefile.program zeeswan-2.00/programs/Makefile.program
--- freeswan-2.00-pre8/programs/Makefile.program 2003-01-14 15:34:20.000000000 -0500
+++ zeeswan-2.00/programs/Makefile.program 2003-02-19 22:29:21.000000000 -0500
@@ -1,7 +1,7 @@
include ${FREESWANSRCDIR}/Makefile.ver
-CC=gcc
+# CC=gcc
CFLAGS+=$(USERCOMPILE) -I${KLIPSINC}
CFLAGS+= $(USERCOMPILE)
@@ -24,6 +24,8 @@
CFLAGS+= ${WERROR}
+LDFLAGS=-L$(LD_LIBRARY_PATH)
+
MANDIR8=$(MANTREE)/man8
MANDIR5=$(MANTREE)/man5
@@ -104,7 +106,7 @@
%: %.c
%: %.o $(OBJS)
- $(CC) $(CFLAGS) -o $@ [email protected] ${OBJS} $(LIBS)
+ $(CC) $(CFLAGS) -o $@ [email protected] ${OBJS} $(LDFLAGS) $(LIBS)
%: %.in ${FREESWANSRCDIR}/Makefile.inc ${FREESWANSRCDIR}/Makefile.ver
cat $< | sed -e "s/xxx/$(IPSECVERSION)/" \
diff -uNr freeswan-2.00-pre8/programs/pluto/Makefile zeeswan-2.00/programs/pluto/Makefile
--- freeswan-2.00-pre8/programs/pluto/Makefile 2003-02-06 23:25:35.000000000 -0500
+++ zeeswan-2.00/programs/pluto/Makefile 2003-02-19 22:25:20.000000000 -0500
@@ -96,7 +96,7 @@
LIBSPLUTO = $(OBJSGCRYPT) $(LIBDESLITE) $(FREESWANLIB)
LIBSPLUTO+= -lgmp -lresolv # -lefence
-LDFLAGS =
+LDFLAGS = -L$(LD_LIBRARY_PATH)
LIBSADNS = $(FREESWANLIB)
LIBSADNS += -lresolv # -lefence