summaryrefslogtreecommitdiff
blob: 44fc11b34ca2697e2e477f84afb518dc7e48a496 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
From a8185ad9270db54b9e0c66002e7ceebdc264af19 Mon Sep 17 00:00:00 2001
From: Sam James <sam@gentoo.org>
Date: Fri, 30 Apr 2021 04:49:26 +0100
Subject: [PATCH] Use PKG_CHECK_MODULES for ncurses, libconfig

It's not always clear how to link against ncurses
and the choices before us are:
1) use a convoluted chain of autoconf checks
2) use pkg-config (this commit)
3) guess and hardcode the most popular values

This is an iteration of a previous change [0] by a
Gentoo contributor which landed upstream.

The previous change ended up doing 3) which is fine
but doesn't always work in strange situations. Gentoo
_usually_ builds 'split tinfo' on Linux but this isn't
guaranteed.

This change now uses PKG_CHECK_MODULES which uses
pkg-config behind the scenes to query ncurses
for the correct way to build & link against it.

(We do the same thing for libconfig too.)

[0] https://github.com/roberthawdon/dfshow/pull/115
---
 Makefile.am  | 13 ++++---------
 configure.ac |  5 +++--
 2 files changed, 7 insertions(+), 11 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 048ded5..6dcaa1f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,21 +4,16 @@ dfshowconfdir = $(sysconfdir)
 dfshowdatadir = $(datadir)/dfshow
 
 AM_CFLAGS = -DSYSCONFIG=\"$(dfshowconfdir)\" -DDATADIR=\"$(dfshowdatadir)\" -D_XOPEN_SOURCE_EXTENDED -fno-common
+AM_CFLAGS += $(ncurses_CFLAGS) $(libconfig_CFLAGS)
 
-LDADD = -lm -lconfig
-
-if DARWIN
-LDADD += -lncurses
-else
-LDADD += -lncursesw
-endif
+LDADD = -lm $(ncurses_LIBS) $(libconfig_LIBS)
 
 if LINUX
-LDADD += -lacl -ltinfo
+LDADD += -lacl
 endif
 
 if HURD
-LDADD += -lacl -ltinfo
+LDADD += -lacl
 endif
 
 if SELINUX
diff --git a/configure.ac b/configure.ac
index f185b69..8acf1ab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -32,10 +32,11 @@ AC_CHECK_FUNCS(acl_get facl_get acl_set facl_set)
 
 AC_CHECK_MEMBERS([struct stat.st_author])
 AC_CHECK_HEADERS([stdio.h limits.h signal.h ctype.h wctype.h getopt.h sys/types.h sys/stat.h dirent.h fcntl.h pwd.h string.h stdlib.h unistd.h time.h sys/statvfs.h libgen.h errno.h wchar.h hurd.h math.h sys/sysmacros.h regex.h utime.h sys/xattr.h acl/libacl.h stdint.h])
-AC_CHECK_HEADERS(ncurses.h, , AC_MSG_ERROR(ncurses header (ncurses.h) not found. You may need to install an ncurses development package.))
-AC_CHECK_HEADERS(libconfig.h, , AC_MSG_ERROR(libconfig header (libconfig.h) not found. You may need to install a libconfig development package.))
 AC_CHECK_HEADERS(sys/acl.h, , AC_MSG_ERROR(libacl header (sys/acl.h) not found. You may need to install a libacl development package.))
 
+PKG_CHECK_MODULES([ncurses], [ncursesw ncurses])
+PKG_CHECK_MODULES([libconfig], [libconfig])
+
 AC_ARG_WITH([selinux], AS_HELP_STRING([--with-selinux], [Build with selinux library (default: disabled)]))
 AC_ARG_ENABLE([move-between-devices], AS_HELP_STRING([--enable-move-between-devices], [Enable moving objects between mounted devices (default: disabled)]))
 
-- 
2.31.1