# HG changeset patch
# User Markus Mützel <markus.muetzel@gmx.de>
# Date 1599599078 -7200
#      Tue Sep 08 23:04:38 2020 +0200
# Node ID 334ebc89650159f6a0dc1d8419ef5f626ee7f918
# Parent  580b332c151b58eb0b2487fc63421d5865c32f52
[wip]: Add build-octave target

diff -r 580b332c151b -r 334ebc896501 Makefile.in
--- a/Makefile.in	Tue Sep 08 16:04:48 2020 +0200
+++ b/Makefile.in	Tue Sep 08 23:04:38 2020 +0200
@@ -257,6 +257,8 @@
 
 BUILD_COMPILER_TOOLS := build-gcc build-binutils
 BUILD_TOOLS := $(ALL_BUILD_TOOLS)
+# build-octave is added as an explicit dependency in the of- package that need it
+BUILD_TOOLS := $(filter-out build-octave, $(BUILD_TOOLS))
 # Building flex for native mingw fails, so disable it.
 ifeq ($(MXE_NATIVE_MINGW_BUILD),yes)
   REQUIREMENTS += flex
@@ -307,6 +309,7 @@
 TMP_DIR     = $(TOP_BUILD_DIR)/tmp-$(1)
 MAKEFILE   := $(TOP_BUILD_DIR)/Makefile
 PKGS       := $(filter-out $(ALL_BUILD_TOOLS), $(shell $(SED) -n 's/^.* class="package">\([^<]*\)<.*$$/\1/p' '$(TOP_DIR)/index.html'))
+PKGS += build-octave
 
 ENV_PATH := $(PATH)
 PATH := $(BUILD_TOOLS_PREFIX)/bin:$(PATH)
diff -r 580b332c151b -r 334ebc896501 dist-files.mk
--- a/dist-files.mk	Tue Sep 08 16:04:48 2020 +0200
+++ b/dist-files.mk	Tue Sep 08 23:04:38 2020 +0200
@@ -41,6 +41,7 @@
   build-meson.mk \
   build-msvctools.mk \
   build-ninja.mk \
+  build-octave.mk \
   build-perl.mk \
   build-pkg-config-1-fixes.patch \
   build-pkg-config.mk \
diff -r 580b332c151b -r 334ebc896501 index.html
--- a/index.html	Tue Sep 08 16:04:48 2020 +0200
+++ b/index.html	Tue Sep 08 23:04:38 2020 +0200
@@ -1050,6 +1050,10 @@
         <td class="website"><a href="https://ninja-build.org/">build-ninja</a></td>
     </tr>
     <tr>
+        <td class="package">build-octave</td>
+        <td class="website">Minimal version of <a href="http://www.octave.org">Octave</a> for cross-compiling some binary packages</td>
+    </tr>
+    <tr>
         <td class="package">build-perl</td>
         <td class="website"><a href="http://www.perl.org">perl</a></td>
     </tr>
diff -r 580b332c151b -r 334ebc896501 src/build-octave.mk
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/build-octave.mk	Tue Sep 08 23:04:38 2020 +0200
@@ -0,0 +1,51 @@
+# This file is part of MXE.
+# See index.html for further information.
+
+## This set of rules is intended for building a minimal version of Octave
+## on the build system.  Some Octave Forge packages need Octave as a build
+## tool.  Whereever possible, packages should try not to depend on Octave
+## as a build tool.
+## It is assumed that the necessary dependencies for a native build are
+## present on the build system.
+
+PKG             := build-octave
+$(PKG)_IGNORE   :=
+$(PKG)_VERSION  := $($(OCTAVE_TARGET)_VERSION)
+$(PKG)_CHECKSUM := $($(OCTAVE_TARGET)_CHECKSUM)
+$(PKG)_SUBDIR   := $($(OCTAVE_TARGET)_SUBDIR)
+$(PKG)_FILE     := $($(OCTAVE_TARGET)_FILE)
+$(PKG)_URL      := $($(OCTAVE_TARGET)_URL)
+$(PKG)_DEPS     :=
+## blas arpack curl epstool $($(PKG)_FONTCONFIG) ghostscript gl2ps gnuplot lapack pcre portaudio pstoedit qhull qrupdate
+
+define $(PKG)_UPDATE
+    echo 'Warning: Updates are temporarily disabled for package octave.' >&2;
+    echo $($(PKG)_VERSION)
+endef
+
+$(PKG)_ENV_FLAGS := \
+    PKG_CONFIG_PATH='$(BUILD_PKG_CONFIG_PATH)' \
+    LD_LIBRARY_PATH='$(LD_LIBRARY_PATH)' \
+    PATH='$(ENV_PATH)'
+
+define $(PKG)_BUILD
+echo $(OCTAVE_TARGET)_FILE
+echo $(PKG)_FILE
+    mkdir '$(1)/.build'
+    cd '$(1)/.build' && \
+        $($(PKG)_ENV_FLAGS) '$(1)/configure' --prefix=$(ROOT_PREFIX) \
+        --disable-docs --disable-fftw-threads --disable-java --disable-jit \
+        --disable-openmp --disable-readline --without-amd --without-arpack \
+        --without-bz2 --without-camd --without-ccolamd --without-cholmod \
+        --without-colamd --without-curl --without-cxsparse --without-fftw3 \
+        --without-fftw3f --without-fltk --without-fontconfig \
+        --without-framework-opengl --without-freetype --without-glpk \
+        --without-hdf5 --without-klu --without-magick --without-opengl \
+        --without-openssl --without-osmesa --without-portaudio \
+        --without-qhull --without-qrupdate --without-qscintilla \
+        --without-qt --without-sndfile --without-sundials_ida \
+        --without-sundials_nvecserial --without-umfpack --without-x \
+        --without-z
+
+    $($(PKG)_ENV_FLAGS) $(MAKE) all -C '$(1)/.build' -j '$(JOBS)' install
+endef
diff -r 580b332c151b -r 334ebc896501 src/of-image.mk
--- a/src/of-image.mk	Tue Sep 08 16:04:48 2020 +0200
+++ b/src/of-image.mk	Tue Sep 08 23:04:38 2020 +0200
@@ -9,10 +9,13 @@
 $(PKG)_SUBDIR   := image-$($(PKG)_VERSION)
 $(PKG)_FILE     := image-$($(PKG)_VERSION).tar.gz
 $(PKG)_URL      := '$(OCTAVE_FORGE_BASE_URL)/$($(PKG)_FILE)/download'
-$(PKG)_DEPS     := 
+$(PKG)_DEPS     :=
 
 ifeq ($(ENABLE_BINARY_PACKAGES),yes)
     $(PKG)_DEPS += $(OCTAVE_TARGET)
+    ifeq ($(MXE_NATIVE_BUILD),no)
+        $(PKG)_DEPS += build-octave
+    endif
 endif
 
 define $(PKG)_UPDATE
diff -r 580b332c151b -r 334ebc896501 src/of-statistics.mk
--- a/src/of-statistics.mk	Tue Sep 08 16:04:48 2020 +0200
+++ b/src/of-statistics.mk	Tue Sep 08 23:04:38 2020 +0200
@@ -13,6 +13,9 @@
 
 ifeq ($(ENABLE_BINARY_PACKAGES),yes)
     $(PKG)_DEPS += $(OCTAVE_TARGET)
+    ifeq ($(MXE_NATIVE_BUILD),no)
+        $(PKG)_DEPS += build-octave
+    endif
 endif
 
 define $(PKG)_UPDATE
