Improve handling of the system architecture in `lang/ocaml'.

OCaml is using ARCH variable throughout its makefiles, which clashes with
our own variable of the same name.  To workaround it, OCAML_ARCH variable
was introduced which is set based on ARCH, and makefiles later patched in
the `post-configure' target.

This approach does not scale well with porting OCaml to new architectures
as being fragile and sometimes making the build non-idempotent under some
circumstances.

Instead of "fixing" makefiles post-configure, rename ARCH to SYSTEM_ARCH:
this avoids the clash altogether and lets configure script to set correct
values for supported architectures in the first place with no adjustments
required afterwards.

Tested on:	i386, amd64, powerpc
This commit is contained in:
Alexey Dokuchaev 2017-12-15 15:15:02 +00:00
parent 1b21df1fb3
commit 79cfdfcb24
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=456400
2 changed files with 16 additions and 6 deletions

View File

@ -99,10 +99,7 @@ CONFIGURE_ARGS+=-no-graph
.include <bsd.port.pre.mk>
.include "${FILESDIR}/manfiles"
OCAML_ARCH= ${ARCH:S/x86_64/amd64/:S/powerpc/power/:C/armv.*/arm/}
.if defined(NO_PROFILE) || ${OCAML_ARCH:Mpower} || ${OCAML_ARCH:Mamd64}
.if defined(NO_PROFILE) || ${ARCH:Mpowerpc} || ${ARCH:Mamd64}
PLIST_SUB+= PROF="@comment "
.else
PLIST_SUB+= PROF=""
@ -119,6 +116,7 @@ post-extract:
.endif
post-patch:
# Don't hardcode GCC for depend target
@${REINPLACE_CMD} \
-e '\|MKLIB=|s|ar rc|${AR} rc|' \
-e '\|RANLIB|s|ranlib|${RANLIB}|' \
@ -127,7 +125,11 @@ post-patch:
-e '\|mksharedlib=|s|$$bytecc|& $$bytecclinkopts|' \
-e 's|-lbfd -ldl|-lbfd $$dllib|' \
${WRKSRC}/configure
# don't hardcode gcc for depend target
@${REINPLACE_CMD} -e 's,$$(ARCH),$$(SYSTEM_ARCH),' \
${WRKSRC}/Makefile ${WRKSRC}/asmrun/Makefile \
${WRKSRC}/otherlibs/systhreads/Makefile \
${WRKSRC}/testsuite/makefiles/Makefile.common \
${WRKSRC}/testsuite/tests/asmcomp/Makefile
post-configure:
# CFLAGS safeness
@ -141,7 +143,6 @@ post-configure:
# user's umask(1)
@${FIND} ${WRKDIR} -type f -name Makefile -print0 | \
${XARGS} -0 -n 5 -x ${REINPLACE_CMD} -E \
-e 's,\$$\(ARCH\),${OCAML_ARCH},g' \
-e 's,^(${PATTERN}+.*INSTALLDIR),\1\$${BSD_INSTALL_DATA} \4,' \
-e 's,^(${PATTERN}+.*BINDIR),\1\$${BSD_INSTALL_PROGRAM} \4,' \
-e 's,^(${PATTERN}+.*LIBDIR),\1\$${BSD_INSTALL_DATA} \4,' \

View File

@ -178,3 +178,12 @@
# Final twiddling of compiler options to work around known bugs
nativeccprofopts="$nativecccompopts"
@@ -1723,7 +1728,7 @@ SYSLIB=-l\$(1)
MKLIB=${TOOLPREF}ar rc \$(1) \$(2); ${TOOLPREF}ranlib \$(1)
#ml let mklib out files opts = Printf.sprintf "${TOOLPREF}ar rc %s %s %s; ${TOOLPREF}ranlib %s" out opts files out;;
EOF
-echo "ARCH=$arch" >> Makefile
+echo "SYSTEM_ARCH=$arch" >> Makefile
echo "MODEL=$model" >> Makefile
echo "SYSTEM=$system" >> Makefile
echo "NATIVECC=$nativecc" >> Makefile