xref: /aosp_15_r20/external/libcups/config-scripts/cups-startup.m4 (revision 5e7646d21f1134fb0638875d812ef646c12ab91e)
1*5e7646d2SAndroid Build Coastguard Workerdnl
2*5e7646d2SAndroid Build Coastguard Workerdnl Launch-on-demand/startup stuff for CUPS.
3*5e7646d2SAndroid Build Coastguard Workerdnl
4*5e7646d2SAndroid Build Coastguard Workerdnl Copyright 2007-2017 by Apple Inc.
5*5e7646d2SAndroid Build Coastguard Workerdnl Copyright 1997-2005 by Easy Software Products, all rights reserved.
6*5e7646d2SAndroid Build Coastguard Workerdnl
7*5e7646d2SAndroid Build Coastguard Workerdnl Licensed under Apache License v2.0.  See the file "LICENSE" for more information.
8*5e7646d2SAndroid Build Coastguard Workerdnl
9*5e7646d2SAndroid Build Coastguard Worker
10*5e7646d2SAndroid Build Coastguard WorkerONDEMANDFLAGS=""
11*5e7646d2SAndroid Build Coastguard WorkerONDEMANDLIBS=""
12*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(ONDEMANDFLAGS)
13*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(ONDEMANDLIBS)
14*5e7646d2SAndroid Build Coastguard Worker
15*5e7646d2SAndroid Build Coastguard Workerdnl Launchd is used on macOS/Darwin...
16*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_ENABLE(launchd, [  --disable-launchd       disable launchd support])
17*5e7646d2SAndroid Build Coastguard WorkerLAUNCHD_DIR=""
18*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(LAUNCHD_DIR)
19*5e7646d2SAndroid Build Coastguard Worker
20*5e7646d2SAndroid Build Coastguard Workerif test x$enable_launchd != xno; then
21*5e7646d2SAndroid Build Coastguard Worker	AC_CHECK_FUNC(launch_activate_socket, [
22*5e7646d2SAndroid Build Coastguard Worker		AC_DEFINE(HAVE_LAUNCHD)
23*5e7646d2SAndroid Build Coastguard Worker		AC_DEFINE(HAVE_ONDEMAND)])
24*5e7646d2SAndroid Build Coastguard Worker	AC_CHECK_HEADER(launch.h, AC_DEFINE(HAVE_LAUNCH_H))
25*5e7646d2SAndroid Build Coastguard Worker
26*5e7646d2SAndroid Build Coastguard Worker	if test "$host_os_name" = darwin; then
27*5e7646d2SAndroid Build Coastguard Worker	        LAUNCHD_DIR="/System/Library/LaunchDaemons"
28*5e7646d2SAndroid Build Coastguard Worker		# liblaunch is already part of libSystem
29*5e7646d2SAndroid Build Coastguard Worker	fi
30*5e7646d2SAndroid Build Coastguard Workerfi
31*5e7646d2SAndroid Build Coastguard Worker
32*5e7646d2SAndroid Build Coastguard Workerdnl Systemd is used on Linux...
33*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_ENABLE(systemd, [  --disable-systemd       disable systemd support])
34*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(systemd, [  --with-systemd          set directory for systemd service files],
35*5e7646d2SAndroid Build Coastguard Worker        SYSTEMD_DIR="$withval", SYSTEMD_DIR="")
36*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(SYSTEMD_DIR)
37*5e7646d2SAndroid Build Coastguard Worker
38*5e7646d2SAndroid Build Coastguard Workerif test x$enable_systemd != xno; then
39*5e7646d2SAndroid Build Coastguard Worker	if test "x$PKGCONFIG" = x; then
40*5e7646d2SAndroid Build Coastguard Worker        	if test x$enable_systemd = xyes; then
41*5e7646d2SAndroid Build Coastguard Worker	        	AC_MSG_ERROR(Need pkg-config to enable systemd support.)
42*5e7646d2SAndroid Build Coastguard Worker                fi
43*5e7646d2SAndroid Build Coastguard Worker        else
44*5e7646d2SAndroid Build Coastguard Worker        	have_systemd=no
45*5e7646d2SAndroid Build Coastguard Worker        	AC_MSG_CHECKING(for libsystemd)
46*5e7646d2SAndroid Build Coastguard Worker                if $PKGCONFIG --exists libsystemd; then
47*5e7646d2SAndroid Build Coastguard Worker                        AC_MSG_RESULT(yes)
48*5e7646d2SAndroid Build Coastguard Worker                        have_systemd=yes
49*5e7646d2SAndroid Build Coastguard Worker                        ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd`
50*5e7646d2SAndroid Build Coastguard Worker                        ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd`
51*5e7646d2SAndroid Build Coastguard Worker		elif $PKGCONFIG --exists libsystemd-daemon; then
52*5e7646d2SAndroid Build Coastguard Worker			AC_MSG_RESULT(yes - legacy)
53*5e7646d2SAndroid Build Coastguard Worker                        have_systemd=yes
54*5e7646d2SAndroid Build Coastguard Worker			ONDEMANDFLAGS=`$PKGCONFIG --cflags libsystemd-daemon`
55*5e7646d2SAndroid Build Coastguard Worker			ONDEMANDLIBS=`$PKGCONFIG --libs libsystemd-daemon`
56*5e7646d2SAndroid Build Coastguard Worker
57*5e7646d2SAndroid Build Coastguard Worker			if $PKGCONFIG --exists libsystemd-journal; then
58*5e7646d2SAndroid Build Coastguard Worker				ONDEMANDFLAGS="$ONDEMANDFLAGS `$PKGCONFIG --cflags libsystemd-journal`"
59*5e7646d2SAndroid Build Coastguard Worker				ONDEMANDLIBS="$ONDEMANDLIBS `$PKGCONFIG --libs libsystemd-journal`"
60*5e7646d2SAndroid Build Coastguard Worker			fi
61*5e7646d2SAndroid Build Coastguard Worker                else
62*5e7646d2SAndroid Build Coastguard Worker                        AC_MSG_RESULT(no)
63*5e7646d2SAndroid Build Coastguard Worker                fi
64*5e7646d2SAndroid Build Coastguard Worker
65*5e7646d2SAndroid Build Coastguard Worker		if test $have_systemd = yes; then
66*5e7646d2SAndroid Build Coastguard Worker                        AC_DEFINE(HAVE_SYSTEMD)
67*5e7646d2SAndroid Build Coastguard Worker                        AC_DEFINE(HAVE_ONDEMAND)
68*5e7646d2SAndroid Build Coastguard Worker			AC_CHECK_HEADER(systemd/sd-journal.h,AC_DEFINE(HAVE_SYSTEMD_SD_JOURNAL_H))
69*5e7646d2SAndroid Build Coastguard Worker			if test "x$SYSTEMD_DIR" = x; then
70*5e7646d2SAndroid Build Coastguard Worker			        SYSTEMD_DIR="`$PKGCONFIG --variable=systemdsystemunitdir systemd`"
71*5e7646d2SAndroid Build Coastguard Worker                        fi
72*5e7646d2SAndroid Build Coastguard Worker                fi
73*5e7646d2SAndroid Build Coastguard Worker        fi
74*5e7646d2SAndroid Build Coastguard Workerfi
75*5e7646d2SAndroid Build Coastguard Worker
76*5e7646d2SAndroid Build Coastguard Workerdnl Upstart is also used on Linux (e.g., Chrome OS)
77*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_ENABLE(upstart, [  --enable-upstart        enable upstart support])
78*5e7646d2SAndroid Build Coastguard Workerif test "x$enable_upstart" = "xyes"; then
79*5e7646d2SAndroid Build Coastguard Worker	if test "x$have_systemd" = "xyes"; then
80*5e7646d2SAndroid Build Coastguard Worker		AC_MSG_ERROR(Cannot support both systemd and upstart.)
81*5e7646d2SAndroid Build Coastguard Worker	fi
82*5e7646d2SAndroid Build Coastguard Worker	AC_DEFINE(HAVE_UPSTART)
83*5e7646d2SAndroid Build Coastguard Worker	AC_DEFINE(HAVE_ONDEMAND)
84*5e7646d2SAndroid Build Coastguard Workerfi
85*5e7646d2SAndroid Build Coastguard Worker
86*5e7646d2SAndroid Build Coastguard Workerdnl Solaris uses smf
87*5e7646d2SAndroid Build Coastguard WorkerSMFMANIFESTDIR=""
88*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(SMFMANIFESTDIR)
89*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(smfmanifestdir, [  --with-smfmanifestdir   set path for Solaris SMF manifest],SMFMANIFESTDIR="$withval")
90*5e7646d2SAndroid Build Coastguard Worker
91*5e7646d2SAndroid Build Coastguard Workerdnl Use init on other platforms...
92*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(rcdir, [  --with-rcdir            set path for rc scripts],rcdir="$withval",rcdir="")
93*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(rclevels, [  --with-rclevels         set run levels for rc scripts],rclevels="$withval",rclevels="2 3 5")
94*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(rcstart, [  --with-rcstart          set start number for rc scripts],rcstart="$withval",rcstart="")
95*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(rcstop, [  --with-rcstop           set stop number for rc scripts],rcstop="$withval",rcstop="")
96*5e7646d2SAndroid Build Coastguard Worker
97*5e7646d2SAndroid Build Coastguard Workerif test x$rcdir = x; then
98*5e7646d2SAndroid Build Coastguard Worker	if test x$LAUNCHD_DIR = x -a x$SYSTEMD_DIR = x -a x$SMFMANIFESTDIR = x; then
99*5e7646d2SAndroid Build Coastguard Worker                # Fall back on "init", the original service startup interface...
100*5e7646d2SAndroid Build Coastguard Worker                if test -d /sbin/init.d; then
101*5e7646d2SAndroid Build Coastguard Worker                        # SuSE
102*5e7646d2SAndroid Build Coastguard Worker                        rcdir="/sbin/init.d"
103*5e7646d2SAndroid Build Coastguard Worker                elif test -d /etc/init.d; then
104*5e7646d2SAndroid Build Coastguard Worker                        # Others
105*5e7646d2SAndroid Build Coastguard Worker                        rcdir="/etc"
106*5e7646d2SAndroid Build Coastguard Worker                else
107*5e7646d2SAndroid Build Coastguard Worker                        # RedHat, NetBSD
108*5e7646d2SAndroid Build Coastguard Worker                        rcdir="/etc/rc.d"
109*5e7646d2SAndroid Build Coastguard Worker                fi
110*5e7646d2SAndroid Build Coastguard Worker        else
111*5e7646d2SAndroid Build Coastguard Worker        	rcdir="no"
112*5e7646d2SAndroid Build Coastguard Worker	fi
113*5e7646d2SAndroid Build Coastguard Workerfi
114*5e7646d2SAndroid Build Coastguard Worker
115*5e7646d2SAndroid Build Coastguard Workerif test "x$rcstart" = x; then
116*5e7646d2SAndroid Build Coastguard Worker	case "$host_os_name" in
117*5e7646d2SAndroid Build Coastguard Worker        	linux* | gnu*)
118*5e7646d2SAndroid Build Coastguard Worker                	# Linux
119*5e7646d2SAndroid Build Coastguard Worker                        rcstart="81"
120*5e7646d2SAndroid Build Coastguard Worker                      	;;
121*5e7646d2SAndroid Build Coastguard Worker
122*5e7646d2SAndroid Build Coastguard Worker		sunos*)
123*5e7646d2SAndroid Build Coastguard Worker			# Solaris
124*5e7646d2SAndroid Build Coastguard Worker                        rcstart="81"
125*5e7646d2SAndroid Build Coastguard Worker			;;
126*5e7646d2SAndroid Build Coastguard Worker
127*5e7646d2SAndroid Build Coastguard Worker                *)
128*5e7646d2SAndroid Build Coastguard Worker                        # Others
129*5e7646d2SAndroid Build Coastguard Worker                        rcstart="99"
130*5e7646d2SAndroid Build Coastguard Worker                        ;;
131*5e7646d2SAndroid Build Coastguard Worker	esac
132*5e7646d2SAndroid Build Coastguard Workerfi
133*5e7646d2SAndroid Build Coastguard Worker
134*5e7646d2SAndroid Build Coastguard Workerif test "x$rcstop" = x; then
135*5e7646d2SAndroid Build Coastguard Worker	case "$host_os_name" in
136*5e7646d2SAndroid Build Coastguard Worker        	linux* | gnu*)
137*5e7646d2SAndroid Build Coastguard Worker                	# Linux
138*5e7646d2SAndroid Build Coastguard Worker                        rcstop="36"
139*5e7646d2SAndroid Build Coastguard Worker                      	;;
140*5e7646d2SAndroid Build Coastguard Worker
141*5e7646d2SAndroid Build Coastguard Worker                *)
142*5e7646d2SAndroid Build Coastguard Worker                        # Others
143*5e7646d2SAndroid Build Coastguard Worker                        rcstop="00"
144*5e7646d2SAndroid Build Coastguard Worker                        ;;
145*5e7646d2SAndroid Build Coastguard Worker	esac
146*5e7646d2SAndroid Build Coastguard Workerfi
147*5e7646d2SAndroid Build Coastguard Worker
148*5e7646d2SAndroid Build Coastguard WorkerINITDIR=""
149*5e7646d2SAndroid Build Coastguard WorkerINITDDIR=""
150*5e7646d2SAndroid Build Coastguard WorkerRCLEVELS="$rclevels"
151*5e7646d2SAndroid Build Coastguard WorkerRCSTART="$rcstart"
152*5e7646d2SAndroid Build Coastguard WorkerRCSTOP="$rcstop"
153*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(INITDIR)
154*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(INITDDIR)
155*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(RCLEVELS)
156*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(RCSTART)
157*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(RCSTOP)
158*5e7646d2SAndroid Build Coastguard Worker
159*5e7646d2SAndroid Build Coastguard Workerif test "x$rcdir" != xno; then
160*5e7646d2SAndroid Build Coastguard Worker	if test "x$rclevels" = x; then
161*5e7646d2SAndroid Build Coastguard Worker		INITDDIR="$rcdir"
162*5e7646d2SAndroid Build Coastguard Worker	else
163*5e7646d2SAndroid Build Coastguard Worker		INITDIR="$rcdir"
164*5e7646d2SAndroid Build Coastguard Worker	fi
165*5e7646d2SAndroid Build Coastguard Workerfi
166*5e7646d2SAndroid Build Coastguard Worker
167*5e7646d2SAndroid Build Coastguard Workerdnl Xinetd support...
168*5e7646d2SAndroid Build Coastguard WorkerAC_ARG_WITH(xinetd, [  --with-xinetd           set path for xinetd config files],xinetd="$withval",xinetd="")
169*5e7646d2SAndroid Build Coastguard WorkerXINETD=""
170*5e7646d2SAndroid Build Coastguard WorkerAC_SUBST(XINETD)
171*5e7646d2SAndroid Build Coastguard Worker
172*5e7646d2SAndroid Build Coastguard Workerif test "x$xinetd" = x; then
173*5e7646d2SAndroid Build Coastguard Worker	if test ! -x /sbin/launchd; then
174*5e7646d2SAndroid Build Coastguard Worker                for dir in /etc/xinetd.d /usr/local/etc/xinetd.d; do
175*5e7646d2SAndroid Build Coastguard Worker                        if test -d $dir; then
176*5e7646d2SAndroid Build Coastguard Worker                                XINETD="$dir"
177*5e7646d2SAndroid Build Coastguard Worker                                break
178*5e7646d2SAndroid Build Coastguard Worker                        fi
179*5e7646d2SAndroid Build Coastguard Worker                done
180*5e7646d2SAndroid Build Coastguard Worker        fi
181*5e7646d2SAndroid Build Coastguard Workerelif test "x$xinetd" != xno; then
182*5e7646d2SAndroid Build Coastguard Worker	XINETD="$xinetd"
183*5e7646d2SAndroid Build Coastguard Workerfi
184