Description: Patch installation paths for Debian packaging
Author: Andreas Bombe <aeb@debian.org>
Forwarded: not-needed
Last-Update: 2021-10-31
---
This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
--- a/Makefile.in
+++ b/Makefile.in
@@ -24,6 +24,7 @@
 backend=@backend@
 libdirsuffix=@libdirsuffix@
 libdirreverse=@libdirreverse@
+incdirsuffix=@incdirsuffix@
 EXEEXT=@EXEEXT@
 SOEXT=@SOEXT@
 PIC_FLAGS=@PIC_FLAGS@
@@ -46,8 +47,8 @@
 PWD=$(CURDIR)
 DESTDIR=
 bindir=$(prefix)/bin
-libdir=$(prefix)/lib
-incdir=$(prefix)/include
+libdir=$(prefix)/$(libdirsuffix)
+incdir=$(prefix)/$(incdirsuffix)
 MKDIR=mkdir
 LN=ln -s
 CP=cp
@@ -56,7 +57,7 @@
 GRT_RANLIB=ranlib
 GHDL_DESC?=tarball
 
-VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)
+VHDL_LIB_DIR=$(prefix)/$(libdirsuffix)/vhdl
 
 ifeq "$(enable_checks)" "true"
  # Debug + checks
@@ -203,7 +204,7 @@
 	$(MAKE) -f $(srcdir)/libraries/Makefile.inc $(LIBVHDL_FLAGS_TO_PASS) GHDL=$(PWD)/ghdl_mcode$(EXEEXT) GHDL_FLAGS="" VHDL_COPY_OBJS=no vhdl.libs.all
 
 install.mcode.program: install.dirs ghdl_mcode$(EXEEXT)
-	$(INSTALL_PROGRAM) ghdl_mcode$(EXEEXT) $(DESTDIR)$(bindir)/ghdl$(EXEEXT)
+	$(INSTALL_PROGRAM) ghdl_mcode$(EXEEXT) $(DESTDIR)$(bindir)/ghdl-mcode$(EXEEXT)
 
 uninstall.mcode.program:
 	$(RM) $(DESTDIR)$(bindir)/ghdl$(EXEEXT)
@@ -375,8 +376,8 @@
 	 LLVM_CONFIG="$(LLVM_CONFIG)" CXX="$(CXX)"
 
 install.llvm.program: install.dirs ghdl1-llvm$(EXEEXT) ghdl_llvm$(EXEEXT)
-	$(INSTALL_PROGRAM) ghdl_llvm$(EXEEXT) $(DESTDIR)$(bindir)/ghdl$(EXEEXT)
-	$(INSTALL_PROGRAM) ghdl1-llvm$(EXEEXT) $(DESTDIR)$(bindir)/ghdl1-llvm$(EXEEXT)
+	$(INSTALL_PROGRAM) ghdl_llvm$(EXEEXT) $(DESTDIR)$(bindir)/ghdl-llvm$(EXEEXT)
+	$(INSTALL_PROGRAM) ghdl1-llvm$(EXEEXT) $(DESTDIR)$(libdir)/ghdl1-llvm$(EXEEXT)
 
 test.llvm: ghdl_llvm$(EXEEXT)
 	cd $(srcdir)/testsuite; GHDL=$(CURDIR)/ghdl_llvm$(EXEEXT) ./testsuite.sh
--- a/configure
+++ b/configure
@@ -32,6 +32,7 @@
 LDFLAGS=
 prefix=/usr/local
 libdirsuffix=lib/ghdl
+incdirsuffix=include
 libdirreverse=../..
 gcc_src_dir=
 llvm_config=
@@ -52,7 +53,7 @@
 show_help=no
 progname=$0
 
-subst_vars="CC CXX GNATMAKE MAKE CFLAGS LDFLAGS build srcdir abs_srcdir prefix backend libdirsuffix libdirreverse gcc_src_dir llvm_config llvm_be backtrace_lib build_mode EXEEXT SOEXT PIC_FLAGS default_pic enable_werror enable_checks enable_gplcompat enable_libghdl libghdl_version ghdl_version"
+subst_vars="CC CXX GNATMAKE MAKE CFLAGS LDFLAGS build srcdir abs_srcdir prefix backend libdirsuffix libdirreverse incdirsuffix gcc_src_dir llvm_config llvm_be backtrace_lib build_mode EXEEXT SOEXT PIC_FLAGS default_pic enable_werror enable_checks enable_gplcompat enable_libghdl libghdl_version ghdl_version"
 
 # Find srcdir
 srcdir=`dirname $progname`
@@ -91,6 +92,8 @@
       ;;
     --prefix=*)             prefix="$optarg";;
     --srcdir=*)             srcdir="$optarg";;
+    --libdir=*)             libdirsuffix="$optarg";;
+    --incdir=*)             incdirsuffix="$optarg";;
     --with-gcc=*)           gcc_src_dir="$optarg";     backend=gcc;;
     --with-llvm=*)
       echo "--with-llvm is deprecated, use --with-llvm-config"
@@ -126,6 +129,8 @@
 Options [defaults in brackets]:
   --prefix=PREFIX             install in PREFIX [$prefix]
   --srcdir=SRCDIR             source code path [$srcdir]
+  --libdir=LIBDIR             lib dir path relative to PREFIX [$libdirsuffix]
+  --incdir=INCDIR             C include dir path relative to PREFIX [$incdirsuffix]
   --with-gcc=DIR              use gcc backend from DIR
   --with-llvm-config[=LLVM-CONFIG]  use llvm backend [llvm-config]
   --with-backtrace-lib=LIB.a  link with libbacktrace LIB.a to display a
@@ -400,10 +405,11 @@
 sed -e "s%@COMPILER_GCC@%ghdl1-gcc$EXEEXT%" \
     -e "s%@COMPILER_DEBUG@%ghdl1-debug$EXEEXT%" \
     -e "s%@COMPILER_MCODE@%ghdl1-mcode$EXEEXT%" \
-    -e "s%@COMPILER_LLVM@%ghdl1-llvm$EXEEXT%" \
+    -e "s%@COMPILER_LLVM@%lib/ghdl/llvm/ghdl1-llvm$EXEEXT%" \
     -e "s%@POST_PROCESSOR@%oread-$backend%" \
     -e "s%@INSTALL_PREFIX@%$prefix%" \
     -e "s%@LIB_PREFIX@%$libdirsuffix%" \
+    -e "s%@INC_PREFIX@%$incdirsuffix%" \
     -e "s%@SOEXT@%$SOEXT%" \
     -e "s%@default_pic@%$default_pic%" \
     < $srcdir/src/ghdldrv/default_paths.ads.in > default_paths.ads
--- a/scripts/gcc/Make-lang.in
+++ b/scripts/gcc/Make-lang.in
@@ -104,7 +104,9 @@
 	echo "   Compiler_Llvm  : constant String := \"\";" >> tmp-dpaths.ads
 	echo "   Post_Processor : constant String := \"\";" >> tmp-dpaths.ads
 	echo "   Lib_Prefix     : constant String :=">> tmp-dpaths.ads
-	echo "     \"lib/ghdl\";" >> tmp-dpaths.ads
+	echo "     \"lib/ghdl/gcc\";" >> tmp-dpaths.ads
+	echo "   Inc_Prefix     : constant String :=" >> tmp-dpaths.ads
+	echo "     \"lib/ghdl/include\";" >> tmp-dpaths.ads
 	echo "   Shared_Library_Extension : constant String :=">> tmp-dpaths.ads
 	echo "     \"$(VHDL_SOEXT)\";" >> tmp-dpaths.ads
 	echo "   Default_Pie : constant Boolean := False;" >> tmp-dpaths.ads
@@ -159,8 +161,8 @@
 # Install the driver program as ghdl.
 vhdl.install-common: ghdl$(exeext) ghdl1$(exeext)
 	-mkdir $(DESTDIR)$(bindir)
-	-$(RM) $(DESTDIR)$(bindir)/ghdl$(exeext)
-	$(INSTALL_PROGRAM) ghdl$(exeext) $(DESTDIR)$(bindir)/ghdl$(exeext)
+	-$(RM) $(DESTDIR)$(bindir)/ghdl-gcc$(exeext)
+	$(INSTALL_PROGRAM) ghdl$(exeext) $(DESTDIR)$(bindir)/ghdl-gcc$(exeext)
 	-mkdir $(DESTDIR)$(libdir)
 	-mkdir $(DESTDIR)$(libdir)/ghdl
 	$(INSTALL_DATA) ../libbacktrace/.libs/libbacktrace.a $(DESTDIR)$(libdir)/ghdl
--- a/src/ghdldrv/default_paths.ads.in
+++ b/src/ghdldrv/default_paths.ads.in
@@ -23,6 +23,8 @@
      "@INSTALL_PREFIX@";
    Lib_Prefix : constant String :=
      "@LIB_PREFIX@";
+   Inc_Prefix : constant String :=
+     "@INC_PREFIX@";
 
    Compiler_Gcc : constant String :=
      "@COMPILER_GCC@";
--- a/src/ghdldrv/ghdllocal.adb
+++ b/src/ghdldrv/ghdllocal.adb
@@ -385,9 +385,9 @@
    function Get_Machine_Path_Prefix return String is
    begin
       if Flag_32bit then
-         return Lib_Prefix_Path.all & "32";
+         return Lib_Prefix_Path.all & "32" & Directory_Separator & "vhdl";
       else
-         return Lib_Prefix_Path.all;
+         return Lib_Prefix_Path.all & Directory_Separator & "vhdl";
       end if;
    end Get_Machine_Path_Prefix;
 
--- a/src/ghdldrv/ghdlvpi.adb
+++ b/src/ghdldrv/ghdlvpi.adb
@@ -37,7 +37,7 @@
       --  Compute install path
       Ghdllocal.Set_Exec_Prefix_From_Program_Name;
 
-      return Ghdllocal.Exec_Prefix.all & Directory_Separator & "include";
+      return Ghdllocal.Exec_Prefix.all & Directory_Separator & Inc_Prefix;
    end Get_Vpi_Include_Dir;
 
    --  Return the lib directory.
@@ -48,7 +48,7 @@
          Ghdllocal.Set_Exec_Prefix_From_Program_Name;
       end if;
 
-      return Ghdllocal.Exec_Prefix.all & Directory_Separator & "lib";
+      return Ghdllocal.Exec_Prefix.all & Directory_Separator & Lib_Prefix;
    end Get_Vpi_Lib_Dir;
 
    --  Return the lib directory, but unixify the path (for a unix shell in
