diff --git a/lib/common/ocaml/Makefile b/lib/common/ocaml/Makefile index c6ce48d3..c7bb6a01 100644 --- a/lib/common/ocaml/Makefile +++ b/lib/common/ocaml/Makefile @@ -33,27 +33,16 @@ endif OCAMLBUILD=ocamlbuild -use-ocamlfind -CAMLP4_DEFS ?= # # NOTE: due to a bug in older ocamlbuild versions the build-dir can NOT be absolute # see http://caml.inria.fr/mantis/view.php?id=5503 -# -OCAML_VERSION := $(shell ocamlc -version) -OCAML_MAJOR := $(shell echo $(OCAML_VERSION) | cut -f1 -d.) -OCAMLC_MINOR := $(shell echo $(OCAML_VERSION) | cut -f2 -d.) # using a recent ocaml(build) version >= 4, # but build-dir MUST NOT contain .. # so use some magic here to get a normalized absolute path if PPRZLINK_DIR is not set PPRZLINK_DIR ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../../..) BUILDDIR ?= $(PPRZLINK_DIR)/build/ocaml/pprzlink -ifeq ($(shell test $(OCAMLC_MINOR) -ge 2; echo $$?),0) -ifeq ($(shell test $(OCAMLC_MINOR) -ge 4; echo $$?),0) -CAMLP4_DEFS += -DOCAML_V404 -endif -endif - INSTALL_FLAGS ?= # use this option leave ocamlfind ldconf file unchanged INSTALL_FLAGS += -ldconf ignore @@ -62,7 +51,6 @@ ifneq ($(DESTDIR),) INSTALL_FLAGS += -destdir $(DESTDIR) endif -PP_OPTS = -pp "camlp4o pa_macro.cmo $(CAMLP4_DEFS)" # enforce checking a clear type checking between bytes and string C_OPTS = -cflags -safe-string INSTALL_FILES = $(shell ls $(BUILDDIR)/*.so $(BUILDDIR)/*.a $(BUILDDIR)/*.mli $(BUILDDIR)/*.cm* $(BUILDDIR)/common/*.mli $(BUILDDIR)/common/*.cm*) @@ -73,20 +61,20 @@ all: byte native byte: _tags META @echo Build bytecode lib $(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR) - $(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) $(C_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cma + $(Q)$(OCAMLBUILD) $(QUIET) $(C_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cma $(Q)cp META $(BUILDDIR) # byte with statically linked libs static: _tags META @echo Build bytecode lib with static linking $(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR) - $(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) $(C_OPTS) -build-dir $(BUILDDIR) -tag static -I common lib-pprzlink.cma + $(Q)$(OCAMLBUILD) $(QUIET) $(C_OPTS) -build-dir $(BUILDDIR) -tag static -I common lib-pprzlink.cma $(Q)cp META $(BUILDDIR) native: _tags META @echo Build native lib $(Q)test -d $(BUILDDIR) || mkdir -p $(BUILDDIR) - $(Q)$(OCAMLBUILD) $(QUIET) $(PP_OPTS) $(C_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cmxa + $(Q)$(OCAMLBUILD) $(QUIET) $(C_OPTS) -build-dir $(BUILDDIR) -I common lib-pprzlink.cmxa $(Q)cp META $(BUILDDIR) install: clean_lib byte native META diff --git a/lib/common/ocaml/compatPL.ml b/lib/common/ocaml/compatPL.ml deleted file mode 100644 index c6654775..00000000 --- a/lib/common/ocaml/compatPL.ml +++ /dev/null @@ -1,39 +0,0 @@ -(* - * Abstract some String/Byte functions for compatibility between OCaml 3.x and 4.x - * - * Copyright (C) 2016 Felix Ruess - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - -IFDEF OCAML_V404 THEN -let lowercase_ascii = String.lowercase_ascii - -let uppercase_ascii = String.uppercase_ascii - -let capitalize_ascii = String.capitalize_ascii - -ELSE -let lowercase_ascii = String.lowercase - -let uppercase_ascii = String.uppercase - -let capitalize_ascii = String.capitalize - -END diff --git a/lib/common/ocaml/compatPL.mli b/lib/common/ocaml/compatPL.mli deleted file mode 100644 index 2b725f67..00000000 --- a/lib/common/ocaml/compatPL.mli +++ /dev/null @@ -1,27 +0,0 @@ -(* - * Abstract some String/Byte functions for compatibility between OCaml 3.x and 4.x - * - * Copyright (C) 2016 Felix Ruess - * - * This file is part of paparazzi. - * - * paparazzi is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2, or (at your option) - * any later version. - * - * paparazzi is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with paparazzi; see the file COPYING. If not, write to - * the Free Software Foundation, 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - *) - -val lowercase_ascii : string -> string -val uppercase_ascii : string -> string -val capitalize_ascii : string -> string diff --git a/lib/v1.0/ocaml/lib-pprzlink.mllib b/lib/v1.0/ocaml/lib-pprzlink.mllib index c75b1721..50f35058 100644 --- a/lib/v1.0/ocaml/lib-pprzlink.mllib +++ b/lib/v1.0/ocaml/lib-pprzlink.mllib @@ -4,4 +4,3 @@ protocol pprz_transport pprzlog_transport xbee_transport -compatPL diff --git a/lib/v1.0/ocaml/pprzLink.ml b/lib/v1.0/ocaml/pprzLink.ml index c3381d66..42c1389c 100644 --- a/lib/v1.0/ocaml/pprzLink.ml +++ b/lib/v1.0/ocaml/pprzLink.ml @@ -245,7 +245,7 @@ let scale_of_units = fun ?auto from_unit to_unit -> and a = try Some (Xml.attrib u "auto") with _ -> None in let a = match auto, a with | Some _, None | None, None -> "" (* No auto conversion *) - | Some t, Some _ | None, Some t -> CompatPL.lowercase_ascii t (* param auto is used before attribute *) + | Some t, Some _ | None, Some t -> String.lowercase_ascii t (* param auto is used before attribute *) in if (f = from_unit || a = "display") && (t = to_unit || a = "code") then true else false ) (Xml.children units_xml) in @@ -332,14 +332,14 @@ let field_of_xml = fun xml -> let auc = alt_unit_coef_of_xml xml in let values = try Str.split pipe_regexp (Xml.attrib xml "values") with _ -> [] in - ( CompatPL.lowercase_ascii (xml_attrib xml "name"), + ( String.lowercase_ascii (xml_attrib xml "name"), { _type = t; fformat = f; alt_unit_coef = auc; enum=values }) let string_of_values = fun vs -> String.concat " " (List.map (fun (a,v) -> sprintf "%s=%s" a (string_of_value v)) vs) let assoc = fun a vs -> - try List.assoc (CompatPL.lowercase_ascii a) vs with Not_found -> + try List.assoc (String.lowercase_ascii a) vs with Not_found -> failwith (sprintf "Attribute '%s' not found in '%s'" a (string_of_values vs)) let float_assoc = fun (a:string) vs -> diff --git a/lib/v2.0/ocaml/lib-pprzlink.mllib b/lib/v2.0/ocaml/lib-pprzlink.mllib index c75b1721..50f35058 100644 --- a/lib/v2.0/ocaml/lib-pprzlink.mllib +++ b/lib/v2.0/ocaml/lib-pprzlink.mllib @@ -4,4 +4,3 @@ protocol pprz_transport pprzlog_transport xbee_transport -compatPL diff --git a/lib/v2.0/ocaml/pprzLink.ml b/lib/v2.0/ocaml/pprzLink.ml index 68e94464..e897e7a1 100644 --- a/lib/v2.0/ocaml/pprzLink.ml +++ b/lib/v2.0/ocaml/pprzLink.ml @@ -248,7 +248,7 @@ let scale_of_units = fun ?auto from_unit to_unit -> and a = try Some (Xml.attrib u "auto") with _ -> None in let a = match auto, a with | Some _, None | None, None -> "" (* No auto conversion *) - | Some t, Some _ | None, Some t -> CompatPL.lowercase_ascii t (* param auto is used before attribute *) + | Some t, Some _ | None, Some t -> String.lowercase_ascii t (* param auto is used before attribute *) in if (f = from_unit || a = "display") && (t = to_unit || a = "code") then true else false ) (Xml.children units_xml) in @@ -335,14 +335,14 @@ let field_of_xml = fun xml -> let auc = alt_unit_coef_of_xml xml in let values = try Str.split pipe_regexp (Xml.attrib xml "values") with _ -> [] in - ( CompatPL.lowercase_ascii (xml_attrib xml "name"), + ( String.lowercase_ascii (xml_attrib xml "name"), { _type = t; fformat = f; alt_unit_coef = auc; enum=values }) let string_of_values = fun vs -> String.concat " " (List.map (fun (a,v) -> sprintf "%s=%s" a (string_of_value v)) vs) let assoc = fun a vs -> - try List.assoc (CompatPL.lowercase_ascii a) vs with Not_found -> + try List.assoc (String.lowercase_ascii a) vs with Not_found -> failwith (sprintf "Attribute '%s' not found in '%s'" a (string_of_values vs)) let float_assoc = fun (a:string) vs -> diff --git a/tools/generator/Makefile b/tools/generator/Makefile index 2c4798fb..aedf2db4 100644 --- a/tools/generator/Makefile +++ b/tools/generator/Makefile @@ -28,21 +28,12 @@ OCAMLBUILD=ocamlbuild -use-ocamlfind # # NOTE: due to a bug in older ocamlbuild versions the build-dir can NOT be absolute # see http://caml.inria.fr/mantis/view.php?id=5503 -# -OCAML_VERSION := $(shell ocamlc -version) -OCAML_MAJOR := $(shell echo $(OCAML_VERSION) | cut -f1 -d.) -ifeq ($(shell test $(OCAML_MAJOR) -lt 4; echo $$?),0) -# need to use an old buggy ocaml(build) version: dir MUST be relative -OCAML_LIBDIR ?= ../../build/ocaml -BUILDDIR ?= ../../build/ocaml/gen -else # using a recent ocaml(build) version without THAT particular bug, # but dir MUST NOT contain .. # so use some magic here to get a normalized absolute path if PPRZLINK_DIR is not set PPRZLINK_DIR ?= $(realpath $(dir $(lastword $(MAKEFILE_LIST)))/../..) OCAML_LIBDIR ?= $(PPRZLINK_DIR)/build/ocaml BUILDDIR ?= $(PPRZLINK_DIR)/build/ocaml/gen -endif # FIXME test if pprzlink is installed in the system or try local build export OCAMLPATH=$(OCAML_LIBDIR)