瀏覽代碼

Cross compilation (#257)

* Makefiles: Don't try to run cross-compiled modules (g.parser.exe specifically)

* Add comments

* configure: Use pwd instead of pwd -W for cross compiling

* configure: Support for $WINDRES and $PKG_CONFIG

* host system => build system

* Cross compilation cannot execute binaries

* Add .exe extension

I tested this PR for the past 3 days in daily cron. It's been successfully building daily builds for x86_64-pc-linux-gnu and x86_64-w64-mingw32.
Huidae Cho 4 年之前
父節點
當前提交
1e5146f1df

文件差異過大導致無法顯示
+ 704 - 741
configure


+ 17 - 4
configure.in

@@ -37,6 +37,19 @@ AC_PROG_CC
 LOC_EXEEXT
 AC_SUBST(MINGW32)
 
+# Set WINDRES
+
+if test "$MINGW32" = yes ; then
+  WINDRES=${WINDRES-windres}
+else
+  WINDRES=
+fi
+
+AC_SUBST(WINDRES)
+
+# Check for custom PKG_CONFIG
+PKG_CONFIG=${PKG_CONFIG-pkg-config}
+
 # Check for full floating-point support, including Infinity and NaN
 IEEEFLAG=
 LOC_CHECK_FP_INF_NAN([],
@@ -64,7 +77,7 @@ AC_SUBST(BINDIR)
 
 AC_PATH_PROG(pwd, pwd, pwd)
 
-if test "$MINGW32" = yes ; then
+if test "$MINGW32" = yes -a "$cross_compiling" != yes ; then
   winpwd="pwd -W"
 else
   winpwd="$pwd"
@@ -1658,14 +1671,14 @@ if test -n "$USE_X11"; then
 	pkgs="$pkgs cairo-xlib cairo-xlib-xrender"
 fi
 for pkg in $pkgs ; do
-    if pkg-config --exists $pkg ; then
+    if $PKG_CONFIG --exists $pkg ; then
         cairo="$cairo $pkg"
     fi
 done
 
 # With Cairo includes directory
 #FIXME: somehow quote dirs with spaces in $cairo ?
-CAIROINC=`pkg-config --cflags $cairo`
+CAIROINC=`$PKG_CONFIG --cflags $cairo`
 
 LOC_CHECK_INC_PATH(cairo,cairo,CAIROINC)
 
@@ -1673,7 +1686,7 @@ LOC_CHECK_INCLUDES(cairo.h,Cairo,$CAIROINC)
 
 # With Cairo library directory
 
-CAIROLIB=`pkg-config --libs $cairo`
+CAIROLIB=`$PKG_CONFIG --libs $cairo`
 
 LOC_CHECK_LIB_PATH(cairo,cairo,CAIROLIB)
 LOC_CHECK_LDFLAGS(cairo,cairo,CAIROLIB)

+ 2 - 2
general/manage/lister/Makefile

@@ -7,9 +7,9 @@ EXTRA_CFLAGS = $(VECT_CFLAGS)
 
 include $(MODULE_TOPDIR)/include/Make/Module.make
 
-default: $(ETC)/lister/cell $(ETC)/lister/vector
+default: $(ETC)/lister/cell$(EXE) $(ETC)/lister/vector$(EXE)
 
-$(ETC)/lister/%: $(OBJDIR)/%.o | $(ETC)/lister
+$(ETC)/lister/%$(EXE): $(OBJDIR)/%.o | $(ETC)/lister
 	$(call linker)
 
 $(ETC)/lister:

+ 2 - 0
gui/wxpython/Makefile

@@ -28,10 +28,12 @@ PYDSTDIRS := $(patsubst %,$(DSTDIR)/%,animation core datacatalog dbmgr gcp gmode
 DSTDIRS := $(patsubst %,$(DSTDIR)/%,icons scripts xml)
 
 default: $(DSTFILES)
+ifndef CROSS_COMPILING
 	-$(MAKE) $(DSTDIR)/xml/module_items.xml
 	-$(MAKE) xml/menudata.xml
 	-$(MAKE) xml/module_tree_menudata.xml
 	-$(MAKE) menustrings.py
+endif
 	$(MAKE) parsubdirs
 
 

+ 0 - 1
include/Make/Grass.make

@@ -81,7 +81,6 @@ VECT_CFLAGS =  $(GDALCFLAGS) $(GEOSCFLAGS)
 
 # Object with _fmode which must be linked to each executable on Windows
 ifdef MINGW
-WINDRES = windres
 FMODE_OBJ = $(BASE_LIBDIR)/fmode.o
 # if fmode.o causes trouble, try:
 # FMODE_OBJ = /lib/binmode.o

+ 3 - 0
include/Make/GuiScript.make

@@ -20,9 +20,12 @@ endif
 PYFILES  := $(patsubst %,$(SCRIPTDIR)/g.gui.%$(SCRIPTEXT),$(MODULES))
 
 guiscript: $(IMGDST) $(PYFILES) $(BATFILES)
+# we cannot use cross-compiled g.parser for generating html files
+ifndef CROSS_COMPILING
 	$(MAKE) $(CMDHTML)
 	-rm -f g.gui.*.tmp.html
 	$(MAKE) $(GUIHTML)
+endif
 
 $(HTMLDIR)/g.gui.%.html: g.gui.%.html g.gui.%.tmp.html | $(HTMLDIR)
 	VERSION_NUMBER=$(GRASS_VERSION_NUMBER) VERSION_DATE=$(GRASS_VERSION_DATE) MODULE_TOPDIR=$(MODULE_TOPDIR) \

+ 1 - 0
include/Make/Platform.make.in

@@ -250,6 +250,7 @@ LFS_CFLAGS          = @LFS_CFLAGS@
 HAVE_SOCKET         = @HAVE_SOCKET@
 
 MINGW		    = @MINGW32@
+WINDRES		    = @WINDRES@
 MACOSX_APP	    = @MACOSX_APP@
 MACOSX_ARCHS        = @MACOSX_ARCHS@
 MACOSX_SDK          = @MACOSX_SDK@

+ 5 - 0
include/Make/Rules.make

@@ -22,12 +22,17 @@ $(ARCH_INCDIR)/%.h: %.h
 	$(INSTALL_DATA) $< $@
 
 ifneq ($(MINGW),)
+ifdef CROSS_COMPILING
+# build system is not MS Windows when cross-compiling
+mkpath = $(1):$(2)
+else
 ifeq ($(wildcard $(TOOLSDIR)/g.echo$(EXE)),)
 # dummy path until g.echo.exe gets compiled and is needed
 mkpath = $(1);$(2)
 else
 mkpath = $(shell $(TOOLSDIR)/g.echo$(EXE) $(1));$(2)
 endif
+endif
 else
 mkpath = $(1):$(2)
 endif

+ 2 - 0
raster/r.colors/Makefile

@@ -13,7 +13,9 @@ include $(MODULE_TOPDIR)/include/Make/Multi.make
 default: multi thumbnails
 
 thumbnails: $(BIN)/r.mapcalc$(EXE) $(BIN)/r.colors$(EXE) $(HTMLDIR)/colortables
+ifndef CROSS_COMPILING
 	-$(call run_grass, $(GRASS_HOME)/tools/thumbnails.py)
+endif
 
 $(HTMLDIR)/colortables: $(HTMLDIR)
 	$(MKDIR) $@