[M3devel] Stuck on adding new cm3 target (AMD64_DRAGONFLY)

John Marino adacore at marino.st
Sun Jan 19 13:09:37 CET 2014

On 1/19/2014 12:40, Jay K wrote:
> Your change looks about right.
> Did you first "upgrade" and existing install, with these changes, and
> then cross?
> That is what you must do.

It's probably easier that I show you.
I've attached "Makefile.local" (I added the .txt extension just now to
help out some mail clients) which is my recipe.

So I run three targets in a freshly patched workarea:
1) make cross-compiler
2) make assembler-code (called from cross-archive)
3) make cross-archive

In the cross-compiler target, the FreeBSD bootstrap compiler builds
m3middle, m3linker, m3front, mequake, and CM3 for the cross compiler.

The cross-compiler then builds libm3core and libm3 with FreeBSD cm3cg
Everything is cleaned, then the cross compiler builds everything again
(including libm3core and libm3) along with m3objfile, sysutils, and

Then the cm3.cfg is changed to specify HOST=freebsd, TARGET=dragonfly,
cm3cg is cm3cg-AMD64_DRAGONFLY.

I would not be surprised is there is a logic flaw or two in "make
cross-compiler".  The "how to port CM3" tutorial was slightly out of
date and some of the instructions were a bit ambiguous so this was a
best guess.

-------------- next part --------------
# This makefile fragment is automatically included by bsd.port.mk
# It is separate because it contains maintenance targets not used in
# normal package building, but the recipes are too value to lose.  So
# we keep them with the port, but out of the way of regular users.
# $FreeBSD$

# The "create-bootstrap" target will assemble a new bootstrap based on the
# contents of the stage directory, which means it has to be run after the
# "stage" target.

NEWBOOTDIR=	${WRKDIR}/new-bootstrap/bootstrap
NEWBOOTNAME=	m3-bootstrap.${MARCH}.${OPSYS:U}.${OSREL:S/.//}.tar.bz2
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

	@${RM} -rf ${NEWBOOTDIR}
	          ${NEWBOOTDIR}/pkg ${NEWBOOTDIR}/etc
.for X in ${BSCONTENTS}
	@${CP} -a ${STAGEDIR}${PREFIX}/${X} ${NEWBOOTDIR}/${X:H}/
	${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)

# The "cross-compiler" target will create a cross-compiler in the
# stage directory based on the value of ${CROSSTARG}.
# Execute it after the "patch" target
# The "cross-archive" will archive assembler code meant for linking
# on the native plaform.  It is run after "cross-compiler"
# The "native-link" target will bootstrap cm3 on a new platform (which
# obviously supports ports) using the archived files generated above.
# It could be done remotely via SSH, but this one target assumes files
# are locally available at ${WRKSRC}/${CROSSTARG}

CORELIBS=	m3-libs/m3core m3-libs/libm3
CORESYS=	m3-sys/m3middle m3-sys/m3objfile m3-sys/m3linker \
		m3-sys/m3back m3-sys/m3front m3-sys/m3quake m3-sys/cm3 \
COREHELPERS=	m3-libs/sysutils m3-libs/patternmatching

		${SH} scripts/build-cross-backend.sh ${CROSSTARG})
		${SH} scripts/do-pkg.sh onlybuild \
		m3middle m3linker m3front m3quake cm3)
	@${FIND} ${WRKSRC} -name \.M3SHIP -print | ${XARGS} ${SED} -i -e \
	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BOOTCM3} \
		${SH} scripts/do-pkg.sh ship \
		m3middle m3linker m3front m3quake cm3)	
	(cd ${WRKSRC}/m3-sys/cminstall/src/config-no-install && \
		${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/etc/modula3)
	${INSTALL_PROGRAM} ${WRKSRC}/m3-sys/cm3/${M3TARGET}/cm3 \
	${ECHO} "include(\"${STAGEDIR}${PREFIX}/etc/modula3/${M3TARGET}\")" >> \
	${INSTALL_PROGRAM} ${WRKDIR}/bootstrap/bin/cm3cg \
		${WRKSRC}/m3-sys/m3cc/${M3TARGET}-${CROSSTARG}/cm3cg \
	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BOOTCM3} \
		${SH} scripts/do-pkg.sh cleanglobal \
		m3middle m3linker m3front m3quake cm3)
.for component in ${CORELIBS}
	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
		${SH} scripts/do-pkg.sh buildship ${component:T})
	@(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
		${SH} scripts/do-pkg.sh cleanglobal ${CORELIBS:T})
.for component in ${CORELIBS} ${COREHELPERS} ${CORESYS}
	@(cd ${WRKSRC}; \
	    ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
		${SH} scripts/do-pkg.sh buildship ${component:T}; \
	    ${SETENV} ${M3MAKE_ENV} ${BUILTCM3} \
		${SH} scripts/do-pkg.sh cleanglobal ${component:T} \
	${ECHO} "m3back = INSTALL_ROOT & \"/bin/cm3cg-${CROSSTARG}\"" >> \
	${ECHO} "BUILD_DIR = \"${CROSSTARG}\"" >> \
	${ECHO} "HOST = \"${M3TARGET}\"" >> ${STAGEDIR}${PREFIX}/bin/cm3.cfg
	${ECHO} "include(\"${STAGEDIR}${PREFIX}/etc/modula3/${CROSSTARG}\")" >> \
	${ECHO} "M3_BOOTSTRAP = TRUE" >> ${STAGEDIR}${PREFIX}/bin/cm3.cfg
	@${ECHO} "====================================="
	@${ECHO} "=====  M3 cross-compiler ready  ====="
	@${ECHO} "====================================="

.for component in ${COREFILES}
	    ${BUILTCM3} ${SH} scripts/do-pkg.sh onlybuild ${component:T} \
.for component in m3-libs/libm3 m3-sys/m3middle
	echo '#include "m3core.h"' > \
	${CP} ${WRKSRC}/m3-libs/m3core/src/m3core.h \
	(cd ${WRKSRC}/m3-sys/m3middle; ${CP} src/POSIX/m3core.h ${CROSSTARG}/)

cross-archive: assembler-code
	(cd ${WRKSRC}; ${SETENV} ${M3MAKE_ENV} M3GDB=no ${BUILTCM3} \
		${SH} scripts/pack-crossbuild.sh ${CROSSTARG})

# This target requires python to be installed
	@(cd ${WRKSRC}/m3-sys/m3cc; src/boot.py)
	${INSTALL_PROGRAM} ${WRKSRC}/m3-sys/m3cc/obj.1/gcc/m3cgc1 \

native-link: native-cm3cg
.for component in ${COREFILES}
	@(cd ${WRKSRC}/${CROSSTARG}; ${TAR} -xzf ${component:T}.tgz)
	@(cd ${WRKSRC}/scripts; \
		./boot-cm3-build-on-target.sh ${CROSSTARG})
	${INSTALL_PROGRAM} ${WRKSRC}/${CROSSTARG}/m3-tools/m3bundle/${CROSSTARG}/m3bundle \

More information about the M3devel mailing list