diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 611daea..6c2254f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: - run: opam pin add num . --no-action # Check building with make - - run: opam exec -- make + - run: opam exec -- make PROFILE=dev - run: opam exec -- make test - run: opam exec -- make clean diff --git a/Makefile.common b/Makefile.common index 5bb2c86..fe1782b 100644 --- a/Makefile.common +++ b/Makefile.common @@ -21,3 +21,29 @@ else NATIVE_COMPILER = true endif endif + +# PROFILE=dev or PROFILE=release +PROFILE ?= auto + +# Assume we're in release mode if there's no .git directory (means that an old +# school installation from a tarball assumes release mode, but a Git clone +# assumes development mode) +ifeq "$(PROFILE)" "auto" +# This file is included from a sub-directory, hence the ../ +ifeq "$(wildcard ../.git)" "" +PROFILE = release +else +PROFILE = dev +endif +endif + +ifneq "$(filter-out release dev, $(PROFILE))$(word 2, $(PROFILE))" "" +$(error The PROFILE variable must be one of auto, dev, or release) +endif + +# Only use -warn-error in dev mode +ifeq "$(PROFILE)" "dev" +WARN_ERROR = -warn-error +A +else +WARN_ERROR = +endif diff --git a/README.md b/README.md index 80cc920..ca41537 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ More documentation on the functions provided in this library can be found in _Th Prerequisites: OCaml version 4.04 or newer. ``` - make all + make all PROFILE=release make test make install make clean diff --git a/dune b/dune new file mode 100644 index 0000000..7faf7cd --- /dev/null +++ b/dune @@ -0,0 +1,16 @@ +(rule (with-stdout-to warnings.sexp (echo +; Add any warnings to this string (-warn-error +A is appended for the dev +; profile) + "(-w +a-4-9-41-42-44-45-48)" +))) + +(rule (with-stdout-to flags.sexp (echo +; Add any compilation flags to this string + "(-safe-string -strict-sequence -strict-formats)" +))) + +(env + (dev + (flags (:include warnings.sexp) -warn-error +A (:include flags.sexp))) + (release + (flags (:include warnings.sexp) (:include flags.sexp)))) diff --git a/num.opam b/num.opam index 97e4ba2..16ddbba 100644 --- a/num.opam +++ b/num.opam @@ -11,7 +11,8 @@ homepage: "https://github.com/ocaml/num/" bug-reports: "https://github.com/ocaml/num/issues" dev-repo: "git+https://github.com/ocaml/num.git" build: [ - [make "opam-legacy" {!ocaml:preinstalled & ocaml:version < "5.0.0~~"} + [make "PROFILE=release" + "opam-legacy" {!ocaml:preinstalled & ocaml:version < "5.0.0~~"} "opam-modern" {ocaml:preinstalled | ocaml:version >= "5.0.0~~"}] [make "test"] {with-test} ] diff --git a/src/Makefile b/src/Makefile index c7ab8c5..13e958c 100644 --- a/src/Makefile +++ b/src/Makefile @@ -9,7 +9,7 @@ else BNG_ARCH=$(ARCH) endif -CAMLCFLAGS=-w +a-4-9-41-42-44-45-48 -warn-error +A -bin-annot -g \ +CAMLCFLAGS=-w +a-4-9-41-42-44-45-48 $(WARN_ERROR) -bin-annot -g \ -safe-string -strict-sequence -strict-formats -I +compiler-libs CAMLOPTFLAGS=$(CAMLCFLAGS) ifeq "$(FLAMBDA)" "true" diff --git a/src/dune b/src/dune index cde1739..fc32f07 100644 --- a/src/dune +++ b/src/dune @@ -15,5 +15,4 @@ (language c) (names nat_stubs bng) (extra_deps (glob_files *.c)) - (flags "-DBNG_ARCH_%{architecture}")) - (flags -w +a-4-9-41-42-44-45-48 -warn-error +A -g -safe-string -strict-sequence -strict-formats)) + (flags "-DBNG_ARCH_%{architecture}"))) diff --git a/test/dune b/test/dune index 8d99b4a..ffa6235 100644 --- a/test/dune +++ b/test/dune @@ -9,7 +9,8 @@ (library (name test_lib) (modules test test_nats test_big_ints test_ratios test_nums test_io end_test) - (libraries num)) + (libraries num) + (flags )) (executable (name driver) diff --git a/toplevel/Makefile b/toplevel/Makefile deleted file mode 100644 index 9b786b7..0000000 --- a/toplevel/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -include ../Makefile.common - -CAMLCFLAGS=-I ../src -I +compiler-libs \ - -w +a-4-9-41-42-44-45-48 -warn-error +A \ - -safe-string -strict-sequence -strict-formats - -CMOS=num_top_printers.cmo num_top.cmo - -all: num_top.cma META - -num_top.cma: $(CMOS) - $(OCAMLC) $(CAMLCFLAGS) -a -o $@ $(CMOS) - -%.cmi: %.mli - $(OCAMLC) $(CAMLCFLAGS) -c $*.mli -%.cmo: %.ml - $(OCAMLC) $(CAMLCFLAGS) -c $*.ml - -TOINSTALL=\ - num_top.cma num_top.cmi num_top_printers.cmi - -META: META.in - echo 'version = "$(VERSION)"' > $@ - cat META.in >> $@ - -install: - $(OCAMLFIND) install num-top META $(TOINSTALL) - rm -f META - -uninstall: - $(OCAMLFIND) remove num-top - -clean: - rm -f *.cm[ioxta] *.cmx[as] *.cmti META - -depend: - $(OCAMLDEP) -slash *.mli *.ml > .depend - -include .depend diff --git a/toplevel/dune b/toplevel/dune index 745f0f0..ec23fcc 100644 --- a/toplevel/dune +++ b/toplevel/dune @@ -3,8 +3,7 @@ (public_name num.top) (libraries num compiler-libs) (wrapped false) - (modes byte) - (flags -w +a-4-9-41-42-44-45-48 -warn-error +A -safe-string -strict-sequence -strict-formats)) + (modes byte)) (rule (with-stdout-to META.shim