From 4087ec556b1ccee15d8e97153f3800b79982f8ba Mon Sep 17 00:00:00 2001 From: Paul Mackerras Date: Fri, 1 Jan 2021 19:44:07 +1100 Subject: [PATCH] Add cross-compilation support on Linux This adds three new command-line options to the configure script: --cross_compile= (default "") --cc= (default cc) --cflags= (default -g -O2 -pipe) These get propagated to the Makefiles in the subdirectories. The cross-compile prefix is prepended to the CC value, so for example if you do "./configure --cross_compile=powerpc64le-linux-" then everything gets compiled and linked using powerpc64le-linux-cc. Signed-off-by: Paul Mackerras --- chat/Makefile.linux | 5 +- configure | 98 +++++----------------------- pppd/Makefile.linux | 9 +-- pppd/plugins/Makefile.linux | 16 +++-- pppd/plugins/pppoatm/Makefile.linux | 13 ++-- pppd/plugins/pppoe/Makefile.linux | 7 +- pppd/plugins/pppol2tp/Makefile.linux | 13 ++-- pppd/plugins/radius/Makefile.linux | 7 +- pppdump/Makefile.linux | 7 +- pppstats/Makefile.linux | 7 +- 10 files changed, 67 insertions(+), 115 deletions(-) diff --git a/chat/Makefile.linux b/chat/Makefile.linux index f082dab..407cc12 100644 --- a/chat/Makefile.linux +++ b/chat/Makefile.linux @@ -1,4 +1,6 @@ -# $Id: Makefile.linux,v 1.15 2006/06/04 05:07:46 paulus Exp $ +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin @@ -10,7 +12,6 @@ CDEF3= -UNO_SLEEP # Use the usleep function CDEF4= -DFNDELAY=O_NDELAY # Old name value CDEFS= $(CDEF1) $(CDEF2) $(CDEF3) $(CDEF4) -COPTS= -O2 -g -pipe CFLAGS= $(COPTS) $(CDEFS) INSTALL= install diff --git a/configure b/configure index ecd1b0d..f977663 100755 --- a/configure +++ b/configure @@ -5,25 +5,25 @@ DESTDIR=/usr/local SYSCONF=/etc -# if [ -d /NextApps ]; then -# system="NeXTStep" -# else - system=`uname -s` - release=`uname -r` - arch=`uname -m` -# fi +# Compile defaults +CROSS_COMPILE= +CC=cc +CFLAGS= + +system=`uname -s` +release=`uname -r` +arch=`uname -m` state="unknown" case $system in Linux) makext="linux"; ksrc="linux"; - state="known";; + state="known"; + CFLAGS="-O2 -g -pipe";; SunOS) karch=`/usr/bin/isainfo -k` case $release in -# [0-3]*) state="ancient";; -# 4*) state="known"; ksrc="sunos4"; makext="sunos4";; 5.[7-9]*|5.[1-9][0-9]*) state="known"; ksrc="solaris"; makext="sol2"; case "$karch" in amd64) archvariant='-64x';; @@ -72,57 +72,6 @@ case $system in fi;; NetBSD|FreeBSD|ULTRIX|OSF1|NeXTStep|SINIX-?|UNIX_SV|UNIX_System_V) state="notincluded";; -# NetBSD) -# makext="bsd"; -# case $release in -# 0.*) state="ancient";; -# 1.0*) state="ancient";; -# 1.1*) state="known"; ksrc="netbsd-1.1";; -# 1.2*) state="known"; ksrc="netbsd-1.2"; makext="netbsd-1.2";; -# 1.[3-9]*|[2-9]*) -# state="late"; ksrc="netbsd-1.2";; -# esac;; -# ULTRIX) -# makext="ultrix"; -# case $release in -# [0-3]*) state="ancient";; -# 4.[01]*) state="early"; ksrc="ultrix";; -# 4.[234]) state="known"; ksrc="ultrix";; -# esac;; -# OSF1) -# makext="osf"; -# case $release in -# V1.*) state="neolithic"; ksrc="osf1";; -# V[23].*) state="neolithic"; ksrc="osf1";; -# V4.*) state="known"; ksrc="osf1";; -# V[5-9]*) state="late"; ksrc="osf1";; -# esac;; -# FreeBSD) -# makext="bsd"; -# case $release in -# 1.*) state="known"; ksrc="freebsd-old";; -# 2.[01]*) state="known"; ksrc="freebsd-2.0";; -# 2.2.[2-7]*) state="late"; ksrc="freebsd-2.0";; -# 2.2.8*) state="known"; ksrc="freebsd-2.2.8";; -# 3.[0-1]*) state="known"; ksrc="freebsd-3.0";; -# esac;; -# NeXTStep) -# makext="NeXT"; -# ksrc="NeXT"; -# state="known";; -# SINIX-?) -# case $release in -# 5.4[01]) state=known; ksrc=svr4; makext=svr4;; -# 5.4[2-9]) state=late; ksrc=svr4; makext=svr4;; -# esac;; -# # Intel SVR4 systems come with a bug in the uname program. Unless -# # your provider fixed the bug, or you get a fix for it, uname -S will -# # overwrite the system name with the node name! -# UNIX_SV|UNIX_System_V|`uname -n`) -# case $release in -# 4.0) state=known; ksrc=svr4; makext=svr4;; -# 4.2) state=late; ksrc=svr4; makext=svr4;; -# esac;; esac if [ -d "$ksrc" ]; then :; else @@ -131,22 +80,6 @@ if [ -d "$ksrc" ]; then :; else fi case $state in - neolithic) - echo "This is a newer release on an outdated OS ($system)." - echo " This software may or may not work on this OS." - echo " You may want to download an older version of PPP for this OS.";; - ancient) - echo "This is an old release of a supported OS ($system)." - echo "This software cannot be used as-is on this system," - echo "but you may be able to port it. Good luck!" - exit;; - early) - echo "This is an old release of a supported OS ($system)." - echo "This software should install and run on this system," - echo "but it hasn't been tested.";; - late) - echo "This is a newer release of $system than is supported by" - echo "this software. It may or may not work.";; unknown) echo "This software has not been ported to $system. Sorry.";; notincluded) @@ -176,8 +109,11 @@ while [ $# -gt 0 ]; do ;; esac case $arg in - --prefix) DESTDIR=$val ;; - --sysconfdir) SYSCONF=$val ;; + --prefix) DESTDIR=$val ;; + --sysconfdir) SYSCONF=$val ;; + --cross_compile) CROSS_COMPILE=$val ;; + --cc) CC=$val ;; + --cflags) CFLAGS=$val ;; esac done @@ -185,7 +121,9 @@ mkmkf() { rm -f $2 if [ -f $1 ]; then echo " $2 <= $1" - sed -e "s,@DESTDIR@,$DESTDIR,g" -e "s,@SYSCONF@,$SYSCONF,g" $1 >$2 + sed -e "s,@DESTDIR@,$DESTDIR,g" -e "s,@SYSCONF@,$SYSCONF,g" \ + -e "s,@CROSS_COMPILE@,$CROSS_COMPILE,g" -e "s,@CC@,$CC,g" \ + -e "s,@CFLAGS@,$CFLAGS,g" $1 >$2 fi } diff --git a/pppd/Makefile.linux b/pppd/Makefile.linux index 958cc29..22837c5 100644 --- a/pppd/Makefile.linux +++ b/pppd/Makefile.linux @@ -3,6 +3,10 @@ # Processed by configure to produce pppd/Makefile # +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + # Default installation locations DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin @@ -30,9 +34,6 @@ ifeq (.depend,$(wildcard .depend)) include .depend endif -# CC = gcc -# -COPTS = -O2 -pipe -Wall -g LIBS = -lrt # Uncomment the next line to include support for Microsoft's @@ -90,7 +91,7 @@ MAXOCTETS=y INCLUDE_DIRS= -I../include -COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP +COMPILE_FLAGS= -DHAVE_PATHS_H -DIPX_CHANGE -DHAVE_MMAP -pipe CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="@DESTDIR@"' diff --git a/pppd/plugins/Makefile.linux b/pppd/plugins/Makefile.linux index e2a680e..6403e3d 100644 --- a/pppd/plugins/Makefile.linux +++ b/pppd/plugins/Makefile.linux @@ -1,5 +1,12 @@ -#CC = gcc -COPTS = -O2 -g +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + +DESTDIR = $(INSTROOT)@DESTDIR@ +BINDIR = $(DESTDIR)/sbin +MANDIR = $(DESTDIR)/share/man/man8 +LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) + CFLAGS = $(COPTS) -I.. -I../../include -fPIC LDFLAGS_SHARED = -shared INSTALL = install @@ -7,11 +14,6 @@ INSTALL = install # EAP-TLS CFLAGS += -DUSE_EAPTLS=1 -DESTDIR = $(INSTROOT)@DESTDIR@ -BINDIR = $(DESTDIR)/sbin -MANDIR = $(DESTDIR)/share/man/man8 -LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) - SUBDIRS := pppoe pppoatm pppol2tp # Uncomment the next line to include the radius authentication plugin SUBDIRS += radius diff --git a/pppd/plugins/pppoatm/Makefile.linux b/pppd/plugins/pppoatm/Makefile.linux index 59dde0e..d3a8086 100644 --- a/pppd/plugins/pppoatm/Makefile.linux +++ b/pppd/plugins/pppoatm/Makefile.linux @@ -1,16 +1,17 @@ -#CC = gcc -COPTS = -O2 -g -CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC -LDFLAGS_SHARED = -shared -INSTALL = install - #*********************************************************************** +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ DESTDIR = $(INSTROOT)@DESTDIR@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) +CFLAGS = $(COPTS) -I../.. -I../../../include -fPIC +LDFLAGS_SHARED = -shared +INSTALL = install + PLUGIN := pppoatm.so PLUGIN_OBJS := pppoatm.o diff --git a/pppd/plugins/pppoe/Makefile.linux b/pppd/plugins/pppoe/Makefile.linux index 473f269..c415ce3 100644 --- a/pppd/plugins/pppoe/Makefile.linux +++ b/pppd/plugins/pppoe/Makefile.linux @@ -1,4 +1,3 @@ -# Generated automatically from Makefile.in by configure. #*********************************************************************** # # Makefile @@ -11,9 +10,12 @@ # This program may be distributed according to the terms of the GNU # General Public License, version 2 or (at your option) any later version. # -# $Id: Makefile.linux,v 1.8 2008/06/09 08:34:23 paulus Exp $ #*********************************************************************** +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin LIBDIR = $(DESTDIR)/lib/pppd/$(PPPDVERSION) @@ -23,7 +25,6 @@ PPPDVERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) INSTALL = install LN_S = ln -sf -COPTS=-O2 -g CFLAGS=$(COPTS) -I../../../include all: pppoe.so pppoe-discovery diff --git a/pppd/plugins/pppol2tp/Makefile.linux b/pppd/plugins/pppol2tp/Makefile.linux index ffb9c34..1aa1c0b 100644 --- a/pppd/plugins/pppol2tp/Makefile.linux +++ b/pppd/plugins/pppol2tp/Makefile.linux @@ -1,16 +1,17 @@ -#CC = gcc -COPTS = -O2 -g -CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -LDFLAGS_SHARED = -shared -INSTALL = install - #*********************************************************************** +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ DESTDIR = $(INSTROOT)/@DESTDIR@ LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) +CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC +LDFLAGS_SHARED = -shared +INSTALL = install + PLUGINS := pppol2tp.so openl2tp.so all: $(PLUGINS) diff --git a/pppd/plugins/radius/Makefile.linux b/pppd/plugins/radius/Makefile.linux index 3a15b03..489aef2 100644 --- a/pppd/plugins/radius/Makefile.linux +++ b/pppd/plugins/radius/Makefile.linux @@ -3,6 +3,10 @@ # Copyright 2002 Roaring Penguin Software Inc. # +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + DESTDIR = $(INSTROOT)@DESTDIR@ MANDIR = $(DESTDIR)/share/man/man8 LIBDIR = $(DESTDIR)/lib/pppd/$(VERSION) @@ -12,8 +16,7 @@ VERSION = $(shell awk -F '"' '/VERSION/ { print $$2; }' ../../patchlevel.h) INSTALL = install PLUGIN=radius.so radattr.so radrealms.so -CFLAGS ?= -O2 -CFLAGS += -I. -I../.. -I../../../include -fPIC -DRC_LOG_FACILITY=LOG_DAEMON +CFLAGS = $(COPTS) -I. -I../.. -I../../../include -fPIC -DRC_LOG_FACILITY=LOG_DAEMON # Uncomment the next line to include support for Microsoft's # MS-CHAP authentication protocol. diff --git a/pppdump/Makefile.linux b/pppdump/Makefile.linux index 742a4b8..a94187f 100644 --- a/pppdump/Makefile.linux +++ b/pppdump/Makefile.linux @@ -1,9 +1,12 @@ +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin MANDIR = $(DESTDIR)/share/man/man8 -CFLAGS ?= -O -CFLAGS += -I../include/net +CFLAGS = $(COPTS) -I../include/net OBJS = pppdump.o bsd-comp.o deflate.o zlib.o INSTALL= install diff --git a/pppstats/Makefile.linux b/pppstats/Makefile.linux index 1819370..ddfe0cc 100644 --- a/pppstats/Makefile.linux +++ b/pppstats/Makefile.linux @@ -1,7 +1,10 @@ # # pppstats makefile -# $Id: Makefile.linux,v 1.9 2006/06/04 05:07:46 paulus Exp $ # +CROSS_COMPILE=@CROSS_COMPILE@ +CC=$(CROSS_COMPILE)@CC@ +COPTS=@CFLAGS@ + DESTDIR = $(INSTROOT)@DESTDIR@ BINDIR = $(DESTDIR)/sbin MANDIR = $(DESTDIR)/share/man/man8 @@ -9,8 +12,6 @@ MANDIR = $(DESTDIR)/share/man/man8 PPPSTATSRCS = pppstats.c PPPSTATOBJS = pppstats.o -#CC = gcc -COPTS = -O COMPILE_FLAGS = -I../include LIBS = -- 2.39.2