]> git.ipfire.org Git - thirdparty/cups.git/blob - config-scripts/cups-startup.m4
support Upstart socket activation
[thirdparty/cups.git] / config-scripts / cups-startup.m4
1 dnl
2 dnl Launch-on-demand/startup stuff for CUPS.
3 dnl
4 dnl Copyright 2007-2015 by Apple Inc.
5 dnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
6 dnl
7 dnl These coded instructions, statements, and computer programs are the
8 dnl property of Apple Inc. and are protected by Federal copyright
9 dnl law. Distribution and use rights are outlined in the file "LICENSE.txt"
10 dnl which should have been included with this file. If this file is
11 dnl file is missing or damaged, see the license at "http://www.cups.org/".
12 dnl
13
14 ONDEMANDFLAGS=""
15 ONDEMANDLIBS=""
16 AC_SUBST(ONDEMANDFLAGS)
17 AC_SUBST(ONDEMANDLIBS)
18
19 dnl Launchd is used on OS X/Darwin...
20 AC_ARG_ENABLE(launchd, [ --disable-launchd disable launchd support])
21 LAUNCHD_DIR=""
22 AC_SUBST(LAUNCHD_DIR)
23
24 if test x$enable_launchd != xno; then
25 AC_CHECK_FUNC(launch_msg, AC_DEFINE(HAVE_LAUNCHD))
26 if test $uversion -ge 140; then
27 AC_CHECK_FUNC(launch_activate_socket, [
28 AC_DEFINE(HAVE_LAUNCHD)
29 AC_DEFINE(HAVE_LAUNCH_ACTIVATE_SOCKET)])
30 fi
31 AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
32
33 case "$uname" in
34 Darwin*)
35 # Darwin, MacOS X
36 LAUNCHD_DIR="/System/Library/LaunchDaemons"
37 # liblaunch is already part of libSystem
38 ;;
39 *)
40 # All others; this test will need to be updated
41 ;;
42 esac
43 fi
44
45 dnl Systemd is used on Linux...
46 AC_ARG_ENABLE(systemd, [ --disable-systemd disable systemd support])
47 AC_ARG_WITH(systemd, [ --with-systemd set directory for systemd service files],
48 SYSTEMD_DIR="$withval", SYSTEMD_DIR="")
49 AC_SUBST(SYSTEMD_DIR)
50
51 if test x$enable_systemd != xno; then
52 if test "x$PKGCONFIG" = x; then
53 if test x$enable_systemd = xyes; then
54 AC_MSG_ERROR(Need pkg-config to enable systemd support.)
55 fi
56 else
57 have_systemd=no
58 AC_MSG_CHECKING(for libsystemd)
59 if $PKGCONFIG --exists libsystemd; then
60 AC_MSG_RESULT(yes)
61 have_systemd=yes
62 ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd`
63 ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd`
64 elif $PKGCONFIG --exists libsystemd-daemon; then
65 AC_MSG_RESULT(yes - legacy)
66 have_systemd=yes
67 ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
68 ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd-daemon`
69
70 if $PKGCONFIG --exists libsystemd-journal; then
71 ONDEMANDFLAGS="$ONDEMANDFLAGS `$PKGCONFIG --cflags libsystemd-journal`"
72 ONDEMANDLIBS="$ONDEMANDLIBS `$PKGCONFIG --libs libsystemd-journal`"
73 fi
74 else
75 AC_MSG_RESULT(no)
76 fi
77
78 if test $have_systemd = yes; then
79 AC_DEFINE(HAVE_SYSTEMD)
80 AC_CHECK_HEADER(systemd/sd-journal.h,AC_DEFINE(HAVE_SYSTEMD_SD_JOURNAL_H))
81 if test "x$SYSTEMD_DIR" = x; then
82 SYSTEMD_DIR="`$PKGCONFIG --variable=systemdsystemunitdir systemd`"
83 fi
84 fi
85 fi
86 fi
87
88 dnl Upstart is also used on Linux (e.g., Chrome OS)
89 AC_ARG_ENABLE(upstart, [ --enable-upstart enable upstart support])
90 if test "x$enable_upstart" = "xyes"; then
91 if test "x$have_systemd" = "xyes"; then
92 AC_MSG_ERROR(Cannot support both systemd and upstart.)
93 fi
94 AC_DEFINE(HAVE_UPSTART)
95 fi
96
97 dnl Solaris uses smf
98 SMFMANIFESTDIR=""
99 AC_SUBST(SMFMANIFESTDIR)
100 AC_ARG_WITH(smfmanifestdir, [ --with-smfmanifestdir set path for Solaris SMF manifest],SMFMANIFESTDIR="$withval")
101
102 dnl Use init on other platforms...
103 AC_ARG_WITH(rcdir, [ --with-rcdir set path for rc scripts],rcdir="$withval",rcdir="")
104 AC_ARG_WITH(rclevels, [ --with-rclevels set run levels for rc scripts],rclevels="$withval",rclevels="2 3 5")
105 AC_ARG_WITH(rcstart, [ --with-rcstart set start number for rc scripts],rcstart="$withval",rcstart="")
106 AC_ARG_WITH(rcstop, [ --with-rcstop set stop number for rc scripts],rcstop="$withval",rcstop="")
107
108 if test x$rcdir = x; then
109 if test x$LAUNCHD_DIR = x -a x$SYSTEMD_DIR = x -a x$SMFMANIFESTDIR = x; then
110 # Fall back on "init", the original service startup interface...
111 if test -d /sbin/init.d; then
112 # SuSE
113 rcdir="/sbin/init.d"
114 elif test -d /etc/init.d; then
115 # Others
116 rcdir="/etc"
117 else
118 # RedHat, NetBSD
119 rcdir="/etc/rc.d"
120 fi
121 else
122 rcdir="no"
123 fi
124 fi
125
126 if test "x$rcstart" = x; then
127 case "$uname" in
128 Linux | GNU | GNU/k*BSD*)
129 # Linux
130 rcstart="81"
131 ;;
132
133 SunOS*)
134 # Solaris
135 rcstart="81"
136 ;;
137
138 *)
139 # Others
140 rcstart="99"
141 ;;
142 esac
143 fi
144
145 if test "x$rcstop" = x; then
146 case "$uname" in
147 Linux | GNU | GNU/k*BSD*)
148 # Linux
149 rcstop="36"
150 ;;
151
152 *)
153 # Others
154 rcstop="00"
155 ;;
156 esac
157 fi
158
159 INITDIR=""
160 INITDDIR=""
161 RCLEVELS="$rclevels"
162 RCSTART="$rcstart"
163 RCSTOP="$rcstop"
164 AC_SUBST(INITDIR)
165 AC_SUBST(INITDDIR)
166 AC_SUBST(RCLEVELS)
167 AC_SUBST(RCSTART)
168 AC_SUBST(RCSTOP)
169
170 if test "x$rcdir" != xno; then
171 if test "x$rclevels" = x; then
172 INITDDIR="$rcdir"
173 else
174 INITDIR="$rcdir"
175 fi
176 fi
177
178 dnl Xinetd support...
179 AC_ARG_WITH(xinetd, [ --with-xinetd set path for xinetd config files],xinetd="$withval",xinetd="")
180 XINETD=""
181 AC_SUBST(XINETD)
182
183 if test "x$xinetd" = x; then
184 if test ! -x /sbin/launchd; then
185 for dir in /etc/xinetd.d /usr/local/etc/xinetd.d; do
186 if test -d $dir; then
187 XINETD="$dir"
188 break
189 fi
190 done
191 fi
192 elif test "x$xinetd" != xno; then
193 XINETD="$xinetd"
194 fi