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