From e6cd8d3940aee898a1250a9e52128773821866a3 Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Tue, 26 Jul 2022 11:54:39 +0200
Subject: [PATCH] [man] restore man installation

---
 dune                        |  2 +-
 man/dune                    | 40 +++++++++++++++++++++++++++++++++++++
 opam/opam                   |  2 +-
 share/Makefile.installation | 19 ++++++++++++++----
 src/plugins/e-acsl/man/dune | 27 +++++++++++++++++++++++++
 5 files changed, 84 insertions(+), 6 deletions(-)
 create mode 100644 man/dune
 create mode 100644 src/plugins/e-acsl/man/dune

diff --git a/dune b/dune
index 88f9131e447..390a079328f 100644
--- a/dune
+++ b/dune
@@ -21,7 +21,7 @@
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (alias (name default) (deps (alias install)))
-(dirs src tools tests headers share bin)
+(dirs bin headers man share src tools tests)
 
 (executable
  (name configurator)
diff --git a/man/dune b/man/dune
new file mode 100644
index 00000000000..d1ff77d3e0b
--- /dev/null
+++ b/man/dune
@@ -0,0 +1,40 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;                                                                        ;;
+;;  This file is part of Frama-C.                                         ;;
+;;                                                                        ;;
+;;  Copyright (C) 2007-2022                                               ;;
+;;    CEA (Commissariat à l'énergie atomique et aux énergies              ;;
+;;         alternatives)                                                  ;;
+;;                                                                        ;;
+;;  you can redistribute it and/or modify it under the terms of the GNU   ;;
+;;  Lesser General Public License as published by the Free Software       ;;
+;;  Foundation, version 2.1.                                              ;;
+;;                                                                        ;;
+;;  It 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 Lesser General Public License for more details.                   ;;
+;;                                                                        ;;
+;;  See the GNU Lesser General Public License version 2.1                 ;;
+;;  for more details (enclosed in the file licenses/LGPLv2.1).            ;;
+;;                                                                        ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(rule
+ (target frama-c.1.generated)
+ (deps frama-c.1.md)
+ (enabled_if %{bin-available:pandoc})
+ (action (run pandoc -s -t man %{deps} -o %{target}))
+)
+
+(rule
+ (alias check-man)
+ (deps frama-c.1 frama-c.1.generated)
+ (action (diff frama-c.1 frama-c.1.generated))
+)
+
+(install
+ (package frama-c)
+ (section man)
+ (files frama-c.1)
+)
diff --git a/opam/opam b/opam/opam
index b6bf8efb427..b47f7904317 100644
--- a/opam/opam
+++ b/opam/opam
@@ -92,7 +92,7 @@ build: [
 ]
 
 install: [
-  [make "INSTALLDIR=%{prefix}%" "install"]
+  [make "INSTALLDIR=%{prefix}%" "MANDIR=%{mandir}%" "install"]
   [make "PREFIX=%{prefix}%" "-C" "doc" "install"] {with-doc}
 ]
 
diff --git a/share/Makefile.installation b/share/Makefile.installation
index 535654377a2..4e89956359c 100644
--- a/share/Makefile.installation
+++ b/share/Makefile.installation
@@ -31,6 +31,17 @@
 # Default: Dune installs in the Opam directory
 INSTALLDIR?=
 
+# Set this variable to request a specific man installation directory
+# Default: the manuals are installed in the installation directory transmitted
+# to Dune (so either in Opam or in INSTALLDIR)
+MANDIR?=
+
+ifeq (${MANDIR},)
+MANDIR_OPT=
+else
+MANDIR_OPT=--mandir ${MANDIR}
+endif
+
 ################################
 ## Install and uninstall
 
@@ -38,18 +49,18 @@ INSTALLDIR?=
 
 install:
 ifeq ($(INSTALLDIR),)
-	dune install
+	dune install ${MANDIR_OPT}
 else
 	@echo "Installing to prefix: ${INSTALLDIR}"
-	dune install --prefix ${INSTALLDIR}
+	dune install --prefix ${INSTALLDIR} ${MANDIR_OPT}
 	@echo 'DO NOT FORGET TO EXPAND YOUR OCAMLPATH VARIABLE:'
 	@echo '  export OCAMLPATH="${INSTALLDIR}/lib:$$OCAMLPATH"'
 endif
 
 uninstall:
 ifeq ($(INSTALLDIR),)
-	dune uninstall
+	dune uninstall ${MANDIR_OPT}
 else
 	@echo "Uninstalling from prefix: ${INSTALLDIR}"
-	dune uninstall --prefix ${INSTALLDIR}
+	dune uninstall --prefix ${INSTALLDIR} ${MANDIR_OPT}
 endif
diff --git a/src/plugins/e-acsl/man/dune b/src/plugins/e-acsl/man/dune
new file mode 100644
index 00000000000..44b5571eb4e
--- /dev/null
+++ b/src/plugins/e-acsl/man/dune
@@ -0,0 +1,27 @@
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;;                                                                        ;;
+;;  This file is part of the Frama-C's E-ACSL plug-in.                    ;;
+;;                                                                        ;;
+;;  Copyright (C) 2012-2022                                               ;;
+;;    CEA (Commissariat à l'énergie atomique et aux énergies              ;;
+;;         alternatives)                                                  ;;
+;;                                                                        ;;
+;;  you can redistribute it and/or modify it under the terms of the GNU   ;;
+;;  Lesser General Public License as published by the Free Software       ;;
+;;  Foundation, version 2.1.                                              ;;
+;;                                                                        ;;
+;;  It 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 Lesser General Public License for more details.                   ;;
+;;                                                                        ;;
+;;  See the GNU Lesser General Public License version 2.1                 ;;
+;;  for more details (enclosed in the file licenses/LGPLv2.1).            ;;
+;;                                                                        ;;
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+(install
+ (package frama-c-e-acsl)
+ (section man)
+ (files e-acsl-gcc.sh.1)
+)
-- 
GitLab