From 55e33158573e38a4c385ca705e26784176d9b508 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Sun, 13 Mar 2022 15:30:54 +0100 Subject: Fix include-dir paths returned by cmdline _again_ --libghdl-include-dir should point at a directory containing a ghdl/ subdirectory while --vpi-include-dir should point right at the ghdl/ subdir. --- Makefile.in | 11 ++++++++--- configure | 2 +- src/ghdldrv/ghdlvpi.adb | 3 ++- testsuite/gna/issue2005/test.c | 9 +++++++++ testsuite/gna/issue2005/testsuite.sh | 21 +++++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 testsuite/gna/issue2005/test.c create mode 100755 testsuite/gna/issue2005/testsuite.sh diff --git a/Makefile.in b/Makefile.in index f99927395..12657beae 100644 --- a/Makefile.in +++ b/Makefile.in @@ -52,7 +52,7 @@ DESTDIR= bindir=$(prefix)/bin libdir=$(prefix)/$(libdirsuffix) libghdldir=$(prefix)/$(libghdldirsuffix) -incdir=$(prefix)/$(incdirsuffix) +incdir=$(prefix)/$(incdirsuffix)/ghdl MKDIR=mkdir LN=ln -s CP=cp @@ -470,6 +470,11 @@ install.libghdl.include: install.dirs $(srcdir)/src/synth/include/synth_gates.h $(INSTALL_DATA) -p $(srcdir)/src/synth/include/synth.h $(DESTDIR)$(incdir)/ $(INSTALL_DATA) -p $(srcdir)/src/synth/include/synth_gates.h $(DESTDIR)$(incdir)/ +test: install.libghdl.local +install.libghdl.local: all.libghdl + $(INSTALL_DATA) -p $(srcdir)/src/synth/include/synth.h $(DESTDIR)$(incdirsuffix)/ghdl + $(INSTALL_DATA) -p $(srcdir)/src/synth/include/synth_gates.h $(DESTDIR)$(incdirsuffix)/ghdl + install.libghdl.lib: $(INSTALL_PROGRAM) -p lib/$(libghdl_name) $(DESTDIR)$(libdir)/ $(INSTALL_PROGRAM) -p libghdl.a $(DESTDIR)$(libdir)/ @@ -567,8 +572,8 @@ uninstall.vpi: test: install.vpi.local install.vpi.local: all.vpi $(MKDIR) -p $(incdirsuffix) lib - $(INSTALL_DATA) -p $(GRTSRCDIR)/vpi_user.h $(incdirsuffix) - $(INSTALL_DATA) -p $(GRTSRCDIR)/vhpi_user.h $(incdirsuffix) + $(INSTALL_DATA) -p $(GRTSRCDIR)/vpi_user.h $(incdirsuffix)/ghdl/ + $(INSTALL_DATA) -p $(GRTSRCDIR)/vhpi_user.h $(incdirsuffix)/ghdl/ ################ Libraries ############################################### diff --git a/configure b/configure index f55987961..0e4c2d756 100755 --- a/configure +++ b/configure @@ -35,7 +35,7 @@ LDFLAGS=${LDFLAGS:-} prefix=/usr/local libdirsuffix=lib libghdldirsuffix=lib/ghdl -incdirsuffix=include/ghdl +incdirsuffix=include gcc_src_dir= llvm_config= backtrace_lib= diff --git a/src/ghdldrv/ghdlvpi.adb b/src/ghdldrv/ghdlvpi.adb index ef79ee305..41e8c7820 100644 --- a/src/ghdldrv/ghdlvpi.adb +++ b/src/ghdldrv/ghdlvpi.adb @@ -38,7 +38,8 @@ package body Ghdlvpi is Ghdllocal.Set_Exec_Prefix_From_Program_Name; return Ghdllocal.Exec_Prefix.all & Directory_Separator - & Default_Paths.IncDir_Suffix; + & Default_Paths.IncDir_Suffix & Directory_Separator + & "ghdl"; end Get_Vpi_Include_Dir; -- Return the lib directory. diff --git a/testsuite/gna/issue2005/test.c b/testsuite/gna/issue2005/test.c new file mode 100644 index 000000000..d958faff7 --- /dev/null +++ b/testsuite/gna/issue2005/test.c @@ -0,0 +1,9 @@ +#include +#include + +void libghdl_init(); // dummy, just to see if finding the library/linking works + +int main() +{ + libghdl_init(); +} diff --git a/testsuite/gna/issue2005/testsuite.sh b/testsuite/gna/issue2005/testsuite.sh new file mode 100755 index 000000000..5cd784bc6 --- /dev/null +++ b/testsuite/gna/issue2005/testsuite.sh @@ -0,0 +1,21 @@ +#! /bin/sh + +. ../../testenv.sh + +set -x + +if c_compiler_is_available; then + lib=$("$GHDL" --libghdl-name) + lib=${lib#lib} # strip "lib" prefix + lib=${lib%.*} # strip .so/.dll suffix + lib_path="$("$GHDL" --libghdl-library-path)" + + libdir="$(dirname "$lib_path")" + incdir="$("$GHDL" --libghdl-include-dir)" + + $CC -I"$incdir" test.c "$("$GHDL" --libghdl-library-path)" + $CC -I"$incdir" -L"$libdir" test.c -l"$lib" + rm -f a.out +fi + +echo "Test successful" -- cgit v1.2.3