summaryrefslogtreecommitdiff
path: root/config-scripts/cups-startup.m4
blob: 099d46b036f9a3548f9f1fe0291d5161b7869310 (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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
dnl
dnl Launch-on-demand/startup stuff for CUPS.
dnl
dnl Copyright 2007-2017 by Apple Inc.
dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
dnl
dnl Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
dnl

ONDEMANDFLAGS=""
ONDEMANDLIBS=""
AC_SUBST(ONDEMANDFLAGS)
AC_SUBST(ONDEMANDLIBS)

dnl Launchd is used on macOS/Darwin...
AC_ARG_ENABLE(launchd, [  --disable-launchd       disable launchd support])
LAUNCHD_DIR=""
AC_SUBST(LAUNCHD_DIR)

if test x$enable_launchd != xno; then
	AC_CHECK_FUNC(launch_activate_socket, [
		AC_DEFINE(HAVE_LAUNCHD)
		AC_DEFINE(HAVE_ONDEMAND)])
	AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))

	if test "$host_os_name" = darwin; then
	        LAUNCHD_DIR="/System/Library/LaunchDaemons"
		# liblaunch is already part of libSystem
	fi
fi

dnl Systemd is used on Linux...
AC_ARG_ENABLE(systemd, [  --disable-systemd       disable systemd support])
AC_ARG_WITH(systemd, [  --with-systemd          set directory for systemd service files],
        SYSTEMD_DIR="$withval", SYSTEMD_DIR="")
AC_SUBST(SYSTEMD_DIR)

if test x$enable_systemd != xno; then
	if test "x$PKGCONFIG" = x; then
        	if test x$enable_systemd = xyes; then
	        	AC_MSG_ERROR(Need pkg-config to enable systemd support.)
                fi
        else
        	have_systemd=no
        	AC_MSG_CHECKING(for libsystemd)
                if $PKGCONFIG --exists libsystemd; then
                        AC_MSG_RESULT(yes)
                        have_systemd=yes
                        ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd`
                        ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd`
		elif $PKGCONFIG --exists libsystemd-daemon; then
			AC_MSG_RESULT(yes - legacy)
                        have_systemd=yes
			ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
			ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd-daemon`

			if $PKGCONFIG --exists libsystemd-journal; then
				ONDEMANDFLAGS="$ONDEMANDFLAGS `$PKGCONFIG --cflags libsystemd-journal`"
				ONDEMANDLIBS="$ONDEMANDLIBS `$PKGCONFIG --libs libsystemd-journal`"
			fi
                else
                        AC_MSG_RESULT(no)
                fi

		if test $have_systemd = yes; then
                        AC_DEFINE(HAVE_SYSTEMD)
                        AC_DEFINE(HAVE_ONDEMAND)
			AC_CHECK_HEADER(systemd/sd-journal.h,AC_DEFINE(HAVE_SYSTEMD_SD_JOURNAL_H))
			if test "x$SYSTEMD_DIR" = x; then
			        SYSTEMD_DIR="`$PKGCONFIG --variable=systemdsystemunitdir systemd`"
                        fi
                fi
        fi
fi

dnl Upstart is also used on Linux (e.g., Chrome OS)
AC_ARG_ENABLE(upstart, [  --enable-upstart        enable upstart support])
if test "x$enable_upstart" = "xyes"; then
	if test "x$have_systemd" = "xyes"; then
		AC_MSG_ERROR(Cannot support both systemd and upstart.)
	fi
	AC_DEFINE(HAVE_UPSTART)
	AC_DEFINE(HAVE_ONDEMAND)
fi

dnl Solaris uses smf
SMFMANIFESTDIR=""
AC_SUBST(SMFMANIFESTDIR)
AC_ARG_WITH(smfmanifestdir, [  --with-smfmanifestdir   set path for Solaris SMF manifest],SMFMANIFESTDIR="$withval")

dnl Use init on other platforms...
AC_ARG_WITH(rcdir, [  --with-rcdir            set path for rc scripts],rcdir="$withval",rcdir="")
AC_ARG_WITH(rclevels, [  --with-rclevels         set run levels for rc scripts],rclevels="$withval",rclevels="2 3 5")
AC_ARG_WITH(rcstart, [  --with-rcstart          set start number for rc scripts],rcstart="$withval",rcstart="")
AC_ARG_WITH(rcstop, [  --with-rcstop           set stop number for rc scripts],rcstop="$withval",rcstop="")

if test x$rcdir = x; then
	if test x$LAUNCHD_DIR = x -a x$SYSTEMD_DIR = x -a x$SMFMANIFESTDIR = x; then
                # Fall back on "init", the original service startup interface...
                if test -d /sbin/init.d; then
                        # SuSE
                        rcdir="/sbin/init.d"
                elif test -d /etc/init.d; then
                        # Others
                        rcdir="/etc"
                else
                        # RedHat, NetBSD
                        rcdir="/etc/rc.d"
                fi
        else
        	rcdir="no"
	fi
fi

if test "x$rcstart" = x; then
	case "$host_os_name" in
        	linux* | gnu*)
                	# Linux
                        rcstart="81"
                      	;;

		sunos*)
			# Solaris
                        rcstart="81"
			;;

                *)
                        # Others
                        rcstart="99"
                        ;;
	esac
fi

if test "x$rcstop" = x; then
	case "$host_os_name" in
        	linux* | gnu*)
                	# Linux
                        rcstop="36"
                      	;;

                *)
                        # Others
                        rcstop="00"
                        ;;
	esac
fi

INITDIR=""
INITDDIR=""
RCLEVELS="$rclevels"
RCSTART="$rcstart"
RCSTOP="$rcstop"
AC_SUBST(INITDIR)
AC_SUBST(INITDDIR)
AC_SUBST(RCLEVELS)
AC_SUBST(RCSTART)
AC_SUBST(RCSTOP)

if test "x$rcdir" != xno; then
	if test "x$rclevels" = x; then
		INITDDIR="$rcdir"
	else
		INITDIR="$rcdir"
	fi
fi

dnl Xinetd support...
AC_ARG_WITH(xinetd, [  --with-xinetd           set path for xinetd config files],xinetd="$withval",xinetd="")
XINETD=""
AC_SUBST(XINETD)

if test "x$xinetd" = x; then
	if test ! -x /sbin/launchd; then
                for dir in /etc/xinetd.d /usr/local/etc/xinetd.d; do
                        if test -d $dir; then
                                XINETD="$dir"
                                break
                        fi
                done
        fi
elif test "x$xinetd" != xno; then
	XINETD="$xinetd"
fi