Fixup devel/hs-c2hs and devel/hs-gtk2hs-buildtools to pass -std=c99 to the preprocessor

The ports using c2hs and gtk2hs fail to build with modern compilers as the c11 features of the FreeBSD system headers are not hidden, yet the tools only understand c99.
* revert change to devel/hs-ncurses from r436451
* patch devel/hs-c2hs to pass -std=c99.
* patch devel/hs-gtk2-buildtools to pass -std=c99.

This should fix compilation of
* devel/hs-ncurses
* dns/hs-gnuidn
* graphics/hs-cairo
* x11-toolkits/hs-vte
* devel/hs-gconf

PR:		216707
Reviewed by:	rakuco
Approved by:	portmgr (antoine)
Differential Revision:	https://reviews.freebsd.org/D10081
This commit is contained in:
Tobias C. Berner 2017-03-25 20:29:13 +00:00
parent 23f2e9e696
commit 4492f249db
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=436914
7 changed files with 66 additions and 14 deletions

View file

@ -3,6 +3,7 @@
PORTNAME= c2hs
PORTVERSION= 0.28.1
PORTREVISION= 1
CATEGORIES= devel haskell
MAINTAINER= haskell@FreeBSD.org

View file

@ -0,0 +1,30 @@
Hide the scary c11 features from c2hs, which does not understand them:
gtk2hsC2hs: Error in C header file.
/usr/include/sys/_types.h:104: (column 61) [FATAL]
>>> Syntax error!
The symbol `long' does not fit here.
*** Error code 1
--- src/C2HS/Config.hs.orig 2017-03-21 18:33:51 UTC
+++ src/C2HS/Config.hs
@@ -56,14 +56,17 @@ cpp = case os of
-- understood at least on Linux, FreeBSD, and Solaris and seems to make a
-- difference over the default language setting on FreeBSD
--
+-- * Pass -std=c99 as c2hs get's confused by the c11 parts in the FreeBSD
+-- system headers.
+--
-- * @-P@ would suppress @#line@ directives
--
cppopts :: [String]
cppopts = case (os,cpp) of
-- why is gcc different between all these platforms?
("openbsd","cpp") -> ["-xc"]
- (_,"cpp") -> ["-x", "c"]
- (_,"gcc") -> ["-E", "-x", "c"]
+ (_,"cpp") -> ["-x", "c", "-std=c99"]
+ (_,"gcc") -> ["-E", "-x", "c", "-std=c99"]
_ -> []
-- | C2HS Library file name

View file

@ -2,6 +2,7 @@
PORTNAME= gtk2hs-buildtools
PORTVERSION= 0.13.0.4
PORTREVISION= 1
CATEGORIES= devel haskell
MAINTAINER= haskell@FreeBSD.org

View file

@ -1,6 +1,6 @@
--- ./c2hs/c/CAST.hs.orig 2012-11-12 00:26:43.000000000 +0100
+++ ./c2hs/c/CAST.hs 2013-05-28 11:02:33.000000000 +0200
@@ -1125,6 +1125,9 @@
--- c2hs/c/CAST.hs.orig 2017-03-21 18:15:30 UTC
+++ c2hs/c/CAST.hs
@@ -1125,6 +1125,9 @@ instance Binary CStorageSpec where
put_ bh (CTypedef ae) = do
putByte bh 4
put_ bh ae
@ -10,7 +10,7 @@
get bh = do
h <- getByte bh
case h of
@@ -1143,6 +1146,9 @@
@@ -1143,6 +1146,9 @@ instance Binary CStorageSpec where
4 -> do
ae <- get bh
return (CTypedef ae)

View file

@ -0,0 +1,29 @@
Hide the scary c11 features from c2hs, which does not understand them:
c2hs: C header contains errors:
/usr/include/sys/_types.h:104: (column 61) [ERROR] >>> Syntax error !
The symbol `long' does not fit here.
*** Error code 1
--- c2hs/toplevel/C2HSConfig.hs.orig 2017-03-21 18:17:37 UTC
+++ c2hs/toplevel/C2HSConfig.hs
@@ -64,14 +64,17 @@ cpp = case os of
-- * `-x c' forces CPP to regard the input as C code; this option seems to be
-- understood at least on Linux, FreeBSD, and Solaris and seems to make a
-- difference over the default language setting on FreeBSD
+--
+-- * Pass -std=c99 as c2hs get's confused by the c11 parts in the FreeBSD
+-- system headers.
--
-- * `-P' would suppress `#line' directives
--
cppopts :: [String]
cppopts = case (os,cpp) of
("openbsd","cpp") -> ["-xc", "-w"]
- (_,"cpp") -> ["-x", "c", "-w"]
- (_,"gcc") -> ["-E", "-x", "c", "-w"]
+ (_,"cpp") -> ["-x", "c", "-w", "-std=c99"]
+ (_,"gcc") -> ["-E", "-x", "c", "-w", "-std=c99"]
_ -> []
-- C preprocessor option for including only definitions (EXPORTED)

View file

@ -3,6 +3,7 @@
PORTNAME= ncurses
PORTVERSION= 0.2.16
PORTREVISION= 1
CATEGORIES= devel haskell
MAINTAINER= haskell@FreeBSD.org

View file

@ -1,10 +0,0 @@
--- ncurses.cabal.orig 2017-02-13 14:30:05 UTC
+++ ncurses.cabal
@@ -103,6 +103,7 @@ library
-- platforms where the linker doesn't automatically follow dependencies.
if os(darwin) || os(freebsd) || flag(force-narrow-library)
cc-options: -DHSNCURSES_NARROW_HEADER
+ cpp-options: -std=c99
if os(darwin) || flag(force-narrow-library)
extra-libraries: panel ncurses pthread
else