From 00452ff743fd19421911b2ed323ee2b152d62ffa Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Fri, 1 Jul 2022 14:38:37 +0200
Subject: [PATCH] [build] share Makefile (un)installation rules

---
 Makefile                    | 19 +++----------
 share/Makefile.installation | 53 +++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+), 16 deletions(-)
 create mode 100644 share/Makefile.installation

diff --git a/Makefile b/Makefile
index 3888fe55efe..b89fe3aba89 100644
--- a/Makefile
+++ b/Makefile
@@ -182,25 +182,12 @@ force-reconfigure:
 ##############################################################################
 # INSTALL/UNINSTALL
 ################################
-.PHONY: install uninstall
 
-FRAMAC_INSTALLDIR?=""
+FRAMAC_INSTALLDIR?=
 
-install:
-ifeq ($(FRAMAC_INSTALLDIR),"")
-	dune install
-else
-	dune install --prefix ${FRAMAC_INSTALLDIR}
-	@echo 'DO NOT FORGET TO EXPAND YOUR OCAMLPATH VARIABLE:'
-	@echo '  export OCAMLPATH="${FRAMAC_INSTALLDIR}/lib:$$OCAMLPATH"'
-endif
+INSTALLDIR:=$(FRAMAC_INSTALLDIR)
 
-uninstall:
-ifeq ($(FRAMAC_INSTALLDIR),"")
-	dune uninstall
-else
-	dune uninstall --prefix ${FRAMAC_INSTALLDIR}
-endif
+include share/Makefile.installation
 
 ###############################################################################
 # HEADER MANAGEMENT
diff --git a/share/Makefile.installation b/share/Makefile.installation
new file mode 100644
index 00000000000..c5cd0159c6c
--- /dev/null
+++ b/share/Makefile.installation
@@ -0,0 +1,53 @@
+##########################################################################
+#                                                                        #
+#  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).            #
+#                                                                        #
+##########################################################################
+
+################
+# INSTALLATION #
+################
+
+################################
+## Default variables
+
+# Set this variable to request a specific installation directory
+# Default: Dune installs in the Opam directory
+INSTALLDIR?=
+
+################################
+## Install and uninstall
+
+.PHONY: install uninstall
+
+install:
+ifeq ($(INSTALLDIR),)
+	dune install
+else
+	dune install --prefix ${INSTALLDIR}
+	@echo 'DO NOT FORGET TO EXPAND YOUR OCAMLPATH VARIABLE:'
+	@echo '  export OCAMLPATH="${INSTALLDIR}/lib:$$OCAMLPATH"'
+endif
+
+uninstall:
+ifeq ($(INSTALLDIR),)
+	dune uninstall
+else
+	dune uninstall --prefix ${INSTALLDIR}
+endif
-- 
GitLab