From ff5a552fe3036e749ad8926e80014f2a2ea09f9a Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 8 Sep 2024 14:15:53 +0100 Subject: [PATCH 1/5] Use $(...) instead of `...` --- configure | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/configure b/configure index 76b997f..73edc81 100755 --- a/configure +++ b/configure @@ -231,7 +231,7 @@ fi # directories if test "$ocamllibdir" = "auto" -then ocamllibdir=`ocamlc -where | sed 's/\r$//'` +then ocamllibdir="$(ocamlc -where | sed 's/\r$//')" fi if test ! -f "$ocamllibdir/caml/mlvalues.h" @@ -258,7 +258,7 @@ searchbin ocamlfind if test $? -eq 1 && test $ocamlfind != "no"; then instmeth='findlib' if test "$installdir" = "auto" - then installdir=`ocamlfind printconf destdir`; fi + then installdir="$(ocamlfind printconf destdir)"; fi else searchbin install if test $? -eq 1; then instmeth='install' @@ -270,7 +270,7 @@ fi # detect OCaml's word-size echo "print_int (Sys.word_size);;" > tmp.ml -wordsize=`ocaml tmp.ml` +wordsize="$(ocaml tmp.ml)" echo "OCaml's word size is $wordsize" rm -f tmp.ml @@ -312,7 +312,7 @@ if test "$gmp" != 'OK'; then echo "cannot find GMP nor MPIR"; exit 2; fi # OCaml version -ocamlver=`ocamlc -version` +ocamlver="$(ocamlc -version)" # OCaml version 4.04 or later is required From b718e20ff574118b94d5eba6160c1aa5c94c1d6e Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 8 Sep 2024 14:19:25 +0100 Subject: [PATCH 2/5] Generate Makefile.config instead of Makefile --- .gitignore | 2 +- project.mak => Makefile | 2 ++ configure | 4 +--- 3 files changed, 4 insertions(+), 4 deletions(-) rename project.mak => Makefile (99%) diff --git a/.gitignore b/.gitignore index 6ee9be0..05a35c1 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,6 @@ *.byt *.o *.so -Makefile +Makefile.config depend zarith_version.ml diff --git a/project.mak b/Makefile similarity index 99% rename from project.mak rename to Makefile index 3d5a837..49ed694 100644 --- a/project.mak +++ b/Makefile @@ -10,6 +10,8 @@ # ENS (École normale supérieure, Paris, France), # INRIA Rocquencourt (Institut national de recherche en informatique, France). +include Makefile.config + ifeq "$(shell $(OCAMLC) -config |grep ccomp_type)" "ccomp_type: msvc" OBJSUFFIX := obj LIBSUFFIX := lib diff --git a/configure b/configure index 73edc81..9886270 100755 --- a/configure +++ b/configure @@ -340,7 +340,7 @@ esac # dump Makefile -cat > Makefile < Makefile.config < Date: Sun, 8 Sep 2024 14:22:07 +0100 Subject: [PATCH 3/5] Move Windows-tests from Makefile to configure Consequently share them with tests/Makefile --- Makefile | 20 +------------------- configure | 30 +++++++++++++++++++++++++++++- tests/Makefile | 12 ++++++------ 3 files changed, 36 insertions(+), 26 deletions(-) diff --git a/Makefile b/Makefile index 49ed694..d795e60 100644 --- a/Makefile +++ b/Makefile @@ -12,24 +12,6 @@ include Makefile.config -ifeq "$(shell $(OCAMLC) -config |grep ccomp_type)" "ccomp_type: msvc" -OBJSUFFIX := obj -LIBSUFFIX := lib -DLLSUFFIX := dll -EXE := .exe -else -OBJSUFFIX := o -LIBSUFFIX := a -ifeq "$(findstring mingw,$(shell $(OCAMLC) -config |grep system))" "mingw" -DLLSUFFIX := dll -EXE := .exe -else -DLLSUFFIX := so -EXE := -endif -endif - - # project files ############### @@ -147,7 +129,7 @@ endif $(OCAMLC) -ccopt "$(CFLAGS)" -c $< clean: - /bin/rm -rf *.$(OBJSUFFIX) *.$(LIBSUFFIX) *.$(DLLSUFFIX) *.cmi *.cmo *.cmx *.cmxa *.cmxs *.cma *.cmt *.cmti *~ \#* depend test $(AUTOGEN) tmp.c depend + /bin/rm -rf *.o *.obj *.lib *.a *.cmi *.cmo *.cmx *.cmxa *.cmxs *.cma *.cmt *.cmti *~ \#* depend test $(AUTOGEN) tmp.c depend make -C tests clean depend: $(AUTOGEN) diff --git a/configure b/configure index 9886270..00fbe5c 100755 --- a/configure +++ b/configure @@ -34,7 +34,6 @@ ccdef='' mlflags="$OCAMLFLAGS" mloptflags="$OCAMLOPTFLAGS" mlinc="$OCAMLINC" -objsuffix="o" ocamlfind="auto" # sanitize @@ -209,6 +208,30 @@ else ccopt="-O3 -Wall -Wextra $CFLAGS" fi +case "$("$ocamlc" -config | tr -d '\r' | sed -ne '/^system:/s/.*: //p')" in + win32|win64) + # MSVC + objsuffix='obj' + libsuffix='lib' + dllsuffix='dll' + exe='.exe' + ;; + mingw|mingw64) + # mingw-w64 + objsuffix='o' + libsuffix='a' + dllsuffix='dll' + exe='.exe' + ;; + *) + # Unix + objsuffix='o' + libsuffix='a' + dllsuffix='so' + exe='' + ;; +esac + # optional native-code generation hasocamlopt='no' @@ -359,9 +382,14 @@ INSTALL=install OCAMLFIND=ocamlfind INSTMETH=$instmeth OBJSUFFIX=$objsuffix +LIBSUFFIX=$libsuffix +DLLSUFFIX=$dllsuffix +EXESUFFIX=$exe HASOCAMLOPT=$hasocamlopt HASDYNLINK=$hasdynlink HASBINANNOT=$hasbinannot +WORDSIZE=$wordsize +STDLIBDIR=$ocamllibdir EOF diff --git a/tests/Makefile b/tests/Makefile index 73ee2cb..3e57d3f 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,5 +1,3 @@ -WORDSIZE:=$(shell echo 'print_int Sys.word_size' | ocaml -stdin) -STDLIBDIR:=$(shell ocamlc -where) ifeq ($(wildcard $(STDLIBDIR)/big_int.cmi),) HAS_NUM=false NUMS_CMA= @@ -10,6 +8,8 @@ NUMS_CMA=nums.cma NUMS_CMXA=nums.cmxa endif +include ../Makefile.config + test:: zq.exe @echo "Testing zq (native)..." @if ./zq.exe | cmp -s zq.output$(WORDSIZE) - ; then echo "zq: passed"; else echo "zq: FAILED"; exit 2; fi @@ -58,16 +58,16 @@ test:: intern.exe extern.data$(WORDSIZE): extern.exe ./extern.exe extern.data$(WORDSIZE) -tofloat.exe: tofloat.ml setround.o ../zarith.cmxa +tofloat.exe: tofloat.ml setround.$(OBJSUFFIX) ../zarith.cmxa ocamlopt -I .. -ccopt "-L.." zarith.cmxa -o tofloat.exe \ - setround.o tofloat.ml + setround.$(OBJSUFFIX) tofloat.ml %.exe: %.ml ../zarith.cmxa ocamlopt -I .. -ccopt "-L.." zarith.cmxa $(NUMS_CMXA) -o $*.exe $*.ml %.byt: %.ml ../zarith.cma ocamlc -I .. -ccopt "-L.." zarith.cma $(NUMS_CMA) -o $*.byt $*.ml -%.o: %.c +%.$(OBJSUFFIX): %.c ocamlc -c $*.c clean: - rm -f *.cm[iox] *.o *.exe *.byt + rm -f *.cm[iox] *.o *.obj *.exe *.byt From a6e3c4f376c357f7ee3113f9f483175e54e716a9 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 8 Sep 2024 14:22:30 +0100 Subject: [PATCH 4/5] Missing patterns in .gitignore --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 05a35c1..9b60f89 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.a +*.lib *.cm? *.cmxa *.cmxs @@ -6,7 +7,9 @@ *.exe *.byt *.o +*.obj *.so +*.dll Makefile.config depend zarith_version.ml From 78c9f89c575d0f1ad1ef5acb278f48f6059a5119 Mon Sep 17 00:00:00 2001 From: David Allsopp Date: Sun, 8 Sep 2024 14:22:41 +0100 Subject: [PATCH 5/5] Strip CR characters from more commands tr -d '\r' is definitely Posix (and shorter than sed) --- configure | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/configure b/configure index 00fbe5c..d8dbb51 100755 --- a/configure +++ b/configure @@ -254,7 +254,7 @@ fi # directories if test "$ocamllibdir" = "auto" -then ocamllibdir="$(ocamlc -where | sed 's/\r$//')" +then ocamllibdir="$(ocamlc -where | tr -d '\r')" fi if test ! -f "$ocamllibdir/caml/mlvalues.h" @@ -281,7 +281,7 @@ searchbin ocamlfind if test $? -eq 1 && test $ocamlfind != "no"; then instmeth='findlib' if test "$installdir" = "auto" - then installdir="$(ocamlfind printconf destdir)"; fi + then installdir="$(ocamlfind printconf destdir | tr -d '\r')"; fi else searchbin install if test $? -eq 1; then instmeth='install'