diff options
-rw-r--r-- | configure.ac | 15 | ||||
-rw-r--r-- | libgpiod.pc.in | 1 | ||||
-rw-r--r-- | tests/Makefile.am | 11 | ||||
-rw-r--r-- | tests/gpiod-test.c | 10 |
4 files changed, 31 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index 49bedf4..b93feab 100644 --- a/configure.ac +++ b/configure.ac @@ -113,6 +113,21 @@ then AC_CHECK_HEADERS([sys/signalfd.h], [], [HEADER_NOT_FOUND_TOOLS([sys/signalfd.h])]) fi +AC_ARG_ENABLE([install-tests], + [AC_HELP_STRING([--enable-install-tests], + [enable install tests [default=no]])], + [ + if test "x$enableval" = xyes + then + with_install_tests=true + with_tests=true + else + with_install_tests=false + fi + ], + [with_install_tests=false]) +AM_CONDITIONAL([WITH_INSTALL_TESTS], [test "x$with_install_tests" = xtrue]) + AC_ARG_ENABLE([tests], [AC_HELP_STRING([--enable-tests], [enable libgpiod tests [default=no]])], diff --git a/libgpiod.pc.in b/libgpiod.pc.in index 48ff113..96d1111 100644 --- a/libgpiod.pc.in +++ b/libgpiod.pc.in @@ -1,5 +1,6 @@ prefix=@prefix@ exec_prefix=@exec_prefix@ +bindir=@bindir@ libdir=@libdir@ includedir=@includedir@ diff --git a/tests/Makefile.am b/tests/Makefile.am index a9319a7..e4b1427 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -9,10 +9,19 @@ AM_CFLAGS = -I$(top_srcdir)/include/ -include $(top_builddir)/config.h AM_CFLAGS += -Wall -Wextra -g $(KMOD_CFLAGS) $(UDEV_CFLAGS) AM_LDFLAGS = -pthread -LDADD = ../src/lib/libgpiod.la $(KMOD_LIBS) $(UDEV_LIBS) +LDADD = $(top_builddir)/src/lib/libgpiod.la $(KMOD_LIBS) $(UDEV_LIBS) check_PROGRAMS = gpiod-test +if WITH_INSTALL_TESTS +bin_PROGRAMS = $(check_PROGRAMS) +TOOLS_PATH=@prefix@/bin +else +noinst_PROGRAMS = $(check_PROGRAMS) +TOOLS_PATH="./../../src/tools" +endif +AM_CFLAGS += -DTOOLS_PATH=$(TOOLS_PATH)/ + gpiod_test_SOURCES = gpiod-test.c \ gpiod-test.h \ tests-chip.c \ diff --git a/tests/gpiod-test.c b/tests/gpiod-test.c index 92d6b78..fda9d9d 100644 --- a/tests/gpiod-test.c +++ b/tests/gpiod-test.c @@ -30,6 +30,9 @@ #define NORETURN __attribute__((noreturn)) #define MALLOC __attribute__((malloc)) +#define xstr(s) str(s) +#define str(s) #s + static const unsigned int min_kern_major = 4; static const unsigned int min_kern_minor = 16; static const unsigned int min_kern_release = 0; @@ -449,12 +452,9 @@ static void gpiotool_proc_dup_fds(int in_fd, int out_fd, int err_fd) static char *gpiotool_proc_get_path(const char *tool) { - char *path, *progpath, *progdir; + char *path; - progpath = xstrdup(program_invocation_name); - progdir = dirname(progpath); - path = xappend(NULL, "%s/../../src/tools/%s", progdir, tool); - free(progpath); + path = xappend(NULL, "%s%s", xstr(TOOLS_PATH), tool); return path; } |