svn commit: r338413 - in head/lang: . modula3 modula3/files

John Marino marino at FreeBSD.org
Thu Jan 2 02:34:49 UTC 2014


Author: marino
Date: Thu Jan  2 02:34:47 2014
New Revision: 338413
URL: http://svnweb.freebsd.org/changeset/ports/338413

Log:
  Add lang/modula3: Critical Mass implementation of Modula-3
  
  This is a huge port.  It probably should be split into several separate
  ports, but Modula-3's lack of popularity doesn't justify the large
  effort that would require yet.
  
  This port will download a "bootstrap" compiler which builds a fresh
  compiler and small set of core components.  The fresh compiler will
  then build everything else.  This includes, among other things:
  
  * CM3 Integrated Development Environment (IDE)
  * CM3 Code Generator based on gcc 4.3
  * CM3 Middle- and back- ends
  * CVSup (CM3 is too new to build the CVSUP already in ports)
  * M3 GDB (GNU Debugger)
  * M3 GUI and networking support
  * M3 Quake
  * some demos
  * many examples
  * many CM3 tools
  * Oblique
  * Caltech Parser toolset
  * Full M3 library
  * Lots of documentation and man pages
  
  Intentionally left out for now: six (6) games, three (3) webdev progs,
  kate (gui), sgml+deepcopy (devlib), pp (m3devtool)
  
  This is the latest release of the Critical Mass Modula-3 (CM3) collection,
  version 5.8.6, and it was released in July 2010.  Days were spent
  developing this port, but not so much time was developed to quality
  assurance.  I added a "recent" patch from upstream for network concurrency
  and also modified the getaddrbyname implementation as the original one
  raised IPError exceptions due to my VM not having a fully qualified
  hostname and external IP address.  My modification makes the exception
  look up hostent with 127.0.0.1 first, then raise a new exception on error.
  It seems to work, but like I said, it was not heavily tested.
  
  Most of the programs require a running X (Trestle), which I don't have
  at the moment, so they stop with an appropriate raised exception.  I only
  assume they work, I'll have to check later.
  
  Right now only FreeBSD AMD64 is supported.  I do not expect to attempt
  to support FreeBSD i386.  I will probably make an attempt to cross-compile
  this on DragonFly x86-64 after appropriate patches are added.  A few
  months ago I nearly succeeded in porting CM3 to DragonFly and I expect to
  succeed on the next attempt.  If other platforms are desired, somebody
  else will have to create bootstraps and any necessary patches.
  
  This was built and poudriere-tested on FreeBSD 9.2.  Only libc, libm, and
  libpthread are dynamically loaded so it should build fine on FreeBSD 8.4.
  I don't have access to my Redports repository ATM so I can't test FreeBSD
  10+, but I will attempt to fix should it fail to build on those platforms.
  
  Hopefully someone will find this port useful.  I was surprised that
  apparently the full Modula-3 compiler set has never been ported to
  FreeBSD, only the ezm3 version needed to build cvsup.  Modula-3 is a nice
  language that probably deserved to be widely used outside of academia.

Added:
  head/lang/modula3/
  head/lang/modula3/Makefile   (contents, props changed)
  head/lang/modula3/distinfo   (contents, props changed)
  head/lang/modula3/files/
  head/lang/modula3/files/patch-m3-comm_tcp_src_POSIX_IP.m3   (contents, props changed)
  head/lang/modula3/files/patch-m3-libs_m3core_src_unix_Common_Unetdb.c   (contents, props changed)
  head/lang/modula3/files/patch-m3-sys_m3cc_gcc_configure   (contents, props changed)
  head/lang/modula3/files/patch-scripts_pkgcmds.sh   (contents, props changed)
  head/lang/modula3/pkg-descr   (contents, props changed)
Modified:
  head/lang/Makefile

Modified: head/lang/Makefile
==============================================================================
--- head/lang/Makefile	Thu Jan  2 01:35:29 2014	(r338412)
+++ head/lang/Makefile	Thu Jan  2 02:34:47 2014	(r338413)
@@ -166,6 +166,7 @@
     SUBDIR += ml-pnet
     SUBDIR += mlton
     SUBDIR += mmix
+    SUBDIR += modula3
     SUBDIR += mono
     SUBDIR += mono-basic
     SUBDIR += moscow_ml

Added: head/lang/modula3/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/Makefile	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,166 @@
+# Created by: marino at FreeBSD.org
+# $FreeBSD$
+
+PORTNAME=	modula3
+PORTVERSION=	5.8.6
+CATEGORIES=	lang
+MASTER_SITES=	https://modula3.elegosoft.com/cm3/releng/ \
+		http://download.dragonlace.net/m3/ \
+		http://download.dragonlace.net/m3/:boot
+DISTFILES=	${SRCDISTFILE} ${BOOTDIST}
+
+MAINTAINER=	marino at FreeBSD.org
+COMMENT=	Critical Mass Modula-3 compiler
+
+LIB_DEPENDS=	libodbc.so:${PORTSDIR}/databases/libiodbc
+
+NEWBOOTDIR=	${WRKDIR}/new-bootstrap/bootstrap
+SRCDISTFILE=	cm3-src-all-${PORTVERSION}-REL.tgz
+DST1=		m3-bootstrap.AMD64.FREEBSD.92.tar.bz2:boot
+DST2=		m3-bootstrap.x86_64.DRAGONFLY.36.tar.bz2:boot
+
+ONLY_FOR_ARCHS=		amd64
+CONFLICTS_INSTALL=	cvsup-*
+
+USES=		gmake
+USE_PGSQL=	yes
+USE_XORG=	xaw xmu xext xt sm ice x11
+USE_GL=		gl glu
+NO_MTREE=	yes
+
+MAKE_ENV+=	CM3_INSTALL="${STAGEDIR}${PREFIX}" \
+		CM3_DEBUG=yes \
+		M3_PORTABLE_RUN_PATH=yes
+BOOTCM3=	CM3="${WRKDIR}/bootstrap/bin/cm3"
+BUILTCM3=	CM3="${STAGEDIR}${PREFIX}/bin/cm3"
+BSCONTENTS=	bin/cm3 bin/cm3cg bin/m3bundle bin/mklib etc/modula3 \
+		lib/libm3core.* lib/libm3.* lib/libsysutils.* \
+		lib/libpatternmatching.* pkg/m3core pkg/libm3 pkg/sysutils \
+		pkg/patternmatching pkg/m3middle pkg/m3objfile pkg/m3linker \
+		pkg/m3back pkg/m3front pkg/m3quake pkg/cm3 pkg/mklib
+
+.include <bsd.port.pre.mk>
+
+M3MAKE_ENV=	${MAKE_ENV:C/^LDFLAGS=.*//:C/^CPPFLAGS=.*//}
+
+# for port maintenance, invoke "make makesum PLUS_BOOTSTRAPS=1"
+.if defined(PLUS_BOOTSTRAPS)
+DISTFILES=	${SRCDISTFILE} ${DST1} ${DST2}
+.else
+
+. if ${OPSYS} == FreeBSD
+BOOTDIST=	${DST1}
+MARCH=		AMD64
+. endif
+
+. if ${OPSYS} == DragonFly
+IGNORE=		modula-3 has not adapted to DragonFly yet
+BOOTDIST=	${DST2}
+MARCH=		x86_64
+. endif
+
+NEWBOOTNAME=	m3-bootstrap.${MARCH}.${OPSYS:U}.${OSREL:S/.//}.tar.bz2
+M3TARGET=	${MARCH}_${OPSYS:U}
+.endif
+
+do-extract:
+	@${RM} -rf ${WRKDIR}
+	@${MKDIR} ${WRKSRC}
+	@(cd ${WRKSRC} && tar -xf ${DISTDIR}/${SRCDISTFILE})
+	@(cd ${WRKDIR} && tar -xf ${DISTDIR}/${BOOTDIST:C/:[^:]+$//})
+
+post-patch:
+	@${REINPLACE_CMD} -e 's|/usr/local|${PREFIX}|g' \
+	    -e 's|\\\\$$ORIGIN"|${PREFIX}/lib"|' \
+	    ${WRKSRC}/m3-sys/cminstall/src/config-no-install/FreeBSD.common
+	@${REINPLACE_CMD} -e 's|/usr/X11R6|${PREFIX}|g' \
+	    ${WRKSRC}/m3-sys/cminstall/src/config-no-install/Unix.common
+
+do-bootstrap:
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BOOTCM3} SHIP=${TRUE} \
+		${SH} scripts/boot-cm3-with-m3.sh onlybuild)
+	@${FIND} ${WRKSRC} -name \.M3SHIP -print | ${XARGS} ${SED} -i -e \
+		's|/bootstrap/|/stage${PREFIX}/|g'
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BOOTCM3} \
+		${SH} scripts/boot-cm3-with-m3.sh ship)
+	(cd ${WRKSRC}/m3-sys/cminstall/src/config-no-install && \
+		${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/etc/modula3)
+	${INSTALL_PROGRAM} ${WRKSRC}/m3-sys/cm3/${M3TARGET}/cm3 \
+		${STAGEDIR}${PREFIX}/bin
+	${ECHO} "INSTALL_ROOT = \"${STAGEDIR}${PREFIX}\"" > \
+		${STAGEDIR}${PREFIX}/bin/cm3.cfg
+	${ECHO} "include(\"${STAGEDIR}${PREFIX}/etc/modula3/${M3TARGET}\")" >> \
+		${STAGEDIR}${PREFIX}/bin/cm3.cfg
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BOOTCM3} \
+		${SH} scripts/boot-cm3-with-m3.sh cleanglobal)
+	@${ECHO} "======================================"
+	@${ECHO} "=====  M3 compiler bootstrapped  ====="
+	@${ECHO} "======================================"
+	@${ECHO}
+
+do-build: do-bootstrap
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
+		${SH} scripts/do-cm3-min.sh buildship)
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
+		${SH} scripts/do-cm3-std.sh buildship)
+	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
+		${SH} scripts/do-cm3-caltech-parser.sh buildship)
+
+do-install:
+	${FIND} ${STAGEDIR}${PREFIX}/pkg -type f -perm +111 -not -name cm3 | \
+		${XARGS} ${CHMOD} -x
+	${ECHO} "INSTALL_ROOT = \"${PREFIX}\"" > \
+		${STAGEDIR}${PREFIX}/bin/cm3.cfg
+	${ECHO} "include(\"${PREFIX}/etc/modula3/${M3TARGET}\")" >> \
+		${STAGEDIR}${PREFIX}/bin/cm3.cfg
+	${MKDIR} ${STAGEDIR}${PREFIX}/share/examples/bin \
+	         ${STAGEDIR}${PREFIX}/share/doc
+	${MV} ${STAGEDIR}${PREFIX}/examples \
+		${STAGEDIR}${PREFIX}/share/examples/modula3
+	${MV} ${STAGEDIR}${PREFIX}/www ${STAGEDIR}${PREFIX}/share/doc/modula3
+	${MV} ${STAGEDIR}${PREFIX}/bin/Cube \
+		${STAGEDIR}${PREFIX}/bin/Calculator \
+		${STAGEDIR}${PREFIX}/bin/fisheye \
+		${STAGEDIR}${PREFIX}/share/examples/bin
+
+# The pkg-plist is well over 6000 entries, so let's just autogen it instead
+post-install:
+	cd ${STAGEDIR}${PREFIX}; ${FIND} * \( -type f -or -type l \) | \
+	   ${SORT} | ${SED} -e 's/^man\/man[1578]\/.*[1578]$$/&.gz/' \
+	   > ${TMPPLIST}
+	cd ${STAGEDIR}${PREFIX}; ${FIND} * -type d | ${SORT} -r | \
+	   ${SED} -e '/^bin$$/d' -e '/^lib$$/d' -e '/^pkg$$/d' \
+	   -e '/^share\/examples$$/d' -e '/^share\/doc$$/d' -e '/^share$$/d' \
+	   -e '/^etc$$/d' -e '/^man\/man[1578]$$/d' -e '/^man$$/d' \
+	   -e 's/^/@dirrm /g' >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/share/doc 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/share/examples 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/share 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/bin 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/etc 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/lib 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/man/man8 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/man/man7 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/man/man5 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/man/man1 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/man 2>/dev/null || true" >> ${TMPPLIST}
+	@echo "@unexec rmdir %D/pkg 2>/dev/null || true" >> ${TMPPLIST}
+
+# to create a new bootstrap, invoke "make stage NEW_BOOTSTRAP=1"
+.if defined(NEW_BOOTSTRAP)
+post-stage:
+	@${RM} -rf ${NEWBOOTDIR}
+	@${MKDIR} ${NEWBOOTDIR}/bin ${NEWBOOTDIR}/lib \
+	          ${NEWBOOTDIR}/pkg ${NEWBOOTDIR}/etc
+.for X in ${BSCONTENTS}
+	@${CP} -a ${STAGEDIR}${PREFIX}/${X} ${NEWBOOTDIR}/${X:H}/
+.endfor
+	${ECHO} "INSTALL_ROOT = path() & \"/..\"" \
+		>  ${NEWBOOTDIR}/bin/cm3.cfg
+	${ECHO} "include(path() & \"/../etc/modula3/${M3TARGET}\")" \
+		>> ${NEWBOOTDIR}/bin/cm3.cfg
+	@${FIND} ${NEWBOOTDIR} -type f -perm +111 | ${XARGS} ${STRIP_CMD}
+	(cd ${NEWBOOTDIR}/.. ; tar -cyf ${NEWBOOTNAME} bootstrap)
+.endif
+
+.include <bsd.port.post.mk>

Added: head/lang/modula3/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/distinfo	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,4 @@
+SHA256 (cm3-src-all-5.8.6-REL.tgz) = ef94f9a5f2a4413a1e544ae94233fb0f475db0be21af652b05f7d8c944b38d78
+SIZE (cm3-src-all-5.8.6-REL.tgz) = 89649351
+SHA256 (m3-bootstrap.AMD64.FREEBSD.92.tar.bz2) = b0396c9048876110683e915b773480fd0717ce3a376e518dae2f9093f18253a1
+SIZE (m3-bootstrap.AMD64.FREEBSD.92.tar.bz2) = 9983846

Added: head/lang/modula3/files/patch-m3-comm_tcp_src_POSIX_IP.m3
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/files/patch-m3-comm_tcp_src_POSIX_IP.m3	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,23 @@
+--- m3-comm/tcp/src/POSIX/IP.m3.orig	2009-03-09 16:55:46.000000000 +0000
++++ m3-comm/tcp/src/POSIX/IP.m3
+@@ -77,6 +77,8 @@ PROCEDURE GetAddress (ent: Unetdb.struct
+ PROCEDURE GetHostAddr(): Address =
+   VAR hname: ARRAY [0..255] OF CHAR;
+       hostent: Unetdb.struct_hostent;
++      lochost := ARRAY [0..9] OF CHAR {'1', '2', '7', '.', '0', '.', '0',
++                '.', '1', '\000'};
+   BEGIN
+     LOCK mu DO
+       IF Unix.gethostname(ADR(hname[0]), BYTESIZE(hname)) # 0 THEN
+@@ -84,7 +86,10 @@ PROCEDURE GetHostAddr(): Address =
+       END;
+       VAR h := Unetdb.gethostbyname(ADR(hname[0]), ADR(hostent));
+       BEGIN
+-        IF h = NIL THEN IPError.Die(); END;
++        IF h = NIL THEN
++          h := Unetdb.gethostbyname(ADR(lochost[0]), ADR(hostent)); 
++          IF h = NIL THEN IPError.Die(); END;
++        END;
+         RETURN GetAddress(h);
+       END;
+     END;

Added: head/lang/modula3/files/patch-m3-libs_m3core_src_unix_Common_Unetdb.c
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/files/patch-m3-libs_m3core_src_unix_Common_Unetdb.c	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,39 @@
+--- m3-libs/m3core/src/unix/Common/Unetdb.c.orig	2010-04-04 11:59:31.000000000 +0000
++++ m3-libs/m3core/src/unix/Common/Unetdb.c
+@@ -35,23 +35,31 @@ struct _m3_hostent_t
+ static m3_hostent_t* native_to_m3(const hostent_t* native, m3_hostent_t* m3)
+ {
+     if (native == NULL)
++    {
+         return NULL;
+-    m3->name = native->h_name;
+-    m3->aliases = native->h_aliases;
+-    m3->addrtype = native->h_addrtype;
+-    m3->length = native->h_length;
+-    m3->addr_list = native->h_addr_list;
++    }
++    else
++    {
++        m3->name = native->h_name;
++        m3->aliases = native->h_aliases;
++        m3->addrtype = native->h_addrtype;
++        m3->length = native->h_length;
++        m3->addr_list = native->h_addr_list;
++    }
++    Scheduler__EnableSwitching();
+     return m3;
+ }
+ 
+ m3_hostent_t* Unetdb__gethostbyname(const char* name, m3_hostent_t* m3)
+ {
++    Scheduler__DisableSwitching();
+     return native_to_m3(gethostbyname(name), m3);
+ }
+ 
+ m3_hostent_t*
+ Unetdb__gethostbyaddr(const char* addr, int len, int type, m3_hostent_t* m3)
+ {
++    Scheduler__DisableSwitching();
+     return native_to_m3(gethostbyaddr(addr, len, type), m3);
+ }
+ 

Added: head/lang/modula3/files/patch-m3-sys_m3cc_gcc_configure
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/files/patch-m3-sys_m3cc_gcc_configure	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,35 @@
+--- m3-sys/m3cc/gcc/configure.orig	2008-04-14 04:36:00.000000000 +0000
++++ m3-sys/m3cc/gcc/configure
+@@ -2147,10 +2147,6 @@ case "${target}" in
+     ;;
+   *-*-freebsd*)
+     noconfigdirs="$noconfigdirs target-newlib target-libgloss"
+-    if test "x$with_gmp" = x && test "x$with_gmp_dir" = x \
+-	&& test -f /usr/local/include/gmp.h; then
+-      with_gmp=/usr/local
+-    fi
+ 
+     # Skip some stuff that's unsupported on some FreeBSD configurations.
+     case "${target}" in
+@@ -4415,8 +4411,8 @@ if test "x$with_mpfr_lib" != x; then
+   gmplibs="-L$with_mpfr_lib $gmplibs"
+ fi
+ if test "x$with_mpfr$with_mpfr_include$with_mpfr_lib" = x && test -d ${srcdir}/mpfr; then
+-  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs -L$$r/$(HOST_SUBDIR)/mpfr/_libs '"$gmplibs"
+-  gmpinc='-I$$r/$(HOST_SUBDIR)/mpfr -I$$s/mpfr '"$gmpinc"
++  gmplibs='-L$$r/$(HOST_SUBDIR)/mpfr/.libs '"$gmplibs"
++  gmpinc='-I$$s/mpfr '"$gmpinc"
+   # Do not test the mpfr version.  Assume that it is sufficient, since
+   # it is in the source tree, and the library has not been built yet
+   # but it would be included on the link line in the version check below
+@@ -4467,8 +4463,8 @@ if test "x$with_gmp_lib" != x; then
+   gmplibs="-L$with_gmp_lib $gmplibs"
+ fi
+ if test "x$with_gmp$with_gmp_include$with_gmp_lib" = x && test -d ${srcdir}/gmp; then
+-  gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/.libs -L$$r/$(HOST_SUBDIR)/gmp/_libs '"$gmplibs"
+-  gmpinc='-I$$r/$(HOST_SUBDIR)/gmp -I$$s/gmp '"$gmpinc"
++  gmplibs='-L$$r/$(HOST_SUBDIR)/gmp/.libs '"$gmplibs"
++  gmpinc='-I$$r/$(HOST_SUBDIR)/gmp '"$gmpinc"
+   # Do not test the gmp version.  Assume that it is sufficient, since
+   # it is in the source tree, and the library has not been built yet
+   # but it would be included on the link line in the version check below

Added: head/lang/modula3/files/patch-scripts_pkgcmds.sh
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/files/patch-scripts_pkgcmds.sh	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,11 @@
+--- scripts/pkgcmds.sh.orig	2010-04-15 20:02:46.000000000 +0000
++++ scripts/pkgcmds.sh
+@@ -43,6 +43,8 @@ map_action() {
+     ACTION="${BUILDLOCAL}"
+   elif [ "$1" = "buildglobal" -o "$1" = "buildship" ] ; then
+     ACTION="${BUILDGLOBAL} && ${SHIP}"
++  elif [ "$1" = "onlybuild" ] ; then
++    ACTION="${BUILDGLOBAL}"
+   elif [ "$1" = "ship" ] ; then
+     ACTION="${SHIP}"
+   elif [ "$1" = "clean" -o "$1" = "cleanlocal" ] ; then

Added: head/lang/modula3/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/lang/modula3/pkg-descr	Thu Jan  2 02:34:47 2014	(r338413)
@@ -0,0 +1,12 @@
+Modula-3 is a systems programming language that descends from Mesa,
+Modula-2, Cedar, and Modula-2+.  It also resembles its cousins Oberon,
+Object Pascal, and Euclid.
+
+Modula-3 retains one of Modula-2's most successful features, the provision
+of explicit interfaces between modules.  It adds objects and classes,
+exception handling, garbage collection, lightweight processes (or threads),
+and the isolation of unsafe features.
+
+This is the Critical Mass implementation.
+
+WWW: http://www.modula3.org


More information about the svn-ports-all mailing list