unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* mingw guile.exe cross build patch series v9
@ 2016-08-09  6:41 Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 01/11] gnu: Add gcc-cross-x86_64 packages for testing Jan Nieuwenhuizen
                   ` (11 more replies)
  0 siblings, 12 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

Hi!

Finally I have the next iteration ready.  After adressing all comments on v8
and rebasing, the patches only built on core-updates.  I spent a some time to
find the problem with master and cherry-picking from core-updates before
giving up.

Now that core-updates has been merged the mingw cross patches build again.

As suggested by Ludovic, I have tested all individual patches with the
script below.

There are no additional changes except for adding gcc-cross-x86_64 package
descriptions to run these tests.

Greetings,
Jan

TEST
--8<---------------cut here---------------start------------->8---
#! /bin/bash -ex

make clean || true
./bootstrap
./configure --localstatedir=/var
make

./pre-inst-env guix build gcc-cross-sans-libc-x86_64-linux-gnu
./pre-inst-env guix build gcc-cross-x86_64-linux-gnu
./pre-inst-env guix build hello
./pre-inst-env guix build guile

./pre-inst-env guix build --target=mips64el-linux-gnuabi64 hello

if grep mingw gnu/packages/cross-base.scm; then
    ./pre-inst-env guix build --target=i686-w64-mingw32 hello
fi

if grep mingw gnu/packages/multiprecision.scm; then
    ./pre-inst-env guix build --target=i686-w64-mingw32 gmp
fi

if grep mingw gnu/packages/ncurses.scm; then
    ./pre-inst-env guix build --target=i686-w64-mingw32 ncurses
fi

if grep mingw gnu/packages/readline.scm; then
    ./pre-inst-env guix build --target=i686-w64-mingw32 readline
fi

if grep mingw gnu/packages/guile.scm; then
    ./pre-inst-env guix build --target=i686-w64-mingw32 guile
fi
--8<---------------cut here---------------end--------------->8---

^ permalink raw reply	[flat|nested] 33+ messages in thread

* [PATCH 01/11] gnu: Add gcc-cross-x86_64 packages for testing.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 02/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/cross-base.scm: (xgcc-sans-libc-x86_64-linux-gnu,
xgcc-x86_64-linux-gnu): New variables.
---
 gnu/packages/cross-base.scm | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 3bd30fd..cb53668 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -402,3 +402,14 @@ XBINUTILS and the cross tool chain."
 ;;     (cross-gcc triplet
 ;;                (cross-binutils triplet)
 ;;                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-x86_64-linux-gnu
+  (let ((triplet "x86_64-linux-gnu"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xgcc-x86_64-linux-gnu
+  (let ((triplet "x86_64-linux-gnu"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-libc triplet))))
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 02/11] gnu: Add mingw-w64.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 01/11] gnu: Add gcc-cross-x86_64 packages for testing Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  7:28   ` Alex Kost
  2016-08-09  6:41 ` [PATCH 03/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
                   ` (9 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch,
gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch,
gnu/packages/mingw.scm: New files.
* gnu/local.mk (dist_patch_DATA): Add them.
---
 gnu/local.mk                                       |   3 +
 gnu/packages/mingw.scm                             |  81 ++++++++
 .../patches/gcc-4.9.3-mingw-gthr-default.patch     |  11 ++
 .../patches/mingw-w64-5.0rc2-gcc-4.9.3.patch       | 218 +++++++++++++++++++++
 4 files changed, 313 insertions(+)
 create mode 100644 gnu/packages/mingw.scm
 create mode 100644 gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
 create mode 100644 gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c7311a4..d468280 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -234,6 +234,7 @@ GNU_SYSTEM_MODULES =				\
   %D%/packages/mc.scm				\
   %D%/packages/mcrypt.scm			\
   %D%/packages/messaging.scm			\
+  %D%/packages/mingw.scm			\
   %D%/packages/mg.scm				\
   %D%/packages/mit-krb5.scm			\
   %D%/packages/moe.scm				\
@@ -512,6 +513,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gcc-arm-link-spec-fix.patch		\
   %D%/packages/patches/gcc-cross-environment-variables.patch	\
   %D%/packages/patches/gcc-libvtv-runpath.patch			\
+  %D%/packages/patches/gcc-4.9.3-mingw-gthr-default.patch	\
   %D%/packages/patches/gcc-5.0-libvtv-runpath.patch		\
   %D%/packages/patches/gd-fix-gd2-read-test.patch		\
   %D%/packages/patches/gd-fix-tests-on-i686.patch		\
@@ -658,6 +660,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/mcrypt-CVE-2012-4426.patch			\
   %D%/packages/patches/mcrypt-CVE-2012-4527.patch			\
   %D%/packages/patches/mhash-keygen-test-segfault.patch		\
+  %D%/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch		\
   %D%/packages/patches/mpc123-initialize-ao.patch		\
   %D%/packages/patches/mplayer2-theora-fix.patch		\
   %D%/packages/patches/module-init-tools-moduledir.patch	\
diff --git a/gnu/packages/mingw.scm b/gnu/packages/mingw.scm
new file mode 100644
index 0000000..aa9f53a
--- /dev/null
+++ b/gnu/packages/mingw.scm
@@ -0,0 +1,81 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (gnu packages mingw)
+  #:use-module ((guix licenses) #:prefix license:)
+  #:use-module (gnu packages)
+  #:use-module (gnu packages base)
+  #:use-module (gnu packages cross-base)
+  #:use-module (gnu packages gcc)
+  #:use-module (gnu packages compression)
+  #:use-module (gnu packages multiprecision)
+  #:use-module (guix build-system gnu)
+  #:use-module (guix packages)
+  #:use-module (guix download)
+  #:use-module (guix utils)
+  #:use-module (ice-9 match))
+
+(define-public mingw-w64
+  (package
+    (name "mingw-w64")
+    (version "5.0-rc2")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/"
+                    "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
+              (sha256
+               (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9"))
+              (patches (search-patches "mingw-w64-5.0rc2-gcc-4.9.3.patch"))))
+    (native-inputs `(("xgcc-core" ,xgcc-sans-libc-i686-w64-mingw32)
+                     ("xbinutils" ,xbinutils-i686-w64-mingw32)))
+    (build-system gnu-build-system)
+    (search-paths
+     (list (search-path-specification
+            (variable "CROSS_C_INCLUDE_PATH")
+            (files '("include" "i686-w64-mingw32/include")))
+           (search-path-specification
+            (variable "CROSS_LIBRARY_PATH")
+            (files
+             '("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib64")))))
+    (arguments
+     `(#:configure-flags '("--host=i686-w64-mingw32")
+       #:phases (modify-phases %standard-phases
+         (add-before
+             'configure 'setenv
+           (lambda _
+             (let ((xgcc-core (assoc-ref %build-inputs "xgcc-core"))
+                   (mingw-headers (string-append (getcwd) "/mingw-w64-headers")))
+               (setenv "CPP"
+                       (string-append xgcc-core "/bin/i686-w64-mingw32-cpp"))
+               (setenv "CROSS_C_INCLUDE_PATH"
+                       (string-append
+                        mingw-headers
+                        ":" mingw-headers "/include"
+                        ":" mingw-headers "/crt"
+                        ":" mingw-headers "/defaults/include"
+                        ":" mingw-headers "/direct-x/include"))))))
+       #:make-flags (list "DEFS=-DHAVE_CONFIG_H -D__MINGW_HAS_DXSDK=1")
+       #:tests? #f ; compiles and includes glibc headers
+       #:strip-binaries? #f))
+    (home-page "http://mingw.org")
+    (synopsis "Minimalist GNU for Windows")
+    (description "MinGW provides a complete Open Source programming tool set
+which is suitable for the development of native MS-Windows applications, and
+which does not depend on any 3rd-party C-Runtime dlls.")
+    (license license:fdl1.3+)))
diff --git a/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch b/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
new file mode 100644
index 0000000..0ea008a
--- /dev/null
+++ b/gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch
@@ -0,0 +1,11 @@
+--- a/libgcc/config/i386/gthr-win32.h	2016-03-30 07:45:33.388684463 +0200
++++ b/libgcc/config/i386/gthr-win32.h	2016-03-30 15:51:24.123896436 +0200
+@@ -30,7 +30,7 @@
+
+ /* Make sure CONST_CAST2 (origin in system.h) is declared.  */
+ #ifndef CONST_CAST2
+-#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((__extension__(union {FROMTYPE _q; TOTYPE _nq;})(X))._nq)
++#define CONST_CAST2(TOTYPE,FROMTYPE,X) ((TOTYPE)X)
+ #endif
+
+ /* Windows32 threads specific definitions. The windows32 threading model
diff --git a/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch b/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch
new file mode 100644
index 0000000..e8f841c
--- /dev/null
+++ b/gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch
@@ -0,0 +1,218 @@
+This patch includes
+
+   * mingw-w64-headers/include/winnt.h: compile fixes for1 gcc-4.9.3
+   * mingw-w64-headers/crt/math.h: Likewise
+   * mingw-w64-headers/crt/float.h (FLT_EPSILON,DBL_EPSILON,LDBL_EPSILON): Add
+   symbols.
+   * mingw-w64-headers/crt/stat.h (S_ISLNK,S_ISSOCK,S_ISUID,S_ISGID,S_ISLINK):
+   Add symbols.
+   (lstat): Add function.
+   * mingw-w64-headers/crt/_mingw_stat64.h: Likewise
+   * mingw-w64-headers/crt/stdlib.h (realpath): Add function.
+
+Needed for building with gcc-4.9.3 and using with cross-libtool-2.4.6.
+
+Upstream status: not yet presented upstream.
+
+index 9c5cf87..74a8541 100644
+--- a/mingw-w64-crt/misc/dirname.c
++++ b/mingw-w64-crt/misc/dirname.c
+@@ -29,6 +29,12 @@
+ #define __cdecl  /* this may not be defined.                   */
+ #endif
+ 
++char *__cdecl
++realpath(const char *name, char *resolved)
++{
++  return resolved ? strcpy (resolved, name) : strdup (name);
++}
++
+ char * __cdecl
+ dirname(char *path)
+ {
+diff --git a/mingw-w64-headers/crt/_mingw_stat64.h b/mingw-w64-headers/crt/_mingw_stat64.h
+index 17e754c..7d2339b 100644
+--- a/mingw-w64-headers/crt/_mingw_stat64.h
++++ b/mingw-w64-headers/crt/_mingw_stat64.h
+@@ -2,13 +2,17 @@
+ 
+ #ifdef _USE_32BIT_TIME_T
+ #define _fstat32 _fstat
++#define _lstat32 _lstat
+ #define _stat32 _stat
+ #define _wstat32 _wstat
+ #define _fstat32i64 _fstati64
++#define _lstat32i64 _lstati64
+ #define _stat32i64 _stati64
+ #define _wstat32i64 _wstati64
+ #else
+ #define _fstat _fstat64i32
++#define _lstat _lstat64i32
++#define _lstati64 _lstat64
+ #define _fstati64 _fstat64
+ #define _stat _stat64i32
+ #define _stati64 _stat64
+diff --git a/mingw-w64-headers/crt/float.h b/mingw-w64-headers/crt/float.h
+index 5874f4e..bdf4ead 100644
+--- a/mingw-w64-headers/crt/float.h
++++ b/mingw-w64-headers/crt/float.h
+@@ -22,6 +22,15 @@
+ #if (__GNUC__ < 4)
+ #error Corrupt install of gcc-s internal headers, or search order was changed.
+ #else
++
++        /* From gcc-4.9.3 float.h.  */
++        #undef FLT_EPSILON
++        #undef DBL_EPSILON
++        #undef LDBL_EPSILON
++        #define FLT_EPSILON	__FLT_EPSILON__
++        #define DBL_EPSILON	__DBL_EPSILON__
++        #define LDBL_EPSILON	__LDBL_EPSILON__
++
+ 	/* #include_next <float_ginclude.h> */
+ 	
+    	/* Number of decimal digits, q, such that any floating-point number with q
+diff --git a/mingw-w64-headers/crt/math.h b/mingw-w64-headers/crt/math.h
+index 1e970f4..99a332f 100644
+--- a/mingw-w64-headers/crt/math.h
++++ b/mingw-w64-headers/crt/math.h
+@@ -216,6 +216,7 @@ extern "C" {
+ #endif
+   }
+ 
++#if 0
+   __CRT_INLINE long double __cdecl fabsl (long double x)
+   {
+ #ifdef __arm__
+@@ -226,6 +227,7 @@ extern "C" {
+     return res;
+ #endif
+   }
++#endif
+ 
+   __CRT_INLINE double __cdecl fabs (double x)
+   {
+@@ -905,7 +907,7 @@ __mingw_choose_expr (                                         \
+ /* 7.12.7.3  */
+   extern double __cdecl hypot (double, double) __MINGW_ATTRIB_DEPRECATED_MSVC2005; /* in libmoldname.a */
+   extern float __cdecl hypotf (float x, float y);
+-#ifndef __CRT__NO_INLINE
++#if 0 //ndef __CRT__NO_INLINE
+   __CRT_INLINE float __cdecl hypotf (float x, float y) { return (float) hypot ((double)x, (double)y);}
+ #endif
+   extern long double __cdecl hypotl (long double, long double);
+diff --git a/mingw-w64-headers/crt/stdlib.h b/mingw-w64-headers/crt/stdlib.h
+index dfc5ae4..6f0fee3 100644
+--- a/mingw-w64-headers/crt/stdlib.h
++++ b/mingw-w64-headers/crt/stdlib.h
+@@ -8,6 +8,7 @@
+ 
+ #include <crtdefs.h>
+ #include <limits.h>
++#include <string.h>
+ 
+ #if defined (__USE_MINGW_ANSI_STDIO) && ((__USE_MINGW_ANSI_STDIO + 0) != 0) && !defined (__USE_MINGW_STRTOX)
+ #define __USE_MINGW_STRTOX 1
+@@ -676,6 +677,8 @@ unsigned long __cdecl _lrotr(unsigned long,int);
+ 
+ #endif /* !__NO_ISOCEXT */
+ 
++char *__cdecl realpath (const char *name, char *resolved);
++
+ #ifdef __cplusplus
+ }
+ #endif
+diff --git a/mingw-w64-headers/crt/sys/stat.h b/mingw-w64-headers/crt/sys/stat.h
+index ed60219..d88b4f1 100644
+--- a/mingw-w64-headers/crt/sys/stat.h
++++ b/mingw-w64-headers/crt/sys/stat.h
+@@ -58,16 +58,21 @@ extern "C" {
+ #include <_mingw_stat64.h>
+ 
+ #define _S_IFMT 0xF000
++#define _S_IFLNK 0xA000
++#define _S_IFSOCK 0xC000
+ #define _S_IFDIR 0x4000
+ #define _S_IFCHR 0x2000
+ #define _S_IFIFO 0x1000
+ #define _S_IFREG 0x8000
++#define _S_ISUID 0x0400
++#define _S_ISGID 0x0200
+ #define _S_IREAD 0x0100
+ #define _S_IWRITE 0x0080
+ #define _S_IEXEC 0x0040
+ 
+   _CRTIMP int __cdecl _fstat32(int _FileDes,struct _stat32 *_Stat);
+   _CRTIMP int __cdecl _stat32(const char *_Name,struct _stat32 *_Stat);
++  static inline int __cdecl _lstat32(const char *_Name,struct _stat32 *_Stat) {return _stat32(_Name, _Stat);}
+   _CRTIMP int __cdecl _fstat64(int _FileDes,struct _stat64 *_Stat);
+   _CRTIMP int __cdecl _fstat32i64(int _FileDes,struct _stat32i64 *_Stat);
+   int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat);
+@@ -97,6 +102,9 @@ extern "C" {
+   _CRTIMP int __cdecl _stat64(const char *_Name,struct _stat64 *_Stat);
+   _CRTIMP int __cdecl _stat32i64(const char *_Name,struct _stat32i64 *_Stat);
+   int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat);
++  static inline int __cdecl _lstat64(const char *_Name,struct _stat64 *_Stat) {return _stat64(_Name, _Stat);}
++  static inline int __cdecl _lstat32i64(const char *_Name,struct _stat32i64 *_Stat) {return _stat32i64(_Name, _Stat);}
++  static inline int __cdecl _lstat64i32(const char *_Name,struct _stat64i32 *_Stat) {return _stat64i32(_Name, _Stat);}
+ #ifndef __CRT__NO_INLINE
+   __CRT_INLINE int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
+   {
+@@ -132,6 +140,8 @@ extern "C" {
+ #ifndef	NO_OLDNAMES
+ #define	_S_IFBLK	0x3000	/* Block: Is this ever set under w32? */
+ 
++#define S_IFLNK _S_IFLNK
++#define S_IFSOCK _S_IFSOCK
+ #define S_IFMT _S_IFMT
+ #define S_IFDIR _S_IFDIR
+ #define S_IFCHR _S_IFCHR
+@@ -162,6 +172,11 @@ extern "C" {
+ #define S_IXOTH    (S_IXGRP >> 3)
+ #define S_IRWXO    (S_IRWXG >> 3)
+ 
++#define S_ISUID _S_ISUID
++#define S_ISGID _S_ISGID
++
++#define S_ISLNK(m)	(((m) & S_IFMT) == S_IFLNK)
++#define S_ISSOCK(m)	(((m) & S_IFMT) == S_IFSOCK)
+ #define	S_ISDIR(m)	(((m) & S_IFMT) == S_IFDIR)
+ #define	S_ISFIFO(m)	(((m) & S_IFMT) == S_IFIFO)
+ #define	S_ISCHR(m)	(((m) & S_IFMT) == S_IFCHR)
+@@ -174,6 +189,7 @@ extern "C" {
+ int __cdecl stat(const char *_Filename,struct stat *_Stat);
+ int __cdecl fstat(int _Desc,struct stat *_Stat);
+ int __cdecl wstat(const wchar_t *_Filename,struct stat *_Stat);
++static inline int __cdecl lstat(const char *_Filename,struct stat *_Stat){return stat(_Filename, _Stat);}
+ 
+ #ifndef __CRT__NO_INLINE
+ #ifdef _USE_32BIT_TIME_T
+@@ -262,9 +278,11 @@ __CRT_INLINE int __cdecl
+ 
+ #if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
+ #ifdef _USE_32BIT_TIME_T
++#define lstat _lstat32i64
+ #define stat _stat32i64
+ #define fstat _fstat32i64
+ #else
++#define lstat _lstat64
+ #define stat _stat64
+ #define fstat _fstat64
+ #endif
+diff --git a/mingw-w64-headers/include/winnt.h b/mingw-w64-headers/include/winnt.h
+index 52af29b..8626396 100644
+--- a/mingw-w64-headers/include/winnt.h
++++ b/mingw-w64-headers/include/winnt.h
+@@ -6895,7 +6895,12 @@ __buildmemorybarrier()
+ 	  DWORD Reg : 3;
+ 	  DWORD R : 1;
+ 	  DWORD L : 1;
++/* C is used as a const specifier */
++#define save_C C
++#undef C
+ 	  DWORD C : 1;
++#define C save_C
++#undef save_C
+ 	  DWORD StackAdjust : 10;
+ 	} DUMMYSTRUCTNAME;
+       } DUMMYUNIONNAME;
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 03/11] gnu: cross-build: i686-w64-mingw32: new cross target.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 01/11] gnu: Add gcc-cross-x86_64 packages for testing Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 02/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 04/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* guix/utils.scm (mingw-target?): New function.
* gnu/packages/cross-base.scm (cross-gcc-snippet): New function for mingw.
(cross-gcc): Use it.
(cross-gcc-arguments, cross-gcc-patches, cross-gcc): Support mingw.
(native-libc, cross-newlib?): New functions.
(cross-libc): Use cross-newlib? to support mingw.
(xbinutils-i686-w64-mingw32, xgcc-sans-libc-i686-w64-mingw32,
xgcc-i686-w64-mingw32): New variables.
---
 gnu/packages/cross-base.scm | 300 +++++++++++++++++++++++++++++++-------------
 guix/utils.scm              |   5 +
 2 files changed, 221 insertions(+), 84 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index cb53668..294de40 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -19,12 +19,12 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages cross-base)
-  #:use-module (guix licenses)
   #:use-module (gnu packages)
-  #:use-module (gnu packages gcc)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages mingw)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix utils)
@@ -35,7 +35,8 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
-            cross-gcc))
+            cross-gcc
+            cross-newlib?))
 
 (define %xgcc
   ;; GCC package used as the basis for cross-compilation.  It doesn't have to
@@ -129,7 +130,12 @@ may be either a libc package or #f.)"
                                "--disable-libitm"
                                "--disable-libvtv"
                                "--disable-libsanitizer"
-                               )))
+                                ))
+
+                       ;; For a newlib (non-glibc) target
+                       ,@(if (cross-newlib? target)
+                             '("--with-newlib")
+                             '()))
 
                  ,(if libc
                       flags
@@ -171,7 +177,85 @@ may be either a libc package or #f.)"
                     ;; for cross-compilers.
                     (zero? (system* "make" "install-strip")))
                   ,phases))))
-          (if libc
+           (cond
+            ((mingw-target? target)
+             `(modify-phases ,phases
+                (add-before
+                 'configure 'set-cross-path
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; Add the cross mingw headers to CROSS_C_*_INCLUDE_PATH,
+                   ;; and remove them from C_*INCLUDE_PATH.
+                   (let ((libc (assoc-ref inputs "libc"))
+                         (gcc (assoc-ref inputs "gcc")))
+                     (define (cross? x)
+                       (and libc (string-prefix? libc x)))
+                     (define (unpacked-mingw-dir)
+                       (match
+                           (scandir
+                            "."
+                            (lambda (name) (string-contains name "mingw-w64")))
+                         ((mingw-dir)
+                          (string-append
+                           (getcwd) "/" mingw-dir "/mingw-w64-headers"))))
+                     (if libc
+                         (let ((cpath (string-append
+                                       libc "/include"
+                                       ":" libc "/i686-w64-mingw32/include")))
+                           (for-each (cut setenv <> cpath)
+                                     '("CROSS_C_INCLUDE_PATH"
+                                       "CROSS_CPLUS_INCLUDE_PATH"
+                                       "CROSS_OBJC_INCLUDE_PATH"
+                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                         ;; libc is false, so we are building xgcc-sans-libc
+                         ;; Add essential headers from mingw-w64.
+                         (let ((mingw-source (assoc-ref inputs "mingw-source")))
+                           (system* "tar" "xf" mingw-source)
+                           (let ((mingw-headers (unpacked-mingw-dir)))
+                             ;; We need _mingw.h which will gets built from
+                             ;; _mingw.h.in by mingw-w64's configure.  We cannot
+                             ;; configure mingw-w64 until we have
+                             ;; xgcc-sans-libc; substitute to the rescue.
+                             (copy-file (string-append mingw-headers
+                                                       "/crt/_mingw.h.in")
+                                        (string-append mingw-headers
+                                                       "/crt/_mingw.h"))
+                             (substitute* (string-append mingw-headers
+                                                         "/crt/_mingw.h")
+                               (("@MINGW_HAS_SECURE_API@")
+                                "#define MINGW_HAS_SECURE_API 1"))
+                             (let ((cpath
+                                    (string-append
+                                     mingw-headers "/include"
+                                     ":" mingw-headers "/crt"
+                                     ":" mingw-headers "/defaults/include")))
+                               (for-each (cut setenv <> cpath)
+                                         '("CROSS_C_INCLUDE_PATH"
+                                           "CROSS_CPLUS_INCLUDE_PATH"
+                                           "CROSS_OBJC_INCLUDE_PATH"
+                                           "CROSS_OBJCPLUS_INCLUDE_PATH"
+                                           "CROSS_LIBRARY_PATH"))))
+                             (when libc
+                               (setenv "CROSS_LIBRARY_PATH"
+                                       (string-append
+                                        libc "/lib"
+                                        ":" libc "/i686-w64-mingw32/lib")))))
+                     (setenv "CPP" (string-append gcc "/bin/cpp"))
+                     (for-each
+                      (lambda (var)
+                        (and=> (getenv var)
+                               (lambda (value)
+                                 (let* ((path (search-path-as-string->list
+                                               value))
+                                        (native-path (list->search-path-as-string
+                                                      (remove cross? path) ":")))
+                                   (setenv var native-path)))))
+                      '("C_INCLUDE_PATH"
+                        "CPLUS_INCLUDE_PATH"
+                        "OBJC_INCLUDE_PATH"
+                        "OBJCPLUS_INCLUDE_PATH"
+                        "LIBRARY_PATH"))
+                     #t)))))
+            (libc
               `(alist-cons-before
                 'configure 'set-cross-path
                 (lambda* (#:key inputs #:allow-other-keys)
@@ -208,16 +292,25 @@ may be either a libc package or #f.)"
                                 "OBJCPLUS_INCLUDE_PATH"
                                 "LIBRARY_PATH"))
                     #t))
-                ,phases)
-              phases)))))))
+                ,phases))
+          (else phases))))))))
 
 (define (cross-gcc-patches target)
   "Return GCC patches needed for TARGET."
   (cond ((string-prefix? "xtensa-" target)
          ;; Patch by Qualcomm needed to build the ath9k-htc firmware.
          (search-patches "ath9k-htc-firmware-gcc.patch"))
+        ((mingw-target? target)
+         (search-patches "gcc-4.9.3-mingw-gthr-default.patch"))
         (else '())))
 
+(define (cross-gcc-snippet target)
+  "Return GCC snippet needed for TARGET."
+  (cond ((mingw-target? target)
+         '(copy-recursively "libstdc++-v3/config/os/mingw32-w64"
+                            "libstdc++-v3/config/os/newlib"))
+        (else #f)))
+
 (define* (cross-gcc target
                     #:optional (xbinutils (cross-binutils target)) libc)
   "Return a cross-compiler for TARGET, where TARGET is a GNU triplet.  Use
@@ -232,7 +325,10 @@ GCC that does not target a libc; otherwise, target that libc."
                (append
                 (origin-patches (package-source %xgcc))
                 (cons (search-patch "gcc-cross-environment-variables.patch")
-                      (cross-gcc-patches target))))))
+                      (cross-gcc-patches target))))
+              (modules '((guix build utils)))
+              (snippet
+               (cross-gcc-snippet target))))
 
     ;; For simplicity, use a single output.  Otherwise libgcc_s & co. are not
     ;; found by default, etc.
@@ -242,6 +338,8 @@ GCC that does not target a libc; otherwise, target that libc."
      `(#:implicit-inputs? #f
        #:modules ((guix build gnu-build-system)
                   (guix build utils)
+                  (ice-9 ftw)
+                  (ice-9 match)
                   (ice-9 regex)
                   (srfi srfi-1)
                   (srfi srfi-26))
@@ -262,13 +360,20 @@ GCC that does not target a libc; otherwise, target that libc."
        ;; Remaining inputs.
        ,@(let ((inputs (append (package-inputs %xgcc)
                                (alist-delete "libc" %final-inputs))))
-           (if libc
-               `(("libc" ,libc)
-                 ("xkernel-headers"                ;the target headers
-                  ,@(assoc-ref (package-propagated-inputs libc)
-                               "kernel-headers"))
-                 ,@inputs)
-               inputs))))
+           (cond
+            ((mingw-target? target)
+             (if libc
+                 `(("libc" ,mingw-w64)
+                   ,@inputs)
+                 `(("mingw-source" ,(package-source mingw-w64))
+                   ,@inputs)))
+            (libc
+             `(("libc" ,libc)
+               ("xkernel-headers"                ;the target headers
+                ,@(assoc-ref (package-propagated-inputs libc)
+                             "kernel-headers"))
+               ,@inputs))
+            (else inputs)))))
 
     (inputs '())
 
@@ -298,75 +403,87 @@ GCC that does not target a libc; otherwise, target that libc."
                      (xbinutils (cross-binutils target)))
   "Return a libc cross-built for TARGET, a GNU triplet.  Use XGCC and
 XBINUTILS and the cross tool chain."
-  (define xlinux-headers
-    (package (inherit linux-libre-headers)
-      (name (string-append (package-name linux-libre-headers)
-                           "-cross-" target))
-      (arguments
-       (substitute-keyword-arguments
-           `(#:implicit-cross-inputs? #f
-             ,@(package-arguments linux-libre-headers))
-         ((#:phases phases)
-          `(alist-replace
-            'build
-            (lambda _
-              (setenv "ARCH" ,(system->linux-architecture target))
-              (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
-
-              (and (zero? (system* "make" "defconfig"))
-                   (zero? (system* "make" "mrproper" "headers_check"))))
-            ,phases))))
-      (native-inputs `(("cross-gcc" ,xgcc)
-                       ("cross-binutils" ,xbinutils)
-                       ,@(package-native-inputs linux-libre-headers)))))
-
-  (package (inherit glibc)
-    (name (string-append "glibc-cross-" target))
-    (arguments
-     (substitute-keyword-arguments
-         `(;; Disable stripping (see above.)
-           #:strip-binaries? #f
-
-           ;; This package is used as a target input, but it should not have
-           ;; the usual cross-compilation inputs since that would include
-           ;; itself.
-           #:implicit-cross-inputs? #f
-
-           ;; We need SRFI 26.
-           #:modules ((guix build gnu-build-system)
-                      (guix build utils)
-                      (srfi srfi-26))
-
-           ,@(package-arguments glibc))
-       ((#:configure-flags flags)
-        `(cons ,(string-append "--host=" target)
-               ,flags))
-       ((#:phases phases)
-        `(alist-cons-before
-          'configure 'set-cross-kernel-headers-path
-          (lambda* (#:key inputs #:allow-other-keys)
-            (let* ((kernel (assoc-ref inputs "kernel-headers"))
-                   (cpath (string-append kernel "/include")))
-              (for-each (cut setenv <> cpath)
-                        '("CROSS_C_INCLUDE_PATH"
-                          "CROSS_CPLUS_INCLUDE_PATH"
-                          "CROSS_OBJC_INCLUDE_PATH"
-                          "CROSS_OBJCPLUS_INCLUDE_PATH"))
-              #t))
-          ,phases))))
-
-    ;; Shadow the native "kernel-headers" because glibc's recipe expects the
-    ;; "kernel-headers" input to point to the right thing.
-    (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
-
-    ;; FIXME: 'static-bash' should really be an input, not a native input, but
-    ;; to do that will require building an intermediate cross libc.
-    (inputs '())
-
-    (native-inputs `(("cross-gcc" ,xgcc)
-                     ("cross-binutils" ,xbinutils)
-                     ,@(package-inputs glibc)     ;FIXME: static-bash
-                     ,@(package-native-inputs glibc)))))
+  (cond
+   ((cross-newlib? target)
+    (native-libc target))
+   (else
+    (let ((xlinux-headers
+           (package (inherit linux-libre-headers)
+             (name (string-append (package-name linux-libre-headers)
+                                  "-cross-" target))
+             (arguments
+              (substitute-keyword-arguments
+                  `(#:implicit-cross-inputs? #f
+                    ,@(package-arguments linux-libre-headers))
+                ((#:phases phases)
+                 `(alist-replace
+                   'build
+                   (lambda _
+                     (setenv "ARCH" ,(system->linux-architecture target))
+                     (format #t "`ARCH' set to `~a' (cross compiling)~%"
+                             (getenv "ARCH"))
+
+                     (and (zero? (system* "make" "defconfig"))
+                          (zero? (system* "make" "mrproper" "headers_check"))))
+                   ,phases))))
+             (native-inputs `(("cross-gcc" ,xgcc)
+                              ("cross-binutils" ,xbinutils)
+                              ,@(package-native-inputs linux-libre-headers))))))
+      (package (inherit glibc)
+        (name (string-append "glibc-cross-" target))
+        (arguments
+         (substitute-keyword-arguments
+             `(;; Disable stripping (see above.)
+               #:strip-binaries? #f
+
+               ;; This package is used as a target input, but it should not have
+               ;; the usual cross-compilation inputs since that would include
+               ;; itself.
+               #:implicit-cross-inputs? #f
+
+               ;; We need SRFI 26.
+               #:modules ((guix build gnu-build-system)
+                          (guix build utils)
+                          (srfi srfi-26))
+
+               ,@(package-arguments glibc))
+           ((#:configure-flags flags)
+            `(cons ,(string-append "--host=" target)
+                   ,flags))
+           ((#:phases phases)
+            `(alist-cons-before
+              'configure 'set-cross-kernel-headers-path
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let* ((kernel (assoc-ref inputs "kernel-headers"))
+                       (cpath (string-append kernel "/include")))
+                  (for-each (cut setenv <> cpath)
+                            '("CROSS_C_INCLUDE_PATH"
+                              "CROSS_CPLUS_INCLUDE_PATH"
+                              "CROSS_OBJC_INCLUDE_PATH"
+                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  #t))
+              ,phases))))
+
+        ;; Shadow the native "kernel-headers" because glibc's recipe expects the
+        ;; "kernel-headers" input to point to the right thing.
+        (propagated-inputs `(("kernel-headers" ,xlinux-headers)))
+
+        ;; FIXME: 'static-bash' should really be an input, not a native input,
+        ;; but to do that will require building an intermediate cross libc.
+        (inputs '())
+
+        (native-inputs `(("cross-gcc" ,xgcc)
+                         ("cross-binutils" ,xbinutils)
+                         ,@(package-inputs glibc)     ;FIXME: static-bash
+                         ,@(package-native-inputs glibc))))))))
+
+(define (native-libc target)
+  (if (mingw-target? target)
+      mingw-w64
+      glibc))
+
+(define (cross-newlib? target)
+  (not (eq? (native-libc target) glibc)))
 
 \f
 ;;;
@@ -413,3 +530,18 @@ XBINUTILS and the cross tool chain."
     (cross-gcc triplet
                (cross-binutils triplet)
                (cross-libc triplet))))
+
+(define-public xgcc-sans-libc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet))))
+
+(define-public xbinutils-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-binutils triplet)))
+
+(define-public xgcc-i686-w64-mingw32
+  (let ((triplet "i686-w64-mingw32"))
+    (cross-gcc triplet
+               (cross-binutils triplet)
+               (cross-newlib? triplet))))
diff --git a/guix/utils.scm b/guix/utils.scm
index c68094c..e44504c 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -68,6 +68,7 @@
             gnu-triplet->nix-system
             %current-system
             %current-target-system
+            mingw-target?
             package-name->name+version
             version-compare
             version>?
@@ -487,6 +488,10 @@ returned by `config.guess'."
   ;; cross-building to.
   (make-parameter #f))
 
+(define* (mingw-target? #:optional (target (%current-target-system)))
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
 and \"0.9.1b\".  When the version part is unavailable, SPEC and #f are
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 04/11] gnu: Add function libiconv-if-needed.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (2 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 03/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/base.scm (libiconv-if-needed): New function.
---
 gnu/packages/base.scm | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index a476837..4eb5b25 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -46,7 +46,8 @@
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (ice-9 match)
-  #:export (glibc))
+  #:export (glibc
+            libiconv-if-needed))
 
 ;;; Commentary:
 ;;;
@@ -997,6 +998,16 @@ program.  It supports a wide variety of different encodings.")
     (home-page "http://www.gnu.org/software/libiconv/")
     (license lgpl3+)))
 
+(define* (libiconv-if-needed #:optional (target (%current-target-system)))
+  "Return either a libiconv package specification to include in a dependency
+list for platforms that have an incomplete libc, or the empty list.  If a
+package needs iconv ,@(libiconv-if-needed) should be added."
+  ;; POSIX C libraries provide iconv.  Platforms with an incomplete libc
+  ;; without iconv, such as MinGW, must return the then clause.
+  (if (mingw-target? target)
+      `(("libiconv" ,libiconv))
+      '()))
+
 (define-public (canonical-package package)
   ;; Avoid circular dependency by lazily resolving 'commencement'.
   (let* ((iface (resolve-interface '(gnu packages commencement)))
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (3 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 04/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  7:37   ` Alex Kost
  2016-08-09  6:41 ` [PATCH 06/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/libunistring (libunistring): propagated-inputs: add
libiconv-if-needed.  Fixes unicode translation in mingw.
---
 gnu/packages/libunistring.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/libunistring.scm b/gnu/packages/libunistring.scm
index f29b742..d2feac2 100644
--- a/gnu/packages/libunistring.scm
+++ b/gnu/packages/libunistring.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2015 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -21,7 +22,8 @@
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (gnu packages base))
 
 (define-public libunistring
   (package
@@ -35,7 +37,7 @@
             (sha256
              (base32
               "0ixxmgpgh2v8ifm6hbwsjxl023myk3dfnj7wnvmqjivza31fw9cn"))))
-   (propagated-inputs '())                  ; FIXME: add libiconv when !glibc
+   (propagated-inputs `(,@(libiconv-if-needed)))
    (build-system gnu-build-system)
    (arguments
     ;; Work around parallel build issue whereby C files may be compiled before
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 06/11] gnu: gmp: build shared library for mingw.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (4 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 07/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/multiprecision.scm (gmp)[MINGW]: Use --enable-shared.
---
 gnu/packages/multiprecision.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/multiprecision.scm b/gnu/packages/multiprecision.scm
index 46540be..0e9b49d 100644
--- a/gnu/packages/multiprecision.scm
+++ b/gnu/packages/multiprecision.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
 ;;; Copyright © 2016 Nicolas Goaziou <mail@nicolasgoaziou.fr>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -49,7 +50,13 @@
                 '(;; Build a "fat binary", with routines for several
                   ;; sub-architectures.
                   "--enable-fat"
-                  "--enable-cxx")))
+                  "--enable-cxx"
+                  ,@(cond ((mingw-target?)
+                           ;; Static and shared cannot be built in one go:
+                           ;; they produce different headers.  We need shared.
+                           `("--disable-static"
+                             "--enable-shared"))
+                          (else '())))))
    (synopsis "Multiple-precision arithmetic library")
    (description
     "GMP is a library for arbitrary precision arithmetic, operating on
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (5 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 06/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  7:53   ` Alex Kost
  2016-08-14 16:54   ` Mark H Weaver
  2016-08-09  6:41 ` [PATCH 08/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
                   ` (4 subsequent siblings)
  11 siblings, 2 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/ncurses-mingw.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/ncurses.scm (ncurses): Support mingw.
---
 gnu/local.mk                             |  1 +
 gnu/packages/ncurses.scm                 | 88 +++++++++++++++++++++++---------
 gnu/packages/patches/ncurses-mingw.patch | 24 +++++++++
 3 files changed, 89 insertions(+), 24 deletions(-)
 create mode 100644 gnu/packages/patches/ncurses-mingw.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index d468280..8829830 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -669,6 +669,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/mutt-store-references.patch		\
   %D%/packages/patches/mysql-fix-failing-test.patch		\
   %D%/packages/patches/nasm-no-ps-pdf.patch			\
+  %D%/packages/patches/ncurses-mingw.patch			\
   %D%/packages/patches/net-tools-bitrot.patch			\
   %D%/packages/patches/netcdf-config-date.patch			\
   %D%/packages/patches/ngircd-handle-zombies.patch		\
diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 147033a..840dcf2 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,9 +20,11 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages ncurses)
+  #:use-module (gnu packages)
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
+  #:use-module (guix utils)
   #:use-module (guix build-system gnu))
 
 (define-public ncurses
@@ -36,6 +39,7 @@
                     #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
                   (doc (assoc-ref outputs "doc")))
+              (format #t "configure flags: ~s~%" configure-flags)
               (zero? (apply system* "./configure"
                             (string-append "SHELL=" (which "sh"))
                             (string-append "--build=" build)
@@ -60,33 +64,66 @@
                "mandir=share/man"))
             #t))
         (post-install-phase
-         '(lambda* (#:key outputs #:allow-other-keys)
-            (let ((out (assoc-ref outputs "out")))
+         `(lambda* (#:key outputs target #:allow-other-keys)
+            (let ((out (assoc-ref outputs "out"))
+                  (mingw-target? (lambda* (#:optional (target target))
+                                   (and target
+                                        (string-suffix? "-mingw32" target))))
+                  (libraries '("curses" "ncurses" "form" "panel" "menu")))
               ;; When building a wide-character (Unicode) build, create backward
               ;; compatibility links from the the "normal" libraries to the
               ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
-              (with-directory-excursion (string-append out "/lib")
-                (for-each (lambda (lib)
-                            (define libw.a
-                              (string-append "lib" lib "w.a"))
-                            (define lib.a
-                              (string-append "lib" lib ".a"))
-                            (define libw.so.x
-                              (string-append "lib" lib "w.so.6"))
-                            (define lib.so.x
-                              (string-append "lib" lib ".so.6"))
-                            (define lib.so
-                              (string-append "lib" lib ".so"))
+              (cond
+               ((mingw-target? target)
+                (with-directory-excursion (string-append out "/bin")
+                  (for-each
+                   (lambda (lib)
+                     (define lib.dll
+                       (string-append "lib" lib ".dll"))
+                     (define libw6.dll
+                       (string-append "lib" lib "w6.dll"))
+
+                     (when (file-exists? libw6.dll)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw6.dll lib.dll)))
+                   libraries))
+                ;; TODO: create .la files to link to the .dll?
+                (with-directory-excursion (string-append out "/lib")
+                  (for-each
+                   (lambda (lib)
+                     (define libw.a
+                       (string-append "lib" lib "w.a"))
+                     (define lib.a
+                       (string-append "lib" lib ".a"))
+
+                     (when (file-exists? libw.a)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.a lib.a)))
+                   libraries)))
+               (else
+                (with-directory-excursion (string-append out "/lib")
+                  (for-each
+                   (lambda (lib)
+                     (define libw.a
+                       (string-append "lib" lib "w.a"))
+                     (define lib.a
+                       (string-append "lib" lib ".a"))
+                     (define libw.so.x
+                       (string-append "lib" lib "w.so.6"))
+                     (define lib.so.x
+                       (string-append "lib" lib ".so.6"))
+                     (define lib.so
+                       (string-append "lib" lib ".so"))
 
-                            (when (file-exists? libw.a)
-                              (format #t "creating symlinks for `lib~a'~%" lib)
-                              (symlink libw.a lib.a)
-                              (symlink libw.so.x lib.so.x)
-                              (false-if-exception (delete-file lib.so))
-                              (call-with-output-file lib.so
-                                (lambda (p)
-                                  (format p "INPUT (-l~aw)~%" lib)))))
-                          '("curses" "ncurses" "form" "panel" "menu")))))))
+                     (when (file-exists? libw.a)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.a lib.a)
+                       (symlink libw.so.x lib.so.x)
+                       (false-if-exception (delete-file lib.so))
+                       (call-with-output-file lib.so
+                         (lambda (p)
+                           (format p "INPUT (-l~aw)~%" lib)))))
+                   libraries))))))))
     (package
      (name "ncurses")
      (version "6.0")
@@ -94,6 +131,7 @@
               (method url-fetch)
               (uri (string-append "mirror://gnu/ncurses/ncurses-"
                                   version ".tar.gz"))
+              (patches (search-patches "ncurses-mingw.patch"))
               (sha256
                (base32
                 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
@@ -113,7 +151,9 @@
           ;; Make sure programs like 'tic', 'reset', and 'clear' have a
           ;; correct RUNPATH.
           ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
-                          "/lib"))
+                          "/lib")
+          ;; MinGW: Provide termcap api, created for the MinGW port.
+          ,@(if ,(mingw-target?) '("--enable-term-driver") '()))
         #:tests? #f                               ; no "check" target
         #:phases (modify-phases %standard-phases
                    (replace 'configure ,configure-phase)
diff --git a/gnu/packages/patches/ncurses-mingw.patch b/gnu/packages/patches/ncurses-mingw.patch
new file mode 100644
index 0000000..0f6a313
--- /dev/null
+++ b/gnu/packages/patches/ncurses-mingw.patch
@@ -0,0 +1,24 @@
+Taken from Eli Zaretskii's gdb bug report
+
+    https://sourceware.org/ml/gdb-patches/2012-04/msg01052.html
+
+Upstream status: Not presented to upstream.
+
+--- ncurses-6.0.orig/include/curses.h.in	2014-08-09 22:39:44.000000000 +0200
++++ ncurses-6.0/include/curses.h.in	2016-04-09 20:47:14.266679000 +0200
+@@ -1420,3 +1420,15 @@
+ #define KEY_BREAK	0401		/* Break key (unreliable) */
+ #define KEY_SRESET	0530		/* Soft (partial) reset (unreliable) */
+ #define KEY_RESET	0531		/* Reset or hard reset (unreliable) */
++
++#ifdef __MINGW32__
++/* Windows API headers, included e.g. by serial.h, define MOUSE_MOVED,
++   and so does PDCurses's curses.h, but for an entirely different
++   purpose.  Since we don't use the Windows semantics of MOUSE_MOVED
++   anywhere, avoid compiler warnings by undefining MOUSE_MOVED before
++   including curses.h.  */
++#undef MOUSE_MOVED
++/* Likewise, KEY_EVENT is defined by ncurses.h, but also by Windows
++   API headers.  */
++#undef KEY_EVENT
++#endif
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 08/11] gnu: cross-base: Add cross-libtool.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (6 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 07/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  8:08   ` Alex Kost
  2016-08-09  6:41 ` [PATCH 09/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
                   ` (3 subsequent siblings)
  11 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/cross-base.scm (cross-libtool): New function.
---
 gnu/packages/cross-base.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 52 insertions(+)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 294de40..f6c30ec 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -21,6 +21,7 @@
 (define-module (gnu packages cross-base)
   #:use-module (gnu packages)
   #:use-module (gnu packages base)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages commencement)
   #:use-module (gnu packages linux)
@@ -35,6 +36,7 @@
   #:use-module (ice-9 match)
   #:export (cross-binutils
             cross-libc
+            cross-libtool
             cross-gcc
             cross-newlib?))
 
@@ -477,6 +479,56 @@ XBINUTILS and the cross tool chain."
                          ,@(package-inputs glibc)     ;FIXME: static-bash
                          ,@(package-native-inputs glibc))))))))
 
+(define* (cross-libtool target
+                        #:optional
+                        (xgcc (cross-gcc target
+                                         (cross-binutils target)
+                                         (cross-libc target)))
+                        (xbinutils (cross-binutils target))
+                        (xlibc (cross-libc target)))
+  (package
+    (inherit libtool)
+    (name (string-append "cross-libtool-" target))
+    (inputs `(("xlibc" ,xlibc)))
+    (native-inputs `(("xgcc" ,xgcc)
+                     ("xbinutils" ,xbinutils)
+                     ("xlibc" ,xlibc)
+                     ,@(package-native-inputs libtool)))
+    (arguments
+     `(;; Libltdl is provided as a separate package, so don't install it here.
+       #:configure-flags
+       `("--disable-ltdl-install"
+         ;; The libtool script uses `host' rather than `target' to decide
+         ;; whether to use -lc, for example.
+         ,(string-append "--host=" ,target)
+         ,(string-append "--target=" ,target)
+         ,(string-append "--program-prefix=" ,target "-")
+         ,(string-append "CC=" ,target "-gcc"))
+       #:tests? #f
+       #:phases (modify-phases %standard-phases
+                  ;; As we are setup as a cross package, PATHs get setup
+                  ;; without the CROSS_ prefix.  Change that here.
+                  (add-before 'configure 'setenv
+                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
+                      (let ((xgcc (assoc-ref inputs "xgcc")))
+                        (setenv "CPP" (string-append xgcc "/bin/"
+                                                     ,target "-cpp"))
+                        (setenv "CXXCPP" (string-append xgcc "/bin/"
+                                                        ,target "-cpp")))
+                      (for-each (lambda (var)
+                                  (and=> (getenv var)
+                                         (lambda (value)
+                                           (let ((cross
+                                                  (string-append "CROSS_" var)))
+                                             (setenv cross value))
+                                           (unsetenv var))))
+                                '("C_INCLUDE_PATH"
+                                  "CPLUS_INCLUDE_PATH"
+                                  "OBJC_INCLUDE_PATH"
+                                  "OBJCPLUS_INCLUDE_PATH"
+                                  "LIBRARY_PATH"))
+                      #t)))))))
+
 (define (native-libc target)
   (if (mingw-target? target)
       mingw-w64
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 09/11] gnu: libtool: support cross-libtool mingw.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (7 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 08/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 10/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/libtool-mingw.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.
* gnu/packages/autotools.scm (libtool): Support cross-libtool for mingw.
---
 gnu/packages/autotools.scm               |  3 ++-
 gnu/packages/patches/libtool-mingw.patch | 28 ++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/patches/libtool-mingw.patch

diff --git a/gnu/packages/autotools.scm b/gnu/packages/autotools.scm
index 21ed0e6..f6706ca 100644
--- a/gnu/packages/autotools.scm
+++ b/gnu/packages/autotools.scm
@@ -295,7 +295,8 @@ Makefile, simplifying the entire process for the developer.")
               (sha256
                (base32
                 "0vxj52zm709125gwv9qqlw02silj8bnjnh4y07arrz60r31ai1vw"))
-              (patches (search-patches "libtool-skip-tests2.patch"))))
+              (patches (search-patches "libtool-skip-tests2.patch"
+                                       "libtool-mingw.patch"))))
     (build-system gnu-build-system)
     (propagated-inputs `(("m4" ,m4)))
     (native-inputs `(("m4" ,m4)
diff --git a/gnu/packages/patches/libtool-mingw.patch b/gnu/packages/patches/libtool-mingw.patch
new file mode 100644
index 0000000..d406f63
--- /dev/null
+++ b/gnu/packages/patches/libtool-mingw.patch
@@ -0,0 +1,28 @@
+With lstat and _lstat are added to MinGW we need to #define lstat along with
+stat because #define'ing stat impacts struct stat, which would otherwise break
+lstat's signature.
+
+Jan Nieuwenhuizen
+
+Upstream status: not yet presented upstream.
+
+--- libtool-2.4.6/build-aux/ltmain.in~	2015-02-06 13:57:56.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.in	2016-05-06 07:46:29.425142546 +0200
+@@ -3658,6 +3658,7 @@
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
++# define lstat   _lstat
+ # define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
+--- libtool-2.4.6/build-aux/ltmain.sh~	2015-02-15 17:15:12.000000000 +0100
++++ libtool-2.4.6/build-aux/ltmain.sh	2016-05-06 08:31:53.854857844 +0200
+@@ -5576,6 +5577,7 @@
+ # define S_IXUSR _S_IEXEC
+ #elif defined __MINGW32__
+ # define setmode _setmode
++# define lstat   _lstat
+ # define stat    _stat
+ # define chmod   _chmod
+ # define getcwd  _getcwd
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 10/11] gnu: ncurses: build mingw with libtool.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (8 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 09/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  6:41 ` [PATCH 11/11] gnu: readline: support mingw Jan Nieuwenhuizen
  2016-08-09  8:30 ` mingw guile.exe cross build patch series v9 Andy Wingo
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/ncurses.scm (ncurses)[MINGW]: Build with libtool, as
recommended; enables dlopen'ing.
---
 gnu/packages/ncurses.scm | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 840dcf2..4c255c9 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -27,6 +27,11 @@
   #:use-module (guix utils)
   #:use-module (guix build-system gnu))
 
+(define* (cross-libtool #:optional (target (%current-target-system)))
+  (let* ((libtool (resolve-interface '(gnu packages cross-base)))
+         (cross-libtool (module-ref libtool 'cross-libtool)))
+    `(("xlibtool" ,(cross-libtool target)))))
+
 (define-public ncurses
   (let ((patch-makefile-phase
          '(lambda _
@@ -80,14 +85,13 @@
                    (lambda (lib)
                      (define lib.dll
                        (string-append "lib" lib ".dll"))
-                     (define libw6.dll
-                       (string-append "lib" lib "w6.dll"))
+                     (define libw-6.dll
+                       (string-append "lib" lib "w-6.dll"))
 
-                     (when (file-exists? libw6.dll)
+                     (when (file-exists? libw-6.dll)
                        (format #t "creating symlinks for `lib~a'~%" lib)
-                       (symlink libw6.dll lib.dll)))
+                       (symlink libw-6.dll lib.dll)))
                    libraries))
-                ;; TODO: create .la files to link to the .dll?
                 (with-directory-excursion (string-append out "/lib")
                   (for-each
                    (lambda (lib)
@@ -95,10 +99,17 @@
                        (string-append "lib" lib "w.a"))
                      (define lib.a
                        (string-append "lib" lib ".a"))
+                     (define libw.la
+                       (string-append "lib" lib "w.la"))
+                     (define lib.la
+                       (string-append "lib" lib ".la"))
 
                      (when (file-exists? libw.a)
                        (format #t "creating symlinks for `lib~a'~%" lib)
-                       (symlink libw.a lib.a)))
+                       (symlink libw.a lib.a))
+                     (when (file-exists? libw.la)
+                       (format #t "creating symlinks for `lib~a'~%" lib)
+                       (symlink libw.la lib.la)))
                    libraries)))
                (else
                 (with-directory-excursion (string-append out "/lib")
@@ -135,6 +146,10 @@
               (sha256
                (base32
                 "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
+     ;; add to gnu:standard-cross-packages?
+     (native-inputs `(,@(if (mingw-target?)
+                            `(,@(cross-libtool))
+                            '())))
      (build-system gnu-build-system)
      (outputs '("out"
                 "doc"))                          ;1 MiB of man pages
@@ -152,8 +167,9 @@
           ;; correct RUNPATH.
           ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
                           "/lib")
-          ;; MinGW: Provide termcap api, created for the MinGW port.
-          ,@(if ,(mingw-target?) '("--enable-term-driver") '()))
+          ;; MinGW: Provide termcap api, created for the MinGW port,
+          ;; use litbool to build .la files to dlopen.
+          ,@(if ,(mingw-target?) `("--enable-term-driver" "--with-libtool") '()))
         #:tests? #f                               ; no "check" target
         #:phases (modify-phases %standard-phases
                    (replace 'configure ,configure-phase)
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* [PATCH 11/11] gnu: readline: support mingw.
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (9 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 10/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
@ 2016-08-09  6:41 ` Jan Nieuwenhuizen
  2016-08-09  8:30 ` mingw guile.exe cross build patch series v9 Andy Wingo
  11 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09  6:41 UTC (permalink / raw)
  To: guix-devel

* gnu/packages/patches/readline-6.3-mingw.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/readline.scm (readline): Support mingw.
---
 gnu/packages/readline.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/readline.scm b/gnu/packages/readline.scm
index 169a738..2df22dd 100644
--- a/gnu/packages/readline.scm
+++ b/gnu/packages/readline.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,7 +25,8 @@
   #:use-module (gnu packages perl)
   #:use-module (guix packages)
   #:use-module (guix download)
-  #:use-module (guix build-system gnu))
+  #:use-module (guix build-system gnu)
+  #:use-module (guix utils))
 
 (define-public readline
   (let ((post-install-phase
@@ -61,8 +63,18 @@
                          ;; cross-compiling, so provide the correct answer.
                          ,@(if (%current-target-system)
                                '("bash_cv_wcwidth_broken=no")
+                               '())
+                         ;; MinGW: ncurses provides the termcap api.
+                         ,@(if (mingw-target?)
+                               '("bash_cv_termcap_lib=ncurses")
                                '()))
 
+                   #:make-flags (list ,@(if (mingw-target?)
+                                            ;; MinGW: termcap in ncurses
+                                            ;; some SIG_* #defined in _POSIX
+                                            '("TERMCAP_LIB=-lncurses"
+                                              "CPPFLAGS=-D_POSIX")
+                                            '()))
                    #:phases (alist-cons-after
                              'install 'post-install
                              ,post-install-phase
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/11] gnu: Add mingw-w64.
  2016-08-09  6:41 ` [PATCH 02/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
@ 2016-08-09  7:28   ` Alex Kost
  2016-08-09 15:56     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Kost @ 2016-08-09  7:28 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Hello, I understand nothing in all this mingw stuff, I just have a couple
of insignificant comments.

Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:

> * gnu/packages/patches/gcc-4.9.3-mingw-gthr-default.patch,
> gnu/packages/patches/mingw-w64-5.0rc2-gcc-4.9.3.patch,
> gnu/packages/mingw.scm: New files.
> * gnu/local.mk (dist_patch_DATA): Add them.
[...]
> +(define-public mingw-w64
> +  (package
> +    (name "mingw-w64")
> +    (version "5.0-rc2")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append
> +                    "https://sourceforge.net/projects/mingw-w64/files/mingw-w64/"
> +                    "mingw-w64-release/mingw-w64-v" version ".tar.bz2"))
> +              (sha256
> +               (base32 "0imdary8j07if8ih73pfgxiclpf2ax8h3mz8mxln07i8sbbd30c9"))
> +              (patches (search-patches "mingw-w64-5.0rc2-gcc-4.9.3.patch"))))
> +    (native-inputs `(("xgcc-core" ,xgcc-sans-libc-i686-w64-mingw32)
> +                     ("xbinutils" ,xbinutils-i686-w64-mingw32)))
> +    (build-system gnu-build-system)
> +    (search-paths
> +     (list (search-path-specification
> +            (variable "CROSS_C_INCLUDE_PATH")
> +            (files '("include" "i686-w64-mingw32/include")))
> +           (search-path-specification
> +            (variable "CROSS_LIBRARY_PATH")
> +            (files
> +             '("lib" "lib64" "i686-w64-mingw32/lib" "i686-w64-mingw32/lib64")))))
> +    (arguments
> +     `(#:configure-flags '("--host=i686-w64-mingw32")
> +       #:phases (modify-phases %standard-phases
> +         (add-before
> +             'configure 'setenv

The indentation of this 'modify-phases' is not good.  I would write it
like this:

  #:phases
  (modify-phases %standard-phases
    (add-before 'configure 'setenv
      (lambda ...)))


> +           (lambda _
> +             (let ((xgcc-core (assoc-ref %build-inputs "xgcc-core"))

Here, instead of referring '%build-inputs', it is better (I mean it
would be more "functional") to use 'inputs' argument passed to this
phase, like this:

  (lambda* (#:key inputs #:allow-other-keys)
    (let ((xgcc-core (assoc-ref inputs "xgcc-core"))

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed.
  2016-08-09  6:41 ` [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
@ 2016-08-09  7:37   ` Alex Kost
  2016-08-09 16:00     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Kost @ 2016-08-09  7:37 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:

[...]
>  (define-public libunistring
>    (package
> @@ -35,7 +37,7 @@
>              (sha256
>               (base32
>                "0ixxmgpgh2v8ifm6hbwsjxl023myk3dfnj7wnvmqjivza31fw9cn"))))
> -   (propagated-inputs '())                  ; FIXME: add libiconv when !glibc
> +   (propagated-inputs `(,@(libiconv-if-needed)))

Or simply:

      (propagated-inputs (libiconv-if-needed))

>     (build-system gnu-build-system)
>     (arguments
>      ;; Work around parallel build issue whereby C files may be compiled before

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-09  6:41 ` [PATCH 07/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
@ 2016-08-09  7:53   ` Alex Kost
  2016-08-09 15:59     ` Jan Nieuwenhuizen
  2016-08-14 16:54   ` Mark H Weaver
  1 sibling, 1 reply; 33+ messages in thread
From: Alex Kost @ 2016-08-09  7:53 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:

> * gnu/packages/patches/ncurses-mingw.patch: New file.
> * gnu-system.am (dist_patch_DATA): Add it.
> * gnu/packages/ncurses.scm (ncurses): Support mingw.
[...]
>  (define-public ncurses
> @@ -36,6 +39,7 @@
>                      #:allow-other-keys)
>              (let ((out (assoc-ref outputs "out"))
>                    (doc (assoc-ref outputs "doc")))
> +              (format #t "configure flags: ~s~%" configure-flags)
>                (zero? (apply system* "./configure"
>                              (string-append "SHELL=" (which "sh"))
>                              (string-append "--build=" build)
> @@ -60,33 +64,66 @@
>                 "mandir=share/man"))
>              #t))
>          (post-install-phase
> -         '(lambda* (#:key outputs #:allow-other-keys)
> -            (let ((out (assoc-ref outputs "out")))
> +         `(lambda* (#:key outputs target #:allow-other-keys)
> +            (let ((out (assoc-ref outputs "out"))
> +                  (mingw-target? (lambda* (#:optional (target target))
> +                                   (and target
> +                                        (string-suffix? "-mingw32" target))))

IIUC you don't use the same 'mingw-target?' procedure you added in an
earlier patch, because it is placed in (guix utils), right?  I don't
know if (guix build utils) would be a better place for it, but I think
this 'mingw-target?' may be used by other packages quite often, so it
should be available by default to avoid the same definitions in other
packages.

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/11] gnu: cross-base: Add cross-libtool.
  2016-08-09  6:41 ` [PATCH 08/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
@ 2016-08-09  8:08   ` Alex Kost
  2016-08-09 16:04     ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Kost @ 2016-08-09  8:08 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:

> * gnu/packages/cross-base.scm (cross-libtool): New function.
> ---
>  gnu/packages/cross-base.scm | 52 +++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 52 insertions(+)
>
>
> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> index 294de40..f6c30ec 100644
> --- a/gnu/packages/cross-base.scm
> +++ b/gnu/packages/cross-base.scm
> @@ -21,6 +21,7 @@
>  (define-module (gnu packages cross-base)
>    #:use-module (gnu packages)
>    #:use-module (gnu packages base)
> +  #:use-module (gnu packages autotools)
>    #:use-module (gnu packages gcc)
>    #:use-module (gnu packages commencement)
>    #:use-module (gnu packages linux)
> @@ -35,6 +36,7 @@
>    #:use-module (ice-9 match)
>    #:export (cross-binutils
>              cross-libc
> +            cross-libtool
>              cross-gcc
>              cross-newlib?))
>  
> @@ -477,6 +479,56 @@ XBINUTILS and the cross tool chain."
>                           ,@(package-inputs glibc)     ;FIXME: static-bash
>                           ,@(package-native-inputs glibc))))))))
>  
> +(define* (cross-libtool target
> +                        #:optional
> +                        (xgcc (cross-gcc target
> +                                         (cross-binutils target)
> +                                         (cross-libc target)))
> +                        (xbinutils (cross-binutils target))
> +                        (xlibc (cross-libc target)))
> +  (package
> +    (inherit libtool)
> +    (name (string-append "cross-libtool-" target))
> +    (inputs `(("xlibc" ,xlibc)))
> +    (native-inputs `(("xgcc" ,xgcc)
> +                     ("xbinutils" ,xbinutils)
> +                     ("xlibc" ,xlibc)
> +                     ,@(package-native-inputs libtool)))
> +    (arguments
> +     `(;; Libltdl is provided as a separate package, so don't install it here.
> +       #:configure-flags
> +       `("--disable-ltdl-install"
> +         ;; The libtool script uses `host' rather than `target' to decide
> +         ;; whether to use -lc, for example.
> +         ,(string-append "--host=" ,target)
> +         ,(string-append "--target=" ,target)
> +         ,(string-append "--program-prefix=" ,target "-")
> +         ,(string-append "CC=" ,target "-gcc"))
> +       #:tests? #f
> +       #:phases (modify-phases %standard-phases
> +                  ;; As we are setup as a cross package, PATHs get setup
> +                  ;; without the CROSS_ prefix.  Change that here.
> +                  (add-before 'configure 'setenv
> +                    (lambda* (#:key inputs native-inputs #:allow-other-keys)

It looks like 'native-inputs' is not needed, as it is not used further.

> +                      (let ((xgcc (assoc-ref inputs "xgcc")))
> +                        (setenv "CPP" (string-append xgcc "/bin/"
> +                                                     ,target "-cpp"))
> +                        (setenv "CXXCPP" (string-append xgcc "/bin/"
> +                                                        ,target "-cpp")))

Since the values are the same, what about:

  (let* ((xgcc     (assoc-ref inputs "xgcc"))
         (xgcc-bin (string-append xgcc "/bin/" ,target "-cpp")))
    (setenv "CPP" xgcc-bin)
    (setenv "CXXCPP" xgcc-bin))

> +                      (for-each (lambda (var)
> +                                  (and=> (getenv var)
> +                                         (lambda (value)
> +                                           (let ((cross
> +                                                  (string-append "CROSS_" var)))
> +                                             (setenv cross value))
> +                                           (unsetenv var))))
> +                                '("C_INCLUDE_PATH"
> +                                  "CPLUS_INCLUDE_PATH"
> +                                  "OBJC_INCLUDE_PATH"
> +                                  "OBJCPLUS_INCLUDE_PATH"
> +                                  "LIBRARY_PATH"))

I have already seen this list of environment variables in an earlier
patch.  Perhaps it would be reasonable to make some global variable with
this list and to put it in (guix build utils) or another appropriate
place, WDYT?

> +                      #t)))))))
> +
>  (define (native-libc target)
>    (if (mingw-target? target)
>        mingw-w64

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: mingw guile.exe cross build patch series v9
  2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
                   ` (10 preceding siblings ...)
  2016-08-09  6:41 ` [PATCH 11/11] gnu: readline: support mingw Jan Nieuwenhuizen
@ 2016-08-09  8:30 ` Andy Wingo
  2016-08-09 15:41   ` Jan Nieuwenhuizen
  2016-08-10 11:03   ` Alex Kost
  11 siblings, 2 replies; 33+ messages in thread
From: Andy Wingo @ 2016-08-09  8:30 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

On Tue 09 Aug 2016 08:41, Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Finally I have the next iteration ready.  After adressing all comments on v8
> and rebasing, the patches only built on core-updates.  I spent a some time to
> find the problem with master and cherry-picking from core-updates before
> giving up.
>
> Now that core-updates has been merged the mingw cross patches build again.

All looks fine to me, though Alex's nits are good of course I'd be happy
to have this in Guix and then we work on it some more in place.  Note
that Guile 2.0 should now support `open-pipe' with MinGW and thus we
will need a static-bash at some point.  I don't think Guix has updated
to that Guile yet though, and probably we need to roll a new release
actually to fix a couple more MinGW things.

Andy

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: mingw guile.exe cross build patch series v9
  2016-08-09  8:30 ` mingw guile.exe cross build patch series v9 Andy Wingo
@ 2016-08-09 15:41   ` Jan Nieuwenhuizen
  2016-08-10 11:03   ` Alex Kost
  1 sibling, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09 15:41 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel, Alex Kost

Andy Wingo writes:

>> Now that core-updates has been merged the mingw cross patches build again.
>
> All looks fine to me, though Alex's nits are good of course I'd be happy
> to have this in Guix and then we work on it some more in place.

I have addressed all but one of Alex's comments, but not having to
rebuild and retest with all these 11 patches would be very nice!

> Note that Guile 2.0 should now support `open-pipe' with MinGW and thus
> we will need a static-bash at some point.  I don't think Guix has
> updated to that Guile yet though, and probably we need to roll a new
> release actually to fix a couple more MinGW things.

Bash for MinGW...fun :-)

Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/11] gnu: Add mingw-w64.
  2016-08-09  7:28   ` Alex Kost
@ 2016-08-09 15:56     ` Jan Nieuwenhuizen
  2016-08-10 10:37       ` Alex Kost
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09 15:56 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost writes:

> Hello, I understand nothing in all this mingw stuff, I just have a couple
> of insignificant comments.

Thanks for looking, they all make sense and I have addressed most.

With MinGW, you can cross build Windows binaries and run them with Wine,
like so

    ./pre-inst-env guix build --target=i686-w64-mingw32 hello
    /gnu/store/5lf701smnkq0wdg91jsyrmf5jnyz6i31-hello-2.10
    guix environment --ad-hoc wine -- wine /gnu/store/5lf701smnkq0wdg91jsyrmf5jnyz6i31-hello-2.10/bin/hello.exe

> Jan Nieuwenhuizen (2016-08-09 09:41 +0300) wrote:
>
>> +(define-public mingw-w64
...
>> +    (arguments
>> +     `(#:configure-flags '("--host=i686-w64-mingw32")
>> +       #:phases (modify-phases %standard-phases
>> +         (add-before
>> +             'configure 'setenv
>
> The indentation of this 'modify-phases' is not good.  I would write it
> like this:
>
>   #:phases
>   (modify-phases %standard-phases
>     (add-before 'configure 'setenv
>       (lambda ...)))

Ok.

>> +           (lambda _
>> +             (let ((xgcc-core (assoc-ref %build-inputs "xgcc-core"))
>
> Here, instead of referring '%build-inputs', it is better (I mean it
> would be more "functional") to use 'inputs' argument passed to this
> phase, like this:
>
>   (lambda* (#:key inputs #:allow-other-keys)
>     (let ((xgcc-core (assoc-ref inputs "xgcc-core"))

Ok.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-09  7:53   ` Alex Kost
@ 2016-08-09 15:59     ` Jan Nieuwenhuizen
  2016-08-10 10:47       ` Alex Kost
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09 15:59 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost writes:

>> +                  (mingw-target? (lambda* (#:optional (target target))
>> +                                   (and target
>> +                                        (string-suffix? "-mingw32" target))))
>
> IIUC you don't use the same 'mingw-target?' procedure you added in an
> earlier patch, because it is placed in (guix utils), right?

Yes, something like that: the function needs to be present at in the
builder, but I'm not sure how we can make that so.  I tried several
things but could not find a way to avoid this duplication.
mingw-target? is passed the TARGET from the post-install-phase.

> I don't know if (guix build utils) would be a better place for it ,

How would that work?  mingw-target? uses %current-build-system which is
defined in (guix utils).  I agree that it would be nice to remove this
duplication.

> but I think this 'mingw-target?' may be used by other packages quite
> often, so it should be available by default to avoid the same
> definitions in other packages.

The definition from (guix utils) is used in libiconv-if-needed, in
cross-gcc, in guile and in readline.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed.
  2016-08-09  7:37   ` Alex Kost
@ 2016-08-09 16:00     ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09 16:00 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost writes:

>> -   (propagated-inputs '())                  ; FIXME: add libiconv when !glibc
>> +   (propagated-inputs `(,@(libiconv-if-needed)))
>
> Or simply:
>
>       (propagated-inputs (libiconv-if-needed))

Ok, thanks.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/11] gnu: cross-base: Add cross-libtool.
  2016-08-09  8:08   ` Alex Kost
@ 2016-08-09 16:04     ` Jan Nieuwenhuizen
  2016-08-10 11:12       ` Alex Kost
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-09 16:04 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost writes:

>> +                  (add-before 'configure 'setenv
>> +                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
>
> It looks like 'native-inputs' is not needed, as it is not used further.

Indeed, dropped.

>> +                      (let ((xgcc (assoc-ref inputs "xgcc")))
>> +                        (setenv "CPP" (string-append xgcc "/bin/"
>> +                                                     ,target "-cpp"))
>> +                        (setenv "CXXCPP" (string-append xgcc "/bin/"
>> +                                                        ,target "-cpp")))
>
> Since the values are the same, what about:
>
>   (let* ((xgcc     (assoc-ref inputs "xgcc"))
>          (xgcc-bin (string-append xgcc "/bin/" ,target "-cpp")))
>     (setenv "CPP" xgcc-bin)
>     (setenv "CXXCPP" xgcc-bin))

That's better, thanks.

>> +                      (for-each (lambda (var)
>> +                                  (and=> (getenv var)
>> +                                         (lambda (value)
>> +                                           (let ((cross
>> +                                                  (string-append "CROSS_" var)))
>> +                                             (setenv cross value))
>> +                                           (unsetenv var))))
>> +                                '("C_INCLUDE_PATH"
>> +                                  "CPLUS_INCLUDE_PATH"
>> +                                  "OBJC_INCLUDE_PATH"
>> +                                  "OBJCPLUS_INCLUDE_PATH"
>> +                                  "LIBRARY_PATH"))
>
> I have already seen this list of environment variables in an earlier
> patch.  Perhaps it would be reasonable to make some global variable with
> this list and to put it in (guix build utils) or another appropriate
> place, WDYT?

I have quicke tested the additional patch below which seems to work.  It
would need some more testing.  How do you like that?

Greetings,
Jan


diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index f6c30ec..0d36143 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -45,6 +45,15 @@
   ;; be 'gcc' and can be a specific variant such as 'gcc-4.8'.
   gcc)
 
+(define gcc-include-paths
+  '("C_INCLUDE_PATH"
+    "CPLUS_INCLUDE_PATH"
+    "OBJC_INCLUDE_PATH"
+    "OBJCPLUS_INCLUDE_PATH"))
+
+(define gcc-cross-include-paths
+  (map (cut string-append "CROSS_" <>) gcc-include-paths))
+
 (define (cross p target)
   (package (inherit p)
     (name (string-append (package-name p) "-cross-" target))
@@ -204,10 +213,7 @@ may be either a libc package or #f.)"
                                        libc "/include"
                                        ":" libc "/i686-w64-mingw32/include")))
                            (for-each (cut setenv <> cpath)
-                                     '("CROSS_C_INCLUDE_PATH"
-                                       "CROSS_CPLUS_INCLUDE_PATH"
-                                       "CROSS_OBJC_INCLUDE_PATH"
-                                       "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                                     ',gcc-cross-include-paths))
                          ;; libc is false, so we are building xgcc-sans-libc
                          ;; Add essential headers from mingw-w64.
                          (let ((mingw-source (assoc-ref inputs "mingw-source")))
@@ -231,11 +237,9 @@ may be either a libc package or #f.)"
                                      ":" mingw-headers "/crt"
                                      ":" mingw-headers "/defaults/include")))
                                (for-each (cut setenv <> cpath)
-                                         '("CROSS_C_INCLUDE_PATH"
-                                           "CROSS_CPLUS_INCLUDE_PATH"
-                                           "CROSS_OBJC_INCLUDE_PATH"
-                                           "CROSS_OBJCPLUS_INCLUDE_PATH"
-                                           "CROSS_LIBRARY_PATH"))))
+                                         (cons
+                                          "CROSS_LIBRARY_PATH"
+                                          ',gcc-cross-include-paths))))
                              (when libc
                                (setenv "CROSS_LIBRARY_PATH"
                                        (string-append
@@ -251,11 +255,7 @@ may be either a libc package or #f.)"
                                         (native-path (list->search-path-as-string
                                                       (remove cross? path) ":")))
                                    (setenv var native-path)))))
-                      '("C_INCLUDE_PATH"
-                        "CPLUS_INCLUDE_PATH"
-                        "OBJC_INCLUDE_PATH"
-                        "OBJCPLUS_INCLUDE_PATH"
-                        "LIBRARY_PATH"))
+                      (cons "LIBRARY_PATH" ',gcc-include-paths))
                      #t)))))
             (libc
               `(alist-cons-before
@@ -272,11 +272,7 @@ may be either a libc package or #f.)"
                     (let ((cpath (string-append
                                   libc "/include"
                                   ":" kernel "/include")))
-                      (for-each (cut setenv <> cpath)
-                                '("CROSS_C_INCLUDE_PATH"
-                                  "CROSS_CPLUS_INCLUDE_PATH"
-                                  "CROSS_OBJC_INCLUDE_PATH"
-                                  "CROSS_OBJCPLUS_INCLUDE_PATH")))
+                      (for-each (cut setenv <> cpath) ',gcc-cross-include-paths))
                     (setenv "CROSS_LIBRARY_PATH"
                             (string-append libc "/lib:"
                                            kernel "/lib")) ;for Hurd's libihash
@@ -288,11 +284,7 @@ may be either a libc package or #f.)"
                                        (native-path (list->search-path-as-string
                                                      (remove cross? path) ":")))
                                   (setenv var native-path)))))
-                              '("C_INCLUDE_PATH"
-                                "CPLUS_INCLUDE_PATH"
-                                "OBJC_INCLUDE_PATH"
-                                "OBJCPLUS_INCLUDE_PATH"
-                                "LIBRARY_PATH"))
+                              (cons "LIBRARY_PATH" ',gcc-include-paths))
                     #t))
                 ,phases))
           (else phases))))))))
@@ -382,21 +374,16 @@ GCC that does not target a libc; otherwise, target that libc."
     ;; Only search target inputs, not host inputs.
     ;; Note: See <http://bugs.gnu.org/22186> for why not 'CPATH'.
     (search-paths
-     (list (search-path-specification
-            (variable "CROSS_C_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "CROSS_CPLUS_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "CROSS_OBJC_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "CROSS_OBJCPLUS_INCLUDE_PATH")
-            (files '("include")))
-           (search-path-specification
-            (variable "CROSS_LIBRARY_PATH")
-            (files '("lib" "lib64")))))
+     (cons
+      (search-path-specification
+       (variable "CROSS_LIBRARY_PATH")
+       (files '("lib" "lib64")))
+      (map
+       (lambda (path)
+         (search-path-specification
+          (variable path)
+          (files '("include"))))
+       gcc-cross-include-paths)))
     (native-search-paths '())))
 
 (define* (cross-libc target
@@ -458,11 +445,7 @@ XBINUTILS and the cross tool chain."
               (lambda* (#:key inputs #:allow-other-keys)
                 (let* ((kernel (assoc-ref inputs "kernel-headers"))
                        (cpath (string-append kernel "/include")))
-                  (for-each (cut setenv <> cpath)
-                            '("CROSS_C_INCLUDE_PATH"
-                              "CROSS_CPLUS_INCLUDE_PATH"
-                              "CROSS_OBJC_INCLUDE_PATH"
-                              "CROSS_OBJCPLUS_INCLUDE_PATH"))
+                  (for-each (cut setenv <> cpath) ',gcc-cross-include-paths)
                   #t))
               ,phases))))
 
@@ -509,12 +492,12 @@ XBINUTILS and the cross tool chain."
                   ;; As we are setup as a cross package, PATHs get setup
                   ;; without the CROSS_ prefix.  Change that here.
                   (add-before 'configure 'setenv
-                    (lambda* (#:key inputs native-inputs #:allow-other-keys)
-                      (let ((xgcc (assoc-ref inputs "xgcc")))
-                        (setenv "CPP" (string-append xgcc "/bin/"
-                                                     ,target "-cpp"))
-                        (setenv "CXXCPP" (string-append xgcc "/bin/"
-                                                        ,target "-cpp")))
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (let* ((xgcc     (assoc-ref inputs "xgcc"))
+                             (xgcc-bin (string-append xgcc "/bin/"
+                                                      ,target "-cpp")))
+                        (setenv "CPP" xgcc-bin)
+                        (setenv "CXXCPP" xgcc-bin))
                       (for-each (lambda (var)
                                   (and=> (getenv var)
                                          (lambda (value)
@@ -522,11 +505,7 @@ XBINUTILS and the cross tool chain."
                                                   (string-append "CROSS_" var)))
                                              (setenv cross value))
                                            (unsetenv var))))
-                                '("C_INCLUDE_PATH"
-                                  "CPLUS_INCLUDE_PATH"
-                                  "OBJC_INCLUDE_PATH"
-                                  "OBJCPLUS_INCLUDE_PATH"
-                                  "LIBRARY_PATH"))
+                                (cons "LIBRARY_PATH" ',gcc-include-paths))
                       #t)))))))
 
 (define (native-libc target)


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 02/11] gnu: Add mingw-w64.
  2016-08-09 15:56     ` Jan Nieuwenhuizen
@ 2016-08-10 10:37       ` Alex Kost
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Kost @ 2016-08-10 10:37 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 18:56 +0300) wrote:

> With MinGW, you can cross build Windows binaries and run them with Wine,
> like so
>
>     ./pre-inst-env guix build --target=i686-w64-mingw32 hello
>     /gnu/store/5lf701smnkq0wdg91jsyrmf5jnyz6i31-hello-2.10
>     guix environment --ad-hoc wine -- wine /gnu/store/5lf701smnkq0wdg91jsyrmf5jnyz6i31-hello-2.10/bin/hello.exe

Wow, I didn't realize it is so simple, thanks!

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-09 15:59     ` Jan Nieuwenhuizen
@ 2016-08-10 10:47       ` Alex Kost
  2016-08-10 13:08         ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Alex Kost @ 2016-08-10 10:47 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 18:59 +0300) wrote:

> Alex Kost writes:
>
>>> +                  (mingw-target? (lambda* (#:optional (target target))
>>> +                                   (and target
>>> +                                        (string-suffix? "-mingw32" target))))
>>
>> IIUC you don't use the same 'mingw-target?' procedure you added in an
>> earlier patch, because it is placed in (guix utils), right?
>
> Yes, something like that: the function needs to be present at in the
> builder, but I'm not sure how we can make that so.  I tried several
> things but could not find a way to avoid this duplication.
> mingw-target? is passed the TARGET from the post-install-phase.
>
>> I don't know if (guix build utils) would be a better place for it ,
>
> How would that work?  mingw-target? uses %current-build-system which is
> defined in (guix utils).  I agree that it would be nice to remove this
> duplication.

I just had the same thought ("it would be nice to remove duplication"),
but I see the problem you faced and I also don't know how to achieve
the goal, so let's forget about this for now, it shouldn't prevent to
merge this patchset, thanks!

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: mingw guile.exe cross build patch series v9
  2016-08-09  8:30 ` mingw guile.exe cross build patch series v9 Andy Wingo
  2016-08-09 15:41   ` Jan Nieuwenhuizen
@ 2016-08-10 11:03   ` Alex Kost
  1 sibling, 0 replies; 33+ messages in thread
From: Alex Kost @ 2016-08-10 11:03 UTC (permalink / raw)
  To: Andy Wingo; +Cc: guix-devel

Andy Wingo (2016-08-09 11:30 +0300) wrote:

> On Tue 09 Aug 2016 08:41, Jan Nieuwenhuizen <janneke@gnu.org> writes:
>
>> Finally I have the next iteration ready.  After adressing all comments on v8
>> and rebasing, the patches only built on core-updates.  I spent a some time to
>> find the problem with master and cherry-picking from core-updates before
>> giving up.
>>
>> Now that core-updates has been merged the mingw cross patches build again.
>
> All looks fine to me, though Alex's nits are good of course I'd be happy
> to have this in Guix and then we work on it some more in place.  Note
> that Guile 2.0 should now support `open-pipe' with MinGW and thus we
> will need a static-bash at some point.  I don't think Guix has updated
> to that Guile yet though, and probably we need to roll a new release
> actually to fix a couple more MinGW things.

If you mean Guile 2.0.12, Ludovic mentioned this update recently:
<http://lists.gnu.org/archive/html/guix-devel/2016-08/msg00328.html>

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 08/11] gnu: cross-base: Add cross-libtool.
  2016-08-09 16:04     ` Jan Nieuwenhuizen
@ 2016-08-10 11:12       ` Alex Kost
  0 siblings, 0 replies; 33+ messages in thread
From: Alex Kost @ 2016-08-10 11:12 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

Jan Nieuwenhuizen (2016-08-09 19:04 +0300) wrote:

[...]
>>> +                      (for-each (lambda (var)
>>> +                                  (and=> (getenv var)
>>> +                                         (lambda (value)
>>> +                                           (let ((cross
>>> +                                                  (string-append "CROSS_" var)))
>>> +                                             (setenv cross value))
>>> +                                           (unsetenv var))))
>>> +                                '("C_INCLUDE_PATH"
>>> +                                  "CPLUS_INCLUDE_PATH"
>>> +                                  "OBJC_INCLUDE_PATH"
>>> +                                  "OBJCPLUS_INCLUDE_PATH"
>>> +                                  "LIBRARY_PATH"))
>>
>> I have already seen this list of environment variables in an earlier
>> patch.  Perhaps it would be reasonable to make some global variable with
>> this list and to put it in (guix build utils) or another appropriate
>> place, WDYT?
>
> I have quicke tested the additional patch below which seems to work.  It
> would need some more testing.  How do you like that?

I like it very much, the only small thing...

> diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
> index f6c30ec..0d36143 100644
> --- a/gnu/packages/cross-base.scm
> +++ b/gnu/packages/cross-base.scm
> @@ -45,6 +45,15 @@
>    ;; be 'gcc' and can be a specific variant such as 'gcc-4.8'.
>    gcc)
>  
> +(define gcc-include-paths
> +  '("C_INCLUDE_PATH"
> +    "CPLUS_INCLUDE_PATH"
> +    "OBJC_INCLUDE_PATH"
> +    "OBJCPLUS_INCLUDE_PATH"))
> +
> +(define gcc-cross-include-paths
> +  (map (cut string-append "CROSS_" <>) gcc-include-paths))

... by convention global variables are prefixed with "%" in
guix code, i.e.: '%gcc-include-paths' and '%gcc-cross-include-paths'.

Perhaps it would be better to have a procedure that transforms usual
paths into cross paths instead of '%gcc-cross-include-paths':

  (define* (paths->cross-paths #:optional (paths %gcc-include-paths))
    (map (cut string-append "CROSS_" <>) paths))

or maybe it is not worth bothering.

The rest looks good to me, thanks!  But again I'm not competent to judge
on the matter of this patchset, IIUC Andy is going to handle it, right?

-- 
Alex

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-10 10:47       ` Alex Kost
@ 2016-08-10 13:08         ` Jan Nieuwenhuizen
  2016-08-10 18:04           ` Mark H Weaver
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-10 13:08 UTC (permalink / raw)
  To: Alex Kost; +Cc: guix-devel

Alex Kost writes:

Hi!

> Jan Nieuwenhuizen (2016-08-09 18:59 +0300) wrote:
>
>> Alex Kost writes:
>>
>>>> +                  (mingw-target? (lambda* (#:optional (target target))
>>>> +                                   (and target
>>>> +                                        (string-suffix? "-mingw32" target))))
>>>
>>> IIUC you don't use the same 'mingw-target?' procedure you added in an
>>> earlier patch, because it is placed in (guix utils), right?
>>
>> Yes, something like that: the function needs to be present at in the
>> builder, but I'm not sure how we can make that so.  I tried several
>> things but could not find a way to avoid this duplication.
>> mingw-target? is passed the TARGET from the post-install-phase.
>>
>>> I don't know if (guix build utils) would be a better place for it ,
>>
>> How would that work?  mingw-target? uses %current-build-system which is
>> defined in (guix utils).  I agree that it would be nice to remove this
>> duplication.
>
> I just had the same thought ("it would be nice to remove duplication"),
> but I see the problem you faced and I also don't know how to achieve
> the goal, so let's forget about this for now, it shouldn't prevent to
> merge this patchset, thanks!

Hmm...the patch removes the duplication, it also rebuilds everything of
course.  Would this be the way to do it, would we want to have this in
core-updates or is there a better way?

Is a mingw test important enough to have in and export from build utils?

Greetings, Jan

--8<---------------cut here---------------start------------->8---
diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index cf502f4..3af1700 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -71,15 +71,12 @@
         (post-install-phase
          `(lambda* (#:key outputs target #:allow-other-keys)
             (let ((out (assoc-ref outputs "out"))
-                  (mingw-target? (lambda* (#:optional (target target))
-                                   (and target
-                                        (string-suffix? "-mingw32" target))))
                   (libraries '("curses" "ncurses" "form" "panel" "menu")))
               ;; When building a wide-character (Unicode) build, create backward
               ;; compatibility links from the the "normal" libraries to the
               ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
               (cond
-               ((mingw-target? target)
+               ((explicit-mingw-target? target)
                 (with-directory-excursion (string-append out "/bin")
                   (for-each
                    (lambda (lib)
diff --git a/guix/build/utils.scm b/guix/build/utils.scm
index 2988193..8b1c417 100644
--- a/guix/build/utils.scm
+++ b/guix/build/utils.scm
@@ -41,6 +41,7 @@
 
             directory-exists?
             executable-file?
+            explicit-mingw-target?
             symbolic-link?
             call-with-ascii-input-file
             elf-file?
@@ -140,6 +141,10 @@ introduce the version part."
     (and s
          (not (zero? (logand (stat:mode s) #o100))))))
 
+(define (explicit-mingw-target? target)
+  (and target
+       (string-suffix? "-mingw32" target)))
+
 (define (symbolic-link? file)
   "Return #t if FILE is a symbolic link (aka. \"symlink\".)"
   (eq? (stat:type (lstat file)) 'symlink))
diff --git a/guix/utils.scm b/guix/utils.scm
index e44504c..ebd9a0d 100644
--- a/guix/utils.scm
+++ b/guix/utils.scm
@@ -33,7 +33,7 @@
   #:use-module (rnrs io ports)
   #:use-module ((rnrs bytevectors) #:select (bytevector-u8-set!))
   #:use-module (guix combinators)
-  #:use-module ((guix build utils) #:select (dump-port))
+  #:use-module ((guix build utils) #:select (dump-port explicit-mingw-target?))
   #:use-module ((guix build syscalls) #:select (mkdtemp! fdatasync))
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 format)
@@ -489,8 +489,7 @@ returned by `config.guess'."
   (make-parameter #f))
 
 (define* (mingw-target? #:optional (target (%current-target-system)))
-  (and target
-       (string-suffix? "-mingw32" target)))
+  (explicit-mingw-target? target))
 
 (define (package-name->name+version spec)
   "Given SPEC, a package name like \"foo@0.9.1b\", return two values: \"foo\"
--8<---------------cut here---------------end--------------->8---


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-10 13:08         ` Jan Nieuwenhuizen
@ 2016-08-10 18:04           ` Mark H Weaver
  0 siblings, 0 replies; 33+ messages in thread
From: Mark H Weaver @ 2016-08-10 18:04 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel, Alex Kost

Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Hmm...the patch removes the duplication, it also rebuilds everything of
> course.  Would this be the way to do it, would we want to have this in
> core-updates or is there a better way?

Even just modifying the existing 'ncurses' derivations will force ~10000
rebuilds, which is far too much outside of core-updates.

In theory, it should be possible to arrange for the 'ncurses'
derivations to be unchanged when not targetting mingw, by doing these
tests on the client side instead of the build side.  Remember that these
backquoted excerpts of code are being generated on the client side to be
run later on the build side, so we should be able to arrange for this
generated code to be unchanged except on mingw.  However, dealing with
the patch will be a bit ugly.  The job of modifying curses.h.in would
have to be moved to a phase.

I'll try to find time in the next day or two to attempt this, and see if
it can be done reasonably or if the resulting code would be too nasty to
consider.

Thanks for working on this.

      Mark

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-09  6:41 ` [PATCH 07/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
  2016-08-09  7:53   ` Alex Kost
@ 2016-08-14 16:54   ` Mark H Weaver
  2016-08-15 16:37     ` Jan Nieuwenhuizen
  1 sibling, 1 reply; 33+ messages in thread
From: Mark H Weaver @ 2016-08-14 16:54 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 905 bytes --]

Hi Jan,

Jan Nieuwenhuizen <janneke@gnu.org> writes:
> * gnu/packages/patches/ncurses-mingw.patch: New file.
> * gnu-system.am (dist_patch_DATA): Add it.
> * gnu/packages/ncurses.scm (ncurses): Support mingw.

As I wrote elsewhere, this patch would force about 10000 rebuilds
(across all four architectures), which would rule out applying it to
master.

However, I've attached an alternative patch that I hope will do the same
job, but it doesn't force any rebuilds at all, so it could be applied to
master right now.  It carefully arranges to add tests only on the client
side, and to generate the same build-side code, and the same derivations
for normal builds.

Can you try it and see if it works?  If so, I will write more about how
it works.  Maybe the other mingw-related changes to core packages could
follow a similar pattern, and thus be eligible to be applied to master
directly.

      Mark



[-- Attachment #2: [PATCH] UNTESTED: gnu: ncurses: support mingw --]
[-- Type: text/x-patch, Size: 14145 bytes --]

From 00fb4b5de2dd14e7b7d4c4c32b1dd4d68f8b425d Mon Sep 17 00:00:00 2001
From: Mark H Weaver <mhw@netris.org>
Date: Sun, 14 Aug 2016 03:46:48 -0400
Subject: [PATCH] UNTESTED: gnu: ncurses: support mingw.

* gnu/packages/patches/ncurses-mingw.patch: New file.
* gnu-system.am (dist_patch_DATA): Add it.
* gnu/packages/ncurses.scm (ncurses): Support mingw.

Co-Authored-By: Jan Nieuwenhuizen <janneke@gnu.org>
---
 gnu/packages/ncurses.scm | 234 ++++++++++++++++++++++++++---------------------
 1 file changed, 132 insertions(+), 102 deletions(-)

diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 147033a..1366dc0 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -1,7 +1,8 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org>
-;;; Copyright © 2014 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2014, 2016 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2015 Leo Famulari <leo@famulari.name>
+;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -19,124 +20,153 @@
 ;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (gnu packages ncurses)
+  #:use-module (gnu packages)
   #:use-module (guix licenses)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix build-system gnu))
 
-(define-public ncurses
-  (let ((patch-makefile-phase
-         '(lambda _
-            (for-each patch-makefile-SHELL
-                      (find-files "." "Makefile.in"))))
-        (configure-phase
-         ;; The 'configure' script does not understand '--docdir', so we must
-         ;; override that and use '--mandir' instead.
-         '(lambda* (#:key build target outputs configure-flags
-                    #:allow-other-keys)
-            (let ((out (assoc-ref outputs "out"))
-                  (doc (assoc-ref outputs "doc")))
-              (zero? (apply system* "./configure"
-                            (string-append "SHELL=" (which "sh"))
-                            (string-append "--build=" build)
-                            (string-append "--prefix=" out)
-                            (string-append "--mandir=" doc "/share/man")
-                            (if target
-                                (cons (string-append "--host=" target)
-                                      configure-flags)
-                                configure-flags))))))
-        (remove-shebang-phase
-         '(lambda _
-            ;; To avoid retaining a reference to the bootstrap Bash via the
-            ;; shebang of the 'ncursesw6-config' script, simply remove that
-            ;; shebang: it'll work just as well without it.  Likewise, do not
-            ;; retain a reference to the "doc" output.
-            (substitute* "misc/ncurses-config.in"
-              (("#!@SHELL@")
-               "# No shebang here, use /bin/sh!\n")
-              (("@SHELL@ \\$0")
-               "$0")
-              (("mandir=.*$")
-               "mandir=share/man"))
-            #t))
-        (post-install-phase
-         '(lambda* (#:key outputs #:allow-other-keys)
-            (let ((out (assoc-ref outputs "out")))
-              ;; When building a wide-character (Unicode) build, create backward
-              ;; compatibility links from the the "normal" libraries to the
-              ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
-              (with-directory-excursion (string-append out "/lib")
-                (for-each (lambda (lib)
-                            (define libw.a
-                              (string-append "lib" lib "w.a"))
-                            (define lib.a
-                              (string-append "lib" lib ".a"))
-                            (define libw.so.x
-                              (string-append "lib" lib "w.so.6"))
-                            (define lib.so.x
-                              (string-append "lib" lib ".so.6"))
-                            (define lib.so
-                              (string-append "lib" lib ".so"))
+(define (target-mingw?)
+  (let ((target (%current-target-system)))
+    (and target (string-suffix? "-mingw32" target))))
 
-                            (when (file-exists? libw.a)
-                              (format #t "creating symlinks for `lib~a'~%" lib)
-                              (symlink libw.a lib.a)
-                              (symlink libw.so.x lib.so.x)
-                              (false-if-exception (delete-file lib.so))
-                              (call-with-output-file lib.so
-                                (lambda (p)
-                                  (format p "INPUT (-l~aw)~%" lib)))))
-                          '("curses" "ncurses" "form" "panel" "menu")))))))
-    (package
-     (name "ncurses")
-     (version "6.0")
-     (source (origin
+(define-public ncurses
+  (package
+    (name "ncurses")
+    (version "6.0")
+    (source (origin
               (method url-fetch)
               (uri (string-append "mirror://gnu/ncurses/ncurses-"
                                   version ".tar.gz"))
               (sha256
                (base32
-                "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))))
-     (build-system gnu-build-system)
-     (outputs '("out"
-                "doc"))                          ;1 MiB of man pages
-     (arguments
-      `(#:configure-flags
-        `("--with-shared" "--without-debug" "--enable-widec"
+                "0q3jck7lna77z5r42f13c4xglc7azd19pxfrjrpgp2yf615w4lgm"))
+              (patches (map search-patch
+                            (if (target-mingw?)
+                                '("ncurses-mingw.patch")
+                                '())))))
+    (build-system gnu-build-system)
+    (outputs '("out"
+               "doc"))                ;1 MiB of man pages
+    (arguments
+     (let ((patch-makefile-phase
+            '(lambda _
+               (for-each patch-makefile-SHELL
+                         (find-files "." "Makefile.in"))))
+           (configure-phase
+            ;; The 'configure' script does not understand '--docdir', so we must
+            ;; override that and use '--mandir' instead.
+            '(lambda* (#:key build target outputs configure-flags
+                       #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out"))
+                     (doc (assoc-ref outputs "doc")))
+                 (zero? (apply system* "./configure"
+                               (string-append "SHELL=" (which "sh"))
+                               (string-append "--build=" build)
+                               (string-append "--prefix=" out)
+                               (string-append "--mandir=" doc "/share/man")
+                               (if target
+                                   (cons (string-append "--host=" target)
+                                         configure-flags)
+                                   configure-flags))))))
+           (remove-shebang-phase
+            '(lambda _
+               ;; To avoid retaining a reference to the bootstrap Bash via the
+               ;; shebang of the 'ncursesw6-config' script, simply remove that
+               ;; shebang: it'll work just as well without it.  Likewise, do not
+               ;; retain a reference to the "doc" output.
+               (substitute* "misc/ncurses-config.in"
+                 (("#!@SHELL@")
+                  "# No shebang here, use /bin/sh!\n")
+                 (("@SHELL@ \\$0")
+                  "$0")
+                 (("mandir=.*$")
+                  "mandir=share/man"))
+               #t))
+           (post-install-phase
+            `(lambda* (#:key outputs #:allow-other-keys)
+               (let ((out (assoc-ref outputs "out")))
+                 ;; When building a wide-character (Unicode) build, create backward
+                 ;; compatibility links from the the "normal" libraries to the
+                 ;; wide-character libraries (e.g. libncurses.so to libncursesw.so).
+                 ,@(if (target-mingw?)
+                       '( ;; TODO: create .la files to link to the .dll?
+                         (with-directory-excursion (string-append out "/bin")
+                           (for-each
+                            (lambda (lib)
+                              (define lib.dll
+                                (string-append "lib" lib ".dll"))
+                              (define libw6.dll
+                                (string-append "lib" lib "w6.dll"))
+
+                              (when (file-exists? libw6.dll)
+                                (format #t "creating symlinks for `lib~a'~%" lib)
+                                (symlink libw6.dll lib.dll)))
+                            libraries)))
+                       '())
+                 (with-directory-excursion (string-append out "/lib")
+                   (for-each (lambda (lib)
+                               (define libw.a
+                                 (string-append "lib" lib "w.a"))
+                               (define lib.a
+                                 (string-append "lib" lib ".a"))
+
+                               ,@(if (not (target-mingw?))
+                                     '((define libw.so.x
+                                         (string-append "lib" lib "w.so.6"))
+                                       (define lib.so.x
+                                         (string-append "lib" lib ".so.6"))
+                                       (define lib.so
+                                         (string-append "lib" lib ".so")))
+                                     '())
+
+                               (when (file-exists? libw.a)
+                                 (format #t "creating symlinks for `lib~a'~%" lib)
+                                 (symlink libw.a lib.a)
+                                 ,@(if (not (target-mingw?))
+                                       '((symlink libw.so.x lib.so.x)
+                                         (false-if-exception (delete-file lib.so))
+                                         (call-with-output-file lib.so
+                                           (lambda (p)
+                                             (format p "INPUT (-l~aw)~%" lib))))
+                                       '())))
+                             '("curses" "ncurses" "form" "panel" "menu")))))))
+       `(#:configure-flags
+         `("--with-shared" "--without-debug" "--enable-widec"
 
-          ;; By default headers land in an `ncursesw' subdir, which is not
-          ;; what users expect.
-          ,(string-append "--includedir=" (assoc-ref %outputs "out")
-                          "/include")
-          "--enable-overwrite"                    ;really honor --includedir
+           ;; By default headers land in an `ncursesw' subdir, which is not
+           ;; what users expect.
+           ,(string-append "--includedir=" (assoc-ref %outputs "out")
+                           "/include")
+           "--enable-overwrite"       ;really honor --includedir
 
-          ;; Make sure programs like 'tic', 'reset', and 'clear' have a
-          ;; correct RUNPATH.
-          ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
-                          "/lib"))
-        #:tests? #f                               ; no "check" target
-        #:phases (modify-phases %standard-phases
-                   (replace 'configure ,configure-phase)
-                   (add-after 'install 'post-install
-                     ,post-install-phase)
-                   (add-before 'configure 'patch-makefile-SHELL
-                     ,patch-makefile-phase)
-                   (add-after 'unpack 'remove-unneeded-shebang
-                     ,remove-shebang-phase))))
-     (self-native-input? #t)                      ; for `tic'
-     (native-search-paths
-      (list (search-path-specification
-             (variable "TERMINFO_DIRS")
-             (files '("share/terminfo")))))
-     (synopsis "Terminal emulation (termcap, terminfo) library")
-     (description
-      "GNU Ncurses is a library which provides capabilities to write text to
+           ;; Make sure programs like 'tic', 'reset', and 'clear' have a
+           ;; correct RUNPATH.
+           ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
+                           "/lib"))
+         #:tests? #f                  ; no "check" target
+         #:phases (modify-phases %standard-phases
+                    (replace 'configure ,configure-phase)
+                    (add-after 'install 'post-install
+                      ,post-install-phase)
+                    (add-before 'configure 'patch-makefile-SHELL
+                      ,patch-makefile-phase)
+                    (add-after 'unpack 'remove-unneeded-shebang
+                      ,remove-shebang-phase)))))
+    (self-native-input? #t)           ; for `tic'
+    (native-search-paths
+     (list (search-path-specification
+            (variable "TERMINFO_DIRS")
+            (files '("share/terminfo")))))
+    (synopsis "Terminal emulation (termcap, terminfo) library")
+    (description
+     "GNU Ncurses is a library which provides capabilities to write text to
 a terminal in a terminal-independent manner.  It supports pads and color as
 well as multiple highlights and forms characters.  It is typically used to
 implement user interfaces for command-line applications.  The accompanying
 ncursesw library provides wide character support.")
-     (license x11)
-     (home-page "http://www.gnu.org/software/ncurses/"))))
+    (license x11)
+    (home-page "http://www.gnu.org/software/ncurses/")))
 
 (define-public dialog
   (package
-- 
2.9.2


^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-14 16:54   ` Mark H Weaver
@ 2016-08-15 16:37     ` Jan Nieuwenhuizen
  2016-08-16 10:26       ` Ricardo Wurmus
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-15 16:37 UTC (permalink / raw)
  To: Mark H Weaver; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 1957 bytes --]

Mark H Weaver writes:

Hi Mark!

> As I wrote elsewhere, this patch would force about 10000 rebuilds
> (across all four architectures), which would rule out applying it to
> master.

That could very well be...I've been rebuilding quite a lot.  Is there a
command I can run to get (an estimate of) the number of rebuilds that
a change triggers?

> However, I've attached an alternative patch that I hope will do the same
> job, but it doesn't force any rebuilds at all, so it could be applied to
> master right now.  It carefully arranges to add tests only on the client
> side, and to generate the same build-side code, and the same derivations
> for normal builds.
>
> Can you try it and see if it works?  If so, I will write more about how
> it works.

Thanks for looking at this!  I think that I see what you're
doing/attempting: evaluate all changes early when reading the package
description, so that the builder (?) sees no changes.

Are these kind of temporary workarounds that should somehow get
changed/cleaned-up later?  I had the impression that this

              (patches (map search-patch
                            (if (target-mingw?)
                                '("ncurses-mingw.patch")
                                '())))))

i.e., conditional patches, was a big nono (this patch was already
tested, but a conditional patch might break x86_64 when applied).

Also, we'll get more conditionals just to keep the original description
unchanged.

I have tested your patch and found two small bits missing.  The
additional patch below adds these and then ncurses builds fine....but it
still seems that rebuilds get still triggered.  Could that be because of
you moved the let into arguments, or did we/I miss something else?

> Maybe the other mingw-related changes to core packages could
> follow a similar pattern, and thus be eligible to be applied to master
> directly.

Sure, let's look at that when we this right.

Greetings,
Jan


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-ncurses-support-mingw-fixlets-libraries-term-dri.patch --]
[-- Type: text/x-patch, Size: 1563 bytes --]

From fad3d7d3929d0397e193c5993d1966e9b6f171fc Mon Sep 17 00:00:00 2001
From: Jan Nieuwenhuizen <janneke@gnu.org>
Date: Mon, 15 Aug 2016 15:39:04 +0200
Subject: [PATCH] gnu: ncurses: support mingw: fixlets: libraries, term driver.

---
 gnu/packages/ncurses.scm | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/ncurses.scm b/gnu/packages/ncurses.scm
index 1366dc0..8002cbe 100644
--- a/gnu/packages/ncurses.scm
+++ b/gnu/packages/ncurses.scm
@@ -102,7 +102,7 @@
                               (when (file-exists? libw6.dll)
                                 (format #t "creating symlinks for `lib~a'~%" lib)
                                 (symlink libw6.dll lib.dll)))
-                            libraries)))
+                            '("curses" "ncurses" "form" "panel" "menu"))))
                        '())
                  (with-directory-excursion (string-append out "/lib")
                    (for-each (lambda (lib)
@@ -143,7 +143,9 @@
            ;; Make sure programs like 'tic', 'reset', and 'clear' have a
            ;; correct RUNPATH.
            ,(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
-                           "/lib"))
+                           "/lib")
+           ;; MinGW: Provide termcap api, created for the MinGW port.
+           ,,@(if (target-mingw?) '("--enable-term-driver") '()))
          #:tests? #f                  ; no "check" target
          #:phases (modify-phases %standard-phases
                     (replace 'configure ,configure-phase)
-- 
2.9.2


[-- Attachment #3: Type: text/plain, Size: 154 bytes --]


-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply related	[flat|nested] 33+ messages in thread

* Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-15 16:37     ` Jan Nieuwenhuizen
@ 2016-08-16 10:26       ` Ricardo Wurmus
  2016-08-16 11:53         ` Guile question ... " Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Ricardo Wurmus @ 2016-08-16 10:26 UTC (permalink / raw)
  To: Jan Nieuwenhuizen; +Cc: guix-devel


Jan Nieuwenhuizen <janneke@gnu.org> writes:

> Mark H Weaver writes:
>
> Hi Mark!
>
>> As I wrote elsewhere, this patch would force about 10000 rebuilds
>> (across all four architectures), which would rule out applying it to
>> master.
>
> That could very well be...I've been rebuilding quite a lot.  Is there a
> command I can run to get (an estimate of) the number of rebuilds that
> a change triggers?

The command “guix refresh -l package-name” gives you a very rough list
of packages (on the same architecture) that would be affected by an
update to “package-name”.  This isn’t always correct, but in the case of
ncurses it shows at least that a lot of packages are affected:

    guix refresh -l ncurses
    …
    Building the following 1018 packages would ensure 2616 dependent
    packages are rebuilt: …

~~ Ricardo

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Guile question ... Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-16 10:26       ` Ricardo Wurmus
@ 2016-08-16 11:53         ` Jan Nieuwenhuizen
  2016-08-16 18:24           ` Jan Nieuwenhuizen
  0 siblings, 1 reply; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-16 11:53 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Ricardo Wurmus writes:

> The command “guix refresh -l package-name” gives you a very rough list
> of packages (on the same architecture) that would be affected by an
> update to “package-name”.  This isn’t always correct, but in the case of
> ncurses it shows at least that a lot of packages are affected:
>
>     guix refresh -l ncurses
>     …
>     Building the following 1018 packages would ensure 2616 dependent
>     packages are rebuilt: …

Thanks!

I found why my ncurses still triggers rebuilds: that was in my fixes
that I added on top of Mark's patch, adding necessary MinGW configure
flags

    `(#:configure-flags
      `(
       ...
       ;; MinGW: Provide termcap api, created for the MinGW port.
       ,,@(if (target-mingw?) '("--enable-term-driver") '())
       )

While this `works' build-wise, it still modifies configure-flags when
not target-mingw?.

That is solved technically by doing it like so

    `(#:configure-flags
      ,(cons*
        'quasiquote
        `("--with-shared" "--without-debug" "--enable-widec"

          ;; By default headers land in an `ncursesw' subdir, which is not
          ;; what users expect.
          ,(list 'unquote '(string-append "--includedir=" (assoc-ref %outputs "out")
                                          "/include"))
          "--enable-overwrite"       ;really honor --includedir

          ;; Make sure programs like 'tic', 'reset', and 'clear' have a
          ;; correct RUNPATH.
          ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
                                          "/lib")))
        ;; MinGW: Provide termcap api, created for the MinGW port.
        (if (target-mingw?) '("--enable-term-driver") '()))

...is there an easier/cleaner way, this looks overly complicated.

Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

* Re: Guile question ... Re: [PATCH 07/11] gnu: ncurses: support mingw.
  2016-08-16 11:53         ` Guile question ... " Jan Nieuwenhuizen
@ 2016-08-16 18:24           ` Jan Nieuwenhuizen
  0 siblings, 0 replies; 33+ messages in thread
From: Jan Nieuwenhuizen @ 2016-08-16 18:24 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

Jan Nieuwenhuizen writes:

> Ricardo Wurmus writes:
>
>> The command “guix refresh -l package-name” gives you a very rough list
>> of packages (on the same architecture) that would be affected by an
>> update to “package-name”.  This isn’t always correct, but in the case of
>> ncurses it shows at least that a lot of packages are affected:
>>
>>     guix refresh -l ncurses
>>     …
>>     Building the following 1018 packages would ensure 2616 dependent
>>     packages are rebuilt: …
>
> Thanks!
>
> I found why my ncurses still triggers rebuilds: that was in my fixes
> that I added on top of Mark's patch, adding necessary MinGW configure
> flags
>
>     `(#:configure-flags
>       `(
>        ...
>        ;; MinGW: Provide termcap api, created for the MinGW port.
>        ,,@(if (target-mingw?) '("--enable-term-driver") '())
>        )
>
> While this `works' build-wise, it still modifies configure-flags when
> not target-mingw?.
>
> That is solved technically by doing it like so

Oops, make that:

    `(#:configure-flags
      ,(cons*
        'quasiquote
        `(("--with-shared" "--without-debug" "--enable-widec"

           ;; By default headers land in an `ncursesw' subdir, which is not
           ;; what users expect.
           ,(list 'unquote '(string-append "--includedir=" (assoc-ref %outputs "out")
                                           "/include"))
           "--enable-overwrite"      ;really honor --includedir

           ;; Make sure programs like 'tic', 'reset', and 'clear' have a
           ;; correct RUNPATH.
           ,(list 'unquote '(string-append "LDFLAGS=-Wl,-rpath=" (assoc-ref %outputs "out")
                                           "/lib"))
           ;; MinGW: Use term-driver created for the MinGW port, libtool.
           ,@(if (target-mingw?) '("--enable-term-driver" "--with-libtool") '()))))


Greetings,
Jan

-- 
Jan Nieuwenhuizen <janneke@gnu.org> | GNU LilyPond http://lilypond.org
Freelance IT http://JoyofSource.com | Avatar®  http://AvatarAcademy.nl  

^ permalink raw reply	[flat|nested] 33+ messages in thread

end of thread, other threads:[~2016-08-16 18:25 UTC | newest]

Thread overview: 33+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09  6:41 mingw guile.exe cross build patch series v9 Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 01/11] gnu: Add gcc-cross-x86_64 packages for testing Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 02/11] gnu: Add mingw-w64 Jan Nieuwenhuizen
2016-08-09  7:28   ` Alex Kost
2016-08-09 15:56     ` Jan Nieuwenhuizen
2016-08-10 10:37       ` Alex Kost
2016-08-09  6:41 ` [PATCH 03/11] gnu: cross-build: i686-w64-mingw32: new cross target Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 04/11] gnu: Add function libiconv-if-needed Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 05/11] gnu: libunistring: support mingw: propagate libiconv if needed Jan Nieuwenhuizen
2016-08-09  7:37   ` Alex Kost
2016-08-09 16:00     ` Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 06/11] gnu: gmp: build shared library for mingw Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 07/11] gnu: ncurses: support mingw Jan Nieuwenhuizen
2016-08-09  7:53   ` Alex Kost
2016-08-09 15:59     ` Jan Nieuwenhuizen
2016-08-10 10:47       ` Alex Kost
2016-08-10 13:08         ` Jan Nieuwenhuizen
2016-08-10 18:04           ` Mark H Weaver
2016-08-14 16:54   ` Mark H Weaver
2016-08-15 16:37     ` Jan Nieuwenhuizen
2016-08-16 10:26       ` Ricardo Wurmus
2016-08-16 11:53         ` Guile question ... " Jan Nieuwenhuizen
2016-08-16 18:24           ` Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 08/11] gnu: cross-base: Add cross-libtool Jan Nieuwenhuizen
2016-08-09  8:08   ` Alex Kost
2016-08-09 16:04     ` Jan Nieuwenhuizen
2016-08-10 11:12       ` Alex Kost
2016-08-09  6:41 ` [PATCH 09/11] gnu: libtool: support cross-libtool mingw Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 10/11] gnu: ncurses: build mingw with libtool Jan Nieuwenhuizen
2016-08-09  6:41 ` [PATCH 11/11] gnu: readline: support mingw Jan Nieuwenhuizen
2016-08-09  8:30 ` mingw guile.exe cross build patch series v9 Andy Wingo
2016-08-09 15:41   ` Jan Nieuwenhuizen
2016-08-10 11:03   ` Alex Kost

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).