File: logind

package info (click to toggle)
daemon 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,072 kB
  • sloc: ansic: 30,432; sh: 4,310; perl: 592; makefile: 307
file content (99 lines) | stat: -rwxr-xr-x 2,216 bytes parent folder | download
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/bin/sh
#
# daemon - https://libslack.org/daemon
#
# Copyright (C) 1999-2004, 2010, 2020-2023 raf <raf@raf.org>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <https://www.gnu.org/licenses/>.
#
# 20230824 raf <raf@raf.org>
#

# Enable/disable support for systemd-logind or elogind (Linux only)

if [ x"$1" = x--enable ]
then
	# Look for libsystemd (e.g. Debian)

	src="conf/test_logind.c"
	out="conf/test_logind"

	${CC:-gcc} -o $out $src -lsystemd 2>/dev/null
	rc=$?
	rm -f $out

	if [ $rc = 0 ]
	then
		echo Configuring libsystemd

		perl -pi \
			-e 's/^# (DAEMON_LIBS \+= systemd)/$1/;' \
			macros.mk

		perl -pi \
			-e 's/^\/\* #undef (HAVE_LOGIND) \*\/$/#define $1 1/;' \
			config.h

		exit 0
	fi

	# Look for libelogind and /usr/include/elogind (e.g. Slackware)

	${CC:-gcc} -I/usr/include/elogind -o $out $src -lelogind 2>/dev/null
	rc=$?
	rm -f $out

	if [ $rc = 0 ]
	then
		echo Configuring libelogind

		perl -pi \
			-e 's{^# (DAEMON_INCDIRS \+= /usr/include/elogind)$}{$1};' \
			Makefile

		perl -pi \
			-e 's/^# (DAEMON_LIBS \+= elogind)/$1/;' \
			macros.mk

		perl -pi \
			-e 's/^\/\* #undef (HAVE_LOGIND) \*\/$/#define $1 1/;' \
			config.h

		exit 0
	fi

	echo "Failed to find libsystemd or libelogind and headers"
	echo "Please try ./configure again without --enable-logind"
	exit 1
fi

if [ x"$1" = x--disable ]
then
	perl -pi \
		-e 's{^(DAEMON_INCDIRS \+= /usr/include/elogind)$}{# $1};' \
		Makefile

	perl -pi \
		-e 's/^(DAEMON_LIBS \+= systemd)/# $1/;' \
		-e 's/^(DAEMON_LIBS \+= elogind)/# $1/;' \
		macros.mk

	perl -pi \
		-e 's/^#define (HAVE_LOGIND) 1$/\/* #undef $1 *\//;' \
		config.h

	exit 0
fi

# vi:set ts=4 sw=4: