Allow ghc to work with external libgmp instead of building its own; this

will help with the sparc port.

From Don Stewart <dons@cse.unsw.edu.au>
This commit is contained in:
avsm 2003-08-12 13:25:18 +00:00
parent 38513b2e46
commit d492df62cc
12 changed files with 148 additions and 46 deletions

View File

@ -1,14 +1,10 @@
# $OpenBSD: Makefile,v 1.6 2003/08/03 18:07:27 avsm Exp $
# $OpenBSD: Makefile,v 1.7 2003/08/12 13:25:18 avsm Exp $
# Based on Simon Marlow's port script for FreeBSD:
# $FreeBSD: ports/lang/ghc/Makefile,v 1.13 2002/08/22 12:53:38 obraun Exp $
#
# Last update : updated to 6.0: Fri Jul 4 10:16:53 EST 2003
# ported to ELF : Wed Apr 23 12:38:42 EST 2003
#
# The build process:
# 1) build a bootstrap ghc4 from C source
# 2) use this to do an in-tree ghc6 bootstrap and build
#
ONLY_FOR_ARCHS= i386
# sparc : needs to handle the asm format in ghc/driver/mangler/*.lprl
@ -29,21 +25,17 @@ CATEGORIES= lang
HOMEPAGE= http://www.haskell.org/ghc/
MAINTAINER= Don Stewart <dons@cse.unsw.edu.au>
LIB_DEPENDS= ::devel/gmp
MULTI_PACKAGES= -doc
SUBPACKAGE?=
FULLPKGNAME-doc= ghc-doc-${FULLVER}
# BSD w/o advertising clause
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
FULLPKGNAME-doc=ghc-doc-${FULLVER}
HASKELL= http://www.haskell.org/
MASTER_SITES= ${HASKELL}ghc/dist/${FULLVER}/
MASTER_SITES0= ${HASKELL}ghc/dist/${BOOTVER}/
MASTER_SITES1= ${HASKELL}ghc/docs/${FULLVER}/
MASTER_SITES2= ftp://ftp.cse.unsw.edu.au/pub/users/dons/ghc/${FULLVER}/
MASTER_SITES2= ftp://ftp.cse.unsw.edu.au/pub/users/dons/ghc/${FULLVER}/
DIST_SUBDIR= ghc-${FULLVER}
DOC_FILES= users_guide hslibs building libraries
@ -51,31 +43,37 @@ DOC_DIR= ${PREFIX}/share/doc/ghc
DISTFILES= ghc-${FULLVER}-src.tar.bz2 ghc-${BOOTVER}-src.tar.bz2:0 \
${DOC_FILES:C/(.+)/\1.html.tar.gz:1/g} \
ghc-regress-${FULLVER}.tar.bz2:2
ghc-regress-${FULLVER}.tar.bz2:2
.if ${MACHINE_ARCH} == "i386"
HCSRC=ghc-${BOOTVER}-x86-hc.tar.bz2:0
A="x86"
.elif ${MACHINE_ARCH} == "sparc"
HCSRC=ghc-${BOOTVER}-sparc-hc.tar.bz2:0
A="sparc"
.else
A="unreg"
.endif
DISTFILES+= ${HCSRC}
DISTFILES+= ghc-${BOOTVER}-${A}-hc.tar.bz2:0
REGRESS_DEPENDS=::lang/python/2.2
REGRESS_RESULT=${WRKSRC}/actual.result
REGRESS_FLAGS=TEST_HC="${WRKSRC}/ghc/compiler/stage2/ghc-inplace"
REGRESS_FLAGS+=EXTRA_RUNTEST_OPTS="--output-summary=${REGRESS_RESULT}"
REGRESS_RESULT= ${WRKSRC}/actual.result
REGRESS_FLAGS= TEST_HC="${WRKSRC}/ghc/compiler/stage2/ghc-inplace"
REGRESS_FLAGS+= EXTRA_RUNTEST_OPTS="--output-summary=${REGRESS_RESULT}"
# where the first compilers will be built
STAGE0= ${WRKDIR}/ghc-${BOOTVER}
USE_GMAKE= Yes
CONFIGURE_STYLE=gnu dest
CONFIGURE_ARGS=--with-ghc=${STAGE0}/ghc/driver/ghc-inplace
CONFIGURE_ARGS= --with-ghc=${STAGE0}/ghc/driver/ghc-inplace
CONFIGURE_ENV+= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib" \
LOCALBASE="${LOCALBASE}"
# Build the GHC-4 bootstrap compiler from C source
pre-configure:
@(cd ${STAGE0} ; distrib/hc-build --prefix=${STAGE0})
@(cd ${STAGE0} ;\
${CONFIGURE_ENV} distrib/hc-build --prefix=${STAGE0})
# note: ghci not in PLIST since it doesnt work yet
@ -85,4 +83,10 @@ post-install:
@tar zxf ${FULLDISTDIR}/${i} -C ${DOC_DIR}
.endfor
# BSD w/o advertising clause
PERMIT_PACKAGE_CDROM= Yes
PERMIT_PACKAGE_FTP= Yes
PERMIT_DISTFILES_CDROM= Yes
PERMIT_DISTFILES_FTP= Yes
.include <bsd.port.mk>

View File

@ -1,9 +1,11 @@
$OpenBSD: patch-___ghc-4_08_2_configure,v 1.3 2003/08/01 14:03:40 avsm Exp $
$OpenBSD: patch-___ghc-4_08_2_configure,v 1.4 2003/08/12 13:25:18 avsm Exp $
Self explanatory, including the annoying falsely detected
leading_underscore issue
Also, fix libgmp test so it works
--- ../ghc-4.08.2/configure.orig Wed Jan 31 02:04:23 2001
+++ ../ghc-4.08.2/configure Thu Apr 24 20:25:39 2003
+++ ../ghc-4.08.2/configure Thu Aug 7 11:06:12 2003
@@ -938,6 +938,15 @@
HostVendor_CPP='sun'
HostOS_CPP='solaris2'
@ -55,7 +57,21 @@ leading_underscore issue
if test -d $srcdir/ghc; then
echo
echo "Happy version 1.6 or later is required to compile GHC."
@@ -7364,6 +7372,7 @@
@@ -6251,10 +6259,11 @@
/* Override any gcc2 internal prototype to avoid an error. */
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char mpz_fdiv_qr();
+#include <gmp.h>
int main() {
-mpz_fdiv_qr()
+mpz_ptr a, b, p, q;
+mpz_fdiv_qr(p,q,a,b)
; return 0; }
EOF
if { (eval echo configure:6261: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
@@ -7364,6 +7373,7 @@
else
case $HostPlatform in

View File

@ -3,13 +3,16 @@ This knocks five minutes of the build time on my 2.4Ghz x86,
probably hours on really slow machines. There is no semantic
difference.
--- ../ghc-4.08.2/distrib/hc-build.orig Sun Aug 3 17:20:59 2003
+++ ../ghc-4.08.2/distrib/hc-build Sun Aug 3 17:21:05 2003
@@ -16,6 +16,7 @@
Help ghc find libgmp.a
--- ../ghc-4.08.2/distrib/hc-build.orig Wed Aug 9 21:09:43 2000
+++ ../ghc-4.08.2/distrib/hc-build Tue Aug 5 10:50:09 2003
@@ -16,6 +16,8 @@
GhcLibHcOpts = -O
SRC_HAPPY_OPTS += -c
GhcLibWays=
+SplitObjs=NO
+SRC_HC_OPTS += -L${LOCALBASE}/lib
END
# touch happy generated files; so that in non-bootstrapping mode for

View File

@ -0,0 +1,16 @@
Get hold of the real gmp.h, not the obsolete one ghc brings with
it. This gives sparc a chance
--- ../ghc-4.08.2/ghc/includes/Makefile.orig Tue Aug 8 02:00:58 2000
+++ ../ghc-4.08.2/ghc/includes/Makefile Tue Aug 5 10:25:58 2003
@@ -20,8 +20,8 @@
all :: $(H_CONFIG) NativeDefs.h
# gmp.h is copied from the GMP directory
-gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
- $(CP) $< $@
+gmp.h :
+ $(CP) $(LOCALBASE)/include/gmp.h $@
# The fptools configure script creates the configuration header file
# and puts it in fptools/mk/config.h. We copy it down to here, prepending

View File

@ -1,9 +1,10 @@
$OpenBSD: patch-configure,v 1.3 2003/08/01 14:03:40 avsm Exp $
$OpenBSD: patch-configure,v 1.4 2003/08/12 13:25:18 avsm Exp $
Falsely detects leading underscore. Plan for sparc.
Help configure find libgmp properly. i.e. fix test for gmp
--- configure.orig Fri Jul 4 10:43:52 2003
+++ configure Fri Jul 4 10:46:27 2003
@@ -1721,6 +1721,15 @@
--- configure.orig Tue Jul 29 05:01:34 2003
+++ configure Thu Aug 7 11:25:32 2003
@@ -1708,6 +1708,15 @@
HostVendor_CPP='sun'
HostOS_CPP='solaris2'
;;
@ -19,7 +20,24 @@ Falsely detects leading underscore. Plan for sparc.
*)
echo "Unrecognised platform: $HostPlatform"
exit 1
@@ -24084,6 +24093,7 @@
@@ -19591,12 +19600,13 @@
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
-char __gmpz_fdiv_qr ();
+#include <gmp.h>
+
int
main ()
{
-__gmpz_fdiv_qr ();
- ;
+ mpz_ptr a, b, p, q;
+ mpz_fdiv_qr(p,q,a,b);
return 0;
}
_ACEOF
@@ -23646,6 +23656,7 @@
else
case $HostPlatform in

View File

@ -0,0 +1,15 @@
Get the real gmp.h, not the obsolete one ghc brings with it
--- ghc/includes/Makefile.orig Sat Mar 22 02:45:56 2003
+++ ghc/includes/Makefile Tue Aug 5 10:25:05 2003
@@ -27,8 +27,8 @@
all :: $(H_CONFIG) NativeDefs.h
# gmp.h is copied from the GMP directory
-gmp.h : $(FPTOOLS_TOP)/ghc/rts/gmp/gmp.h
- $(CP) $< $@
+gmp.h :
+ $(CP) $(LOCALBASE)/include/gmp.h $@
# The fptools configure script creates the configuration header file
# and puts it in fptools/mk/config.h. We copy it down to here, prepending

View File

@ -0,0 +1,14 @@
Added extra ld options for the runtime system so it can find
libgmp. There is code in mk/package.mk that will:
s/LOCALBASE/${LOCALBASE}/
--- ghc/rts/package.conf.in.orig Sat May 17 10:11:27 2003
+++ ghc/rts/package.conf.in Wed Aug 6 15:12:45 2003
@@ -133,6 +133,7 @@
, "-u", "GHCziWeak_runFinalizzerBatch_closure"
, "-u", "__stginit_Prelude"
#endif
+ , "-L", "LOCALBASE/lib"
]
#ifdef HAVE_FRAMEWORK_HASKELLSUPPORT
, extra_frameworks = [ "HaskellSupport" ]

View File

@ -1,10 +1,13 @@
$OpenBSD: patch-mk_build_mk,v 1.2 2003/08/01 14:03:40 avsm Exp $
$OpenBSD: patch-mk_build_mk,v 1.3 2003/08/12 13:25:18 avsm Exp $
SplitObjs are unnecessary (it splits object files up), and seems
to use enormous amounts of memory, eventually stomping on my
stack/data/file size ulimits when set, and dumping core. Solution
: turn it off
--- mk/build.mk.orig Fri Jul 11 10:14:53 2003
+++ mk/build.mk Fri Jul 11 16:54:28 2003
@@ -0,0 +1,1 @@
Help ghc find libgmp.a
--- /dev/null Tue Aug 5 10:47:30 2003
+++ mk/build.mk Tue Aug 5 10:51:30 2003
@@ -0,0 +1,2 @@
+SplitObjs=NO
+SRC_HC_OPTS+=-L$(LOCALBASE)/lib

View File

@ -0,0 +1,18 @@
substitute in the path to localbase in the runtime package file,
so it can find libgmp.
--- mk/package.mk.orig Wed Aug 6 13:40:45 2003
+++ mk/package.mk Wed Aug 6 13:41:06 2003
@@ -9,10 +9,12 @@
ifeq "$(way)" ""
package.conf.inplace : package.conf.in
+ perl -pi.bak -e 's,LOCALBASE,'$(LOCALBASE)',' $<
$(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -x c $(PACKAGE_CPP_OPTS) $< \
| sed 's/^#.*$$//g' >$@
package.conf.installed : package.conf.in
+ perl -pi.bak -e 's,LOCALBASE,'$(LOCALBASE)',' $<
$(CPP) $(RAWCPP_FLAGS) -I$(GHC_INCLUDE_DIR) -DINSTALLING -x c $(PACKAGE_CPP_OPTS) $< \
| sed 's/^#.*$$//g' >$@

View File

@ -7,5 +7,3 @@ concurrency, a foreign language interface, several type-system
extensions, exceptions, and so on. GHC comes with a generational
garbage collector, a space and time profiler, and a comprehensive
set of libraries.
WWW: ${HOMEPAGE}

View File

@ -3,5 +3,3 @@ compiler for the functional programming language Haskell 98.
This package contains the users guide, build instructions, and
library specifications from the Haskell web site.
WWW: ${HOMEPAGE}

View File

@ -1,10 +1,10 @@
@comment $OpenBSD: PLIST,v 1.3 2003/08/03 18:07:27 avsm Exp $
@comment $OpenBSD: PLIST,v 1.4 2003/08/12 13:25:18 avsm Exp $
bin/ghc
bin/ghc-6.0.1
bin/ghc-pkg
bin/ghc-pkg-6.0.1
bin/ghci
bin/ghci-6.0.1
@comment bin/ghci
@comment bin/ghci-6.0.1
bin/ghcprof
bin/hasktags
bin/hp2ps
@ -857,7 +857,6 @@ lib/ghc-6.0.1/libHSunix_p.a
lib/ghc-6.0.1/libHSutil.a
lib/ghc-6.0.1/libHSutil_cbits.a
lib/ghc-6.0.1/libHSutil_p.a
lib/ghc-6.0.1/libgmp.a
lib/ghc-6.0.1/package.conf
lib/ghc-6.0.1/parse-gcstats.prl
lib/ghc-6.0.1/process-gcstats.prl