From 10ce2006ce01df3ab1d9523386b60da61d951f25 Mon Sep 17 00:00:00 2001 From: John Cowan Date: Wed, 18 Dec 2019 18:43:50 -0500 Subject: [PATCH] Implement platform auto-detection when possible. Cross-compilation still requires PLATFORM to be set, and you can always set it yourself if you want to, but the README examples no longer mention it. Signed-off-by: Peter Bex --- GNUmakefile | 4 ++- Makefile.detect | 76 +++++++++++++++++++++++++++++++++++++++++++ NEWS | 3 ++ README | 39 ++++++++++++++-------- distribution/manifest | 1 + 5 files changed, 109 insertions(+), 14 deletions(-) create mode 100644 Makefile.detect diff --git a/GNUmakefile b/GNUmakefile index feea5d14..49e701b1 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -37,6 +37,8 @@ include $(CONFIG) endif endif +include Makefile.detect + ifndef PLATFORM $(info Please select your target platform by running one of the following commands:) $(info ) @@ -46,4 +48,4 @@ $(info For more information, consult the README file.) $(error No PLATFORM given.) else include $(SRCDIR)Makefile.$(PLATFORM) -endif \ No newline at end of file +endif diff --git a/Makefile.detect b/Makefile.detect new file mode 100644 index 00000000..a50a57de --- /dev/null +++ b/Makefile.detect @@ -0,0 +1,76 @@ +# -*- makefile-gmake -*- + +######################################################################## +# Detect the PLATFORM with uname. +# Based on Chibi Scheme auto-detector +# Copyright (c) 2009-2018 Alex Shinn +# BSD license at + +ifndef PLATFORM +# ComSpec value is "c:\windows\system32\cmd.exe" on Windows +# Cygwin bash renames this to COMSPEC +ifneq ($(COMSPEC)$(ComSpec),) +ifneq ($(SHELL),) # set by Msys bash +PLATFORM=mingw-msys +else +PLATFORM=mingw +endif +else +ifeq ($(shell uname),Darwin) +PLATFORM=macosx +else +ifeq ($(shell uname),FreeBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),NetBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),OpenBSD) +PLATFORM=bsd +else +ifeq ($(shell uname),DragonFly) +PLATFORM=bsd +else +ifeq ($(shell uname -o),Cygwin) +PLATFORM=cygwin +else +ifeq ($(shell uname -o),Android) +PLATFORM=android +else +ifeq ($(shell uname -o),GNU/Linux) +PLATFORM=linux +else +ifeq ($(shell uname),SunOS) +PLATFORM=solaris +else +ifeq ($(shell uname), Haiku) +PLATFORM=Haiku +else +ifeq ($(shell uname), BeOS) +PLATFORM=Haiku +else +ifeq ($(shell uname), GNU) +PLATFORM=hurd +else +ifeq ($(shell uname),AIX) +PLATFORM=aix +else +ifeq ($(shell uname),iOS) # may not be correct +PLATFORM=ios +# add more options here +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif +endif diff --git a/NEWS b/NEWS index 05b4dfe9..56361160 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,8 @@ 5.1.1 +- Build system + - Auto-configure at build time on most platforms. + - Core libraries - Fix `memory-statistics` by returning semi-space bytes and used semi-space bytes like the documentation says. Old implementation diff --git a/README b/README index 3b88f6af..58965e76 100644 --- a/README +++ b/README @@ -78,8 +78,20 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ currently not supported, so you must be in the toplevel source directory to invoke "make". - Enter "make" without any options to see a list of supported - platforms. + If you enter "make" without the PLATFORM option, Chicken will + attempt to figure out what platform you are using. If it cannot + do so, you will see a list of supported platforms. If you + are cross-building, you must specify PLATFORM; for example, + PLATFORM=cross-linux-mingw will build Chicken on Linux to deploy + on Windows. + + If Chicken somehow detects the wrong platform, type + + make PLATFORM="" + + to get a list of available platforms, and re-run "make" using + the correct platform. From now on we will assume that platform + detection is correct. Note that parallel builds (using the "-j" make(1) option) are *not* supported. @@ -87,7 +99,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ If you invoke "make" later with different configuration parameters, it is advisable to run: - make PLATFORM= confclean + make confclean to remove old configuration files. @@ -96,13 +108,14 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ If you build CHICKEN directly from the development sources out of the git repository, you will need a "chicken" executable to generate the compiled C files from the Scheme library sources. + See section 2.1 for platform detection issues. If you are building in a checkout where you have built other versions of chicken, you need to make sure that all traces of the previous build are removed. "make clean" is insufficient, and you should do the following: - make PLATFORM= spotless + make spotless You will need to have a "chicken" binary installed, ideally from the development snapshot tarball that is closest to the @@ -114,7 +127,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ Then, to build you can run: - make PLATFORM= CHICKEN=/bin/chicken + make CHICKEN=/bin/chicken In some cases, the sources may have diverged enough to become unbuildable even with the snapshot. Then you'll need @@ -127,7 +140,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ If CHICKEN is built successfully, you can install it on your system by entering - make PLATFORM= PREFIX= install + make PREFIX= install "PREFIX" defaults to "/usr/local". Note that the PREFIX is compiled into several CHICKEN tools and must be the same @@ -248,7 +261,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ To remove CHICKEN from your file-system, enter (probably as root): - make PLATFORM= PREFIX= uninstall + make PREFIX= uninstall (If you gave DESTDIR during installation, you have to pass the same setting to "make" when uninstalling) @@ -474,7 +487,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ - CHICKEN will normally select a 32-bit or 64-bit build automatically when you use the normal build step: - make PLATFORM=macosx + make Specifically, the defaults are: @@ -487,18 +500,18 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ released in late 2006 or later (i.e. with a Core 2 Duo or Xeon CPU), by specifying ARCH=x86-64: - make PLATFORM=macosx ARCH=x86-64 + make ARCH=x86-64 - Universal binaries: On 10.4 and 10.5 only, CHICKEN and its eggs can be built as universal binaries which will work on either Intel or PowerPC. Most users will not want to do this. For 10.4 universal build: - make PLATFORM=macosx ARCH=universal + make ARCH=universal For 10.5 universal build: export MACOSX_DEPLOYMENT_TARGET=10.4 - make C_COMPILER=gcc-4.0 PLATFORM=macosx ARCH=universal + make C_COMPILER=gcc-4.0 ARCH=universal For 10.6 and later, universal builds are not supported. @@ -642,7 +655,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ http://code.call-cc.org, unpack it, build and install it. Then change to the directory containing the git code and run: - make PLATFORM= CHICKEN= \ + make CHICKEN= \ boot-chicken This will produce a statically linked binary with the name @@ -657,7 +670,7 @@ _/ _/ _/ _/ _/ _/ _/ _/ _/ _/_/ builds the boot-chicken that you can use to compile the development sources. The invocation is: - scripts/bootstrap.sh PLATFORM= ... + scripts/bootstrap.sh ... You can add additional parameters if you like to customize the build, but this should not be necessary. Note that your current diff --git a/distribution/manifest b/distribution/manifest index 9d43de14..504ddb5e 100644 --- a/distribution/manifest +++ b/distribution/manifest @@ -253,6 +253,7 @@ tweaks.scm Makefile Makefile.android Makefile.aix +Makefile.detect Makefile.linux Makefile.macosx Makefile.ios -- 2.20.1