From 95165884b67f30d794e963be81d0a6a2adba2d4a Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser <albrechts.fltk@online.de> Date: Wed, 10 Jun 2020 16:24:39 +0200 Subject: [PATCH] Support cross-compilation with autotools We use the host system's `fluid` when cross-compiling. This must be executable as `fluid`, i.e. it must be in the PATH or otherwise defined, for instance as an alias. --- .gitignore | 1 + configure.ac | 36 +++++++++++++++++++++++++++++------- makeinclude.in | 10 +++++++--- test/Makefile | 10 ++++------ 4 files changed, 41 insertions(+), 16 deletions(-) diff --git a/.gitignore b/.gitignore index 3d1cfe982..57abd8705 100644 --- a/.gitignore +++ b/.gitignore @@ -115,6 +115,7 @@ etc/FLTKConfig.cmake /src/*.sl* /src/*.a /src/*.bck +/src/*.dll /src/*.sav /src/*.dylib diff --git a/configure.ac b/configure.ac index 12a2a0bf9..fda55a21d 100644 --- a/configure.ac +++ b/configure.ac @@ -1,21 +1,19 @@ dnl -*- sh -*- dnl the "configure" script is made from this by running GNU "autoconf" dnl -dnl "$Id$" -dnl dnl Configuration script for the Fast Light Tool Kit (FLTK). dnl -dnl Copyright 1998-2018 by Bill Spitzak and others. +dnl Copyright 1998-2020 by Bill Spitzak and others. dnl dnl This library is free software. Distribution and use rights are outlined in dnl the file "COPYING" which should have been included with this file. If this dnl file is missing or damaged, see the license at: dnl -dnl http://www.fltk.org/COPYING.php +dnl https://www.fltk.org/COPYING.php dnl dnl Please report all bugs and problems on the following page: dnl -dnl http://www.fltk.org/str.php +dnl https://www.fltk.org/str.php dnl dnl We need at least autoconf 2.50... @@ -27,6 +25,13 @@ AC_CONFIG_SRCDIR([src/Fl.cxx]) AC_CANONICAL_HOST +dnl determine whether we're cross-compiling +if test "$host" != "$build"; then + fltk_cross_compiling="yes" +else + fltk_cross_compiling="no" +fi + dnl Do not automatically add "-g" to compiler options... dnl This must be _before_ "Find compiler commands..." ARCHFLAGS="${ARCHFLAGS:=}" @@ -390,6 +395,16 @@ else LINKSHARED="$LINKFLTKCAIRO ../lib/libfltk_images.a ../lib/libfltk_forms.a ../lib/libfltk.a" fi +dnl Define the fluid executable used when building the test programs. +dnl In a native build we use the fluid executable created during the build, +dnl in a cross-compilation we use `fluid' which must exist on the build system +dnl and must be in the PATH, i.e. executable as 'fluid' (w/o $EXEEXT). +if test "$fltk_cross_compiling" = "yes"; then + FLUID_BUILD="fluid" +else + FLUID_BUILD="../fluid/fluid$EXEEXT" +fi + AC_SUBST(DSOCOMMAND) AC_SUBST(DSOFLAGS) AC_SUBST(DSOLINK) @@ -401,6 +416,7 @@ AC_SUBST(CAIRODSONAME) AC_SUBST(SHAREDSUFFIX) AC_SUBST(LINKSHARED) AC_SUBST(FLUID) +AC_SUBST(FLUID_BUILD) AC_ARG_ENABLE(threads, [ --enable-threads enable multi-threading support [[default=yes]]]) @@ -1602,8 +1618,14 @@ case $host_os in echo " MSys docpath=$msyspath/local/share/doc/fltk" ;; esac +dnl +echo "Cross-compiling: $fltk_cross_compiling" +if test "$fltk_cross_compiling" = "yes"; then + echo " Build: $build -> Host: $host" +fi +dnl echo " Graphics: $graphics" - +dnl if test x$JPEG = x; then echo "Image Libraries: JPEG=System" else @@ -1658,5 +1680,5 @@ dnl Make sure the fltk-config script is executable... chmod +x fltk-config dnl -dnl End of "$Id$". +dnl End of file. dnl diff --git a/makeinclude.in b/makeinclude.in index bad8b454f..9069abb70 100644 --- a/makeinclude.in +++ b/makeinclude.in @@ -3,17 +3,17 @@ # # Make include file for the Fast Light Tool Kit (FLTK). # -# Copyright 1998-2018 by Bill Spitzak and others. +# Copyright 1998-2020 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this # file is missing or damaged, see the license at: # -# http://www.fltk.org/COPYING.php +# https://www.fltk.org/COPYING.php # # Please report all bugs and problems on the following page: # -# http://www.fltk.org/str.php +# https://www.fltk.org/str.php # # FLTK version numbers @@ -122,6 +122,10 @@ THREADS = @THREADS@ # Name of FLUID executable we install FLUID = @FLUID@$(EXEEXT) +# Name and/or path of FLUID executable we use for building: +# depends on the build type (native or cross-compiler) +FLUID_BUILD = @FLUID_BUILD@ + # Possible steps for OS X build only OSX_ONLY = @OSX_ONLY@ diff --git a/test/Makefile b/test/Makefile index 40b5344af..959d28709 100644 --- a/test/Makefile +++ b/test/Makefile @@ -1,19 +1,17 @@ # -# "$Id$" -# # Test/example program makefile for the Fast Light Tool Kit (FLTK). # -# Copyright 1998-2019 by Bill Spitzak and others. +# Copyright 1998-2020 by Bill Spitzak and others. # # This library is free software. Distribution and use rights are outlined in # the file "COPYING" which should have been included with this file. If this # file is missing or damaged, see the license at: # -# http://www.fltk.org/COPYING.php +# https://www.fltk.org/COPYING.php # # Please report all bugs and problems on the following page: # -# http://www.fltk.org/str.php +# https://www.fltk.org/str.php # include ../makeinclude @@ -302,7 +300,7 @@ uninstall-osx: # FLUID file rules .fl.cxx .fl.h: ../fluid/fluid$(EXEEXT) echo Generating $@ and header from $<... - ../fluid/fluid$(EXEEXT) -c $< + $(FLUID_BUILD) -c $< # All demos depend on the FLTK library... $(ALL): $(LIBNAME) -- GitLab