[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ocaml-findlib cannot compile on m68k



Stefano Zacchiroli a écrit :
> 
> I receive a bug report for findlib that state the failure of compilation
> on m68k.
> The reason is pretty simple and already know (not for me anyway): on
> m68k ocaml optimizing compiler is not available.
> Talking with Claudio I realize that this is an old problem widely know.
> 
> What is the old adopted solution ?
> 

I do not know what it is but I myself use an autoconf generated
configure script testing whether the optimizing compiler is there or
not. Then it sets a variable OCAMLBEST to "opt" or "byte", and the
target "all" of my Makefile does ${MAKE} ${OCAMLBEST}.

Here are the configure.in and template Makefile.in I use. As it is based
on work from Jean-Christophe Filliâtre and Georges Mariano, so I have to
have their formal agreement to put it in GPL but I think there is no
problem with this (I already have the agreement of Jean-Christophe, I
will see Georges today and will ask him).
For the moment, there is no specific macro in this script. However, if
anybody is interested and I could package the tests done in configure.in
as new autoconf macros.

Sincerly yours,

Judicaël Courant.
-- 
Judicael.Courant@lri.fr, http://www.lri.fr/~jcourant/
(+33) (0)1 69 15 64 85
"Montre moi des morceaux de ton monde, et je te montrerai le mien"
Tim, matricule #929, condamné à mort.
http://rozenn.picard.free.fr/tim.html
# autoconf input for Objective Caml programs
# modified by Judicaël Courant from a version
# by Jean-Christophe Filliâtre, from a first script by Georges Mariano
#
# the script generated by autoconf from this input will set the following
# variables:
#   OCAMLC        "ocamlc" if present in the path, or a failure
#                 or "ocamlc.opt" if present with same version number as ocamlc
#   OCAMLOPT      "ocamlopt" (or "ocamlopt.opt" if present), or "no"
#   OCAMLBEST     either "byte" if no native compiler was found, 
#                 or "opt" otherwise
#   OCAMLDEP      "ocamldep"
#   OCAMLLEX      "ocamllex"
#   OCAMLYACC     "ocamlyac"
#   OCAMLLIB      the path to the ocaml standard library
#   OCAMLVERSION  the ocaml version number

# check for one particular file of the sources 
# ADAPT THE FOLLOWING LINE TO YOUR SOURCES!
AC_INIT(lexer.mll)

# default prefix is /usr
#AC_PREFIX_DEFAULT(/usr)

# Check for Ocaml compilers

# we first look for ocamlc in the path; if not present, we fail
AC_CHECK_PROG(OCAMLC,ocamlc,ocamlc,no)
if test "$OCAMLC" = no ; then
	AC_MSG_ERROR(Cannot find ocamlc.)
fi

# we extract Ocaml version number and library path
OCAMLVERSION=`$OCAMLC -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
echo "ocaml version is $OCAMLVERSION"
OCAMLLIB=`$OCAMLC -v | tail -1 | cut -f 4 -d " "`
echo "ocaml library path is $OCAMLLIB"

# then we look for ocamlopt; if not present, we issue a warning
# if the version is not the same, we also discard it
# we set OCAMLBEST to "opt" or "byte", whether ocamlopt is available or not
AC_CHECK_PROG(OCAMLOPT,ocamlopt,ocamlopt,no)
OCAMLBEST=byte
if test "$OCAMLOPT" = no ; then
	AC_MSG_WARN(Cannot find ocamlopt; bytecode compilation only.)
else
	AC_MSG_CHECKING(ocamlopt version)
	TMPVERSION=`$OCAMLOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
	    AC_MSG_RESULT(differs from ocamlc; ocamlopt discarded.)
	    OCAMLOPT=no
	else
	    AC_MSG_RESULT(ok)
	    OCAMLBEST=opt
	fi
fi

# checking for ocamlc.opt
AC_CHECK_PROG(OCAMLCDOTOPT,ocamlc.opt,ocamlc.opt,no)
if test "$OCAMLCDOTOPT" != no ; then
	AC_MSG_CHECKING(ocamlc.opt version)
	TMPVERSION=`$OCAMLCDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
	if test "$TMPVERSION" != "$OCAMLVERSION" ; then
	    AC_MSG_RESULT(differs from ocamlc; ocamlc.opt discarded.)
	else
	    AC_MSG_RESULT(ok)
	    OCAMLC=$OCAMLCDOTOPT
	fi
fi

# checking for ocamlopt.opt
if test "$OCAMLOPT" != no ; then
    AC_CHECK_PROG(OCAMLOPTDOTOPT,ocamlopt.opt,ocamlopt.opt,no)
    if test "$OCAMLOPTDOTOPT" != no ; then
	AC_MSG_CHECKING(ocamlc.opt version)
	TMPVER=`$OCAMLOPTDOTOPT -v | sed -n -e 's|.*version* *\(.*\)$|\1|p' `
	if test "$TMPVER" != "$OCAMLVERSION" ; then
	    AC_MSG_RESULT(differs from ocamlc; ocamlopt.opt discarded.)
	else
	    AC_MSG_RESULT(ok)
	    OCAMLOPT=$OCAMLOPTDOTOPT
	fi
    fi
fi

# ocamldep, ocamllex and ocamlyacc should also be present in the path
AC_CHECK_PROG(OCAMLDEP,ocamldep,ocamldep,no)
if test "$OCAMLDEP" = no ; then
	AC_MSG_ERROR(Cannot find ocamldep.)
fi

AC_CHECK_PROG(OCAMLLEX,ocamllex,ocamllex,no)
if test "$OCAMLLEX" = no ; then
	AC_MSG_ERROR(Cannot find ocamllex.)
fi

AC_CHECK_PROG(OCAMLYACC,ocamlyacc,ocamlyacc,no)
if test "$OCAMLYACC" = no ; then
	AC_MSG_ERROR(Cannot find ocamlyacc.)
fi

# substitutions to perform
AC_SUBST(OCAMLC)
AC_SUBST(OCAMLOPT)
AC_SUBST(OCAMLDEP)
AC_SUBST(OCAMLLEX)
AC_SUBST(OCAMLYACC)
AC_SUBST(OCAMLBEST)
AC_SUBST(OCAMLVERSION)
AC_SUBST(OCAMLLIB)

# Finally create the Makefile from Makefile.in
AC_OUTPUT(Makefile)
# Makefile for Ocaml
####################

# CMO files to be compiled
CMO      = 
CMX      = $(CMO:.cmo=.cmx)

# name of the executable that should be produced
PROG = 
# how to produce it : byte or opt
# NB: OCAMLBEST is
#              - "opt" if the optimizing compiler is available
#              - "byte" otherwise
DEFAULT=byte

GENERATEDML=

LINKFLAGS=
prefix=@prefix@
exec_prefix=@exec_prefix@
bindir=@bindir@
libdir=@libdir@
srcdir=@srcdir@

#
INSTALL=shtool install
INSTALL_PROGRAM=${INSTALL} -c -s -m a+rx

OCAMLC   = @OCAMLC@
OCAMLOPT = @OCAMLOPT@
OCAMLDEP = @OCAMLDEP@
OCAMLLEX = @OCAMLLEX@
OCAMLYACC= @OCAMLYACC@
OCAMLLIB = @OCAMLLIB@
OCAMLBEST= @OCAMLBEST@
OCAMLVERSION = @OCAMLVERSION@

PPRO=@PPRO@

INCLUDES = 


all:: ${DEFAULT}

byte:: ${CMO}
	${OCAMLC} ${LINKFLAGS} -o ${PROG} ${CMO}

opt:: ${CMX}
	${OCAMLOPT} ${LINKFLAGS} -o ${PROG} ${CMX}

install::
	${INSTALL_PROGRAM} ${PROG} ${libdir}

# generic rules :
#################

.SUFFIXES: .mli .ml .cmi .cmo .cmx .mll .mly .mlp

.mli.cmi:
	$(OCAMLC) -c $(FLAGS) $<

.ml.cmo:
	$(OCAMLC) -c $(FLAGS) $<

.ml.o:
	$(OCAMLOPT) -c $(FLAGS) $<

.ml.cmx:
	$(OCAMLOPT) -c $(FLAGS) $<

.mll.ml:
	$(OCAMLLEX) $<

.mly.ml:
	$(OCAMLYACC) -v $<

.mly.mli:
	$(OCAMLYACC) -v $<

.mlp.ml:
	$(PPRO) $< > $@ || (rm -f $@; exit 1)

# Emacs tags
############

tags:
	find . -name "*.ml*" | sort -r | xargs \
	etags "--regex=/let[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/let[ \t]+rec[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/and[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/type[ \t]+\([^ \t]+\)/\1/" \
              "--regex=/exception[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/val[ \t]+\([^ \t]+\)/\1/" \
	      "--regex=/module[ \t]+\([^ \t]+\)/\1/"

# backup, clean and depend :
############################

clean::
	rm -f *.cm[iox] *.o *~
	rm -f ${GENERATEDML}

depend:: ${GENERATEDML}
	rm -f .depend
	$(OCAMLDEP) $(INCLUDES) *.ml *.mli > .depend

${srcdir}/configure: configure.in
	cd ${srcdir} && autoconf


Makefile: Makefile.in config.status
	./config.status

config.status: configure
	./config.status --recheck

include .depend

Reply to: