If using systemd, CUPS can be started via socket activation or directly,
in any case it is run as user daemon, group lp. The default spool and
cache locations were moved to /tmp/cups so we don't need to set up a
tmpfs for /var/spool/cups and /var/cache/cups.

sysvinit script is installed from upstream, but untested.

Some config files are only created by cupsd on the first start and not
at install time, so we supply reasonable defaults in projectroot/ in
order to use $(call install_alternative...) on them.

Signed-off-by: Roland Hieber <r.hie...@pengutronix.de>
---

Notes:
    changes in v1 -> v2:
     - move CUPS_BBINIT_LINK into separate .in file
     - correct license specification
     - improve scripting languages integration (via configure.ac patch)
     - change hard php-cli dependency into soft dependency of php-cli or php-cgi
     - break long lines in cups.make
     - targetinstall: install links to cupsaccept into /sbin
     - targetinstall: use user/group names instead of IDs
     - targetinstall: create config directories with correct permissions
     - targetinstall: fix permissions for readonly config files

 ...llow-explicit-disabling-of-Java-PHP-Perl-.patch |  92 ++++++++
 ...-remove-leftover-check-for-empty-CUPS_PHP.patch |  29 +++
 ...e-make-interpreter-detection-more-verbose.patch |  88 ++++++++
 patches/cups-2.2.4/autogen.sh                      |   7 +
 patches/cups-2.2.4/series                          |   6 +
 projectroot/etc/cups/classes.conf                  |   1 +
 projectroot/etc/cups/client.conf                   |   2 +
 projectroot/etc/cups/cups-files.conf               |  22 ++
 projectroot/etc/cups/mailto.conf                   |   1 +
 projectroot/etc/cups/ppd/.createdirectory          |   0
 projectroot/etc/cups/printers.conf                 |   1 +
 projectroot/etc/cups/ssl/.createdirectory          |   0
 projectroot/etc/printcap                           |   3 +
 projectroot/usr/lib/systemd/system/cups.service    |  15 ++
 projectroot/usr/lib/systemd/system/cups.socket     |  14 ++
 projectroot/usr/lib/tmpfiles.d/cups.conf           |   6 +
 rules/cups-bbinit.in                               |   8 +
 rules/cups.in                                      | 140 ++++++++++++
 rules/cups.make                                    | 243 +++++++++++++++++++++
 19 files changed, 678 insertions(+)
 create mode 100644 
patches/cups-2.2.4/0001-configure-allow-explicit-disabling-of-Java-PHP-Perl-.patch
 create mode 100644 
patches/cups-2.2.4/0002-configure-remove-leftover-check-for-empty-CUPS_PHP.patch
 create mode 100644 
patches/cups-2.2.4/0003-configure-make-interpreter-detection-more-verbose.patch
 create mode 100755 patches/cups-2.2.4/autogen.sh
 create mode 100644 patches/cups-2.2.4/series
 create mode 100644 projectroot/etc/cups/classes.conf
 create mode 100644 projectroot/etc/cups/client.conf
 create mode 100644 projectroot/etc/cups/cups-files.conf
 create mode 100644 projectroot/etc/cups/mailto.conf
 create mode 100644 projectroot/etc/cups/ppd/.createdirectory
 create mode 100644 projectroot/etc/cups/printers.conf
 create mode 100644 projectroot/etc/cups/ssl/.createdirectory
 create mode 100644 projectroot/etc/printcap
 create mode 100644 projectroot/usr/lib/systemd/system/cups.service
 create mode 100644 projectroot/usr/lib/systemd/system/cups.socket
 create mode 100644 projectroot/usr/lib/tmpfiles.d/cups.conf
 create mode 100644 rules/cups-bbinit.in
 create mode 100644 rules/cups.in
 create mode 100644 rules/cups.make

diff --git 
a/patches/cups-2.2.4/0001-configure-allow-explicit-disabling-of-Java-PHP-Perl-.patch
 
b/patches/cups-2.2.4/0001-configure-allow-explicit-disabling-of-Java-PHP-Perl-.patch
new file mode 100644
index 000000000..f110f5aaa
--- /dev/null
+++ 
b/patches/cups-2.2.4/0001-configure-allow-explicit-disabling-of-Java-PHP-Perl-.patch
@@ -0,0 +1,92 @@
+From: Roland Hieber <r.hie...@pengutronix.de>
+Date: Mon, 25 Sep 2017 15:00:16 +0200
+Subject: [PATCH] configure: allow explicit disabling of Java/PHP/Perl/Python
+ support
+
+Currently, when configure is called with --with-java or --with-java=,
+auto-detection is performed. When called with --without-java, HAVE_JAVA
+is still being defined. This is unfortunate when cross-compiling for
+embedded systems, we would end up with Java on the host being
+auto-detected (which is not what we have on the target), or with a wrong
+HAVE_JAVA define. We need a way to explicitely disable scripting support
+for all supported languages.
+
+Forwarded: https://github.com/apple/cups/pull/5122
+Signed-off-by: Roland Hieber <r.hie...@pengutronix.de>
+---
+ config-scripts/cups-scripting.m4 | 24 ++++++++++++++++--------
+ 1 file changed, 16 insertions(+), 8 deletions(-)
+
+diff --git a/config-scripts/cups-scripting.m4 
b/config-scripts/cups-scripting.m4
+index bff3e9a0505c..137c3be72cb0 100644
+--- a/config-scripts/cups-scripting.m4
++++ b/config-scripts/cups-scripting.m4
+@@ -14,11 +14,13 @@ dnl
+ dnl Do we have Java?
+ AC_ARG_WITH(java, [  --with-java             set Java interpreter for web 
interfaces ],
+       CUPS_JAVA="$withval",
+-      CUPS_JAVA="")
++      CUPS_JAVA="auto")
+ 
+-if test "x$CUPS_JAVA" = x; then
++if test "x$CUPS_JAVA" = xauto; then
+       AC_PATH_PROG(JAVA,java)
+       CUPS_JAVA="$JAVA"
++elif test "x$CUPS_JAVA" = xno; then
++      CUPS_JAVA=""
+ fi
+ 
+ AC_DEFINE_UNQUOTED(CUPS_JAVA, "$CUPS_JAVA")
+@@ -30,11 +32,13 @@ fi
+ dnl Do we have Perl?
+ AC_ARG_WITH(perl, [  --with-perl             set Perl interpreter for web 
interfaces ],
+       CUPS_PERL="$withval",
+-      CUPS_PERL="")
++      CUPS_PERL="auto")
+ 
+-if test "x$CUPS_PERL" = x; then
++if test "x$CUPS_PERL" = xauto; then
+       AC_PATH_PROG(PERL,perl)
+       CUPS_PERL="$PERL"
++elif test "x$CUPS_PERL" = xno; then
++      CUPS_PERL=""
+ fi
+ 
+ AC_DEFINE_UNQUOTED(CUPS_PERL, "$CUPS_PERL")
+@@ -46,9 +50,9 @@ fi
+ dnl Do we have PHP?
+ AC_ARG_WITH(php, [  --with-php              set PHP interpreter for web 
interfaces ],
+       CUPS_PHP="$withval",
+-      CUPS_PHP="")
++      CUPS_PHP="auto")
+ 
+-if test "x$CUPS_PHP" = x; then
++if test "x$CUPS_PHP" = xauto; then
+       AC_PATH_PROG(PHPCGI,php-cgi)
+       if test "x$PHPCGI" = x; then
+               AC_PATH_PROG(PHP,php)
+@@ -56,6 +60,8 @@ if test "x$CUPS_PHP" = x; then
+       else
+               CUPS_PHP="$PHPCGI"
+       fi
++elif test "x$CUPS_PHP" = xno; then
++      CUPS_PHP=""
+ fi
+ 
+ AC_DEFINE_UNQUOTED(CUPS_PHP, "$CUPS_PHP")
+@@ -69,11 +75,13 @@ fi
+ dnl Do we have Python?
+ AC_ARG_WITH(python, [  --with-python           set Python interpreter for web 
interfaces ],
+       CUPS_PYTHON="$withval",
+-      CUPS_PYTHON="")
++      CUPS_PYTHON="auto")
+ 
+-if test "x$CUPS_PYTHON" = x; then
++if test "x$CUPS_PYTHON" = xauto; then
+       AC_PATH_PROG(PYTHON,python)
+       CUPS_PYTHON="$PYTHON"
++elif test "x$CUPS_PYTHON" = xno; then
++      CUPS_PYTHON=""
+ fi
+ 
+ AC_DEFINE_UNQUOTED(CUPS_PYTHON, "$CUPS_PYTHON")
diff --git 
a/patches/cups-2.2.4/0002-configure-remove-leftover-check-for-empty-CUPS_PHP.patch
 
b/patches/cups-2.2.4/0002-configure-remove-leftover-check-for-empty-CUPS_PHP.patch
new file mode 100644
index 000000000..b0b59a78f
--- /dev/null
+++ 
b/patches/cups-2.2.4/0002-configure-remove-leftover-check-for-empty-CUPS_PHP.patch
@@ -0,0 +1,29 @@
+From: Roland Hieber <r.hie...@pengutronix.de>
+Date: Mon, 25 Sep 2017 17:04:49 +0200
+Subject: [PATCH] configure: remove leftover check for empty CUPS_PHP
+
+After the respective AC_DEFINE_UNQUOTED(CUPS_PHP) call, assigning
+anything to CUPS_PHP is a no-op. Remove it so the surrounding test looks
+like the other tests in the file.
+
+Forwarded: https://github.com/apple/cups/pull/5122
+Signed-off-by: Roland Hieber <r.hie...@pengutronix.de>
+---
+ config-scripts/cups-scripting.m4 | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/config-scripts/cups-scripting.m4 
b/config-scripts/cups-scripting.m4
+index 137c3be72cb0..f73d5310a3ae 100644
+--- a/config-scripts/cups-scripting.m4
++++ b/config-scripts/cups-scripting.m4
+@@ -66,9 +66,7 @@ fi
+ 
+ AC_DEFINE_UNQUOTED(CUPS_PHP, "$CUPS_PHP")
+ 
+-if test "x$CUPS_PHP" = x; then
+-      CUPS_PHP="no"
+-else
++if test "x$CUPS_PHP" != x; then
+       AC_DEFINE(HAVE_PHP)
+ fi
+ 
diff --git 
a/patches/cups-2.2.4/0003-configure-make-interpreter-detection-more-verbose.patch
 
b/patches/cups-2.2.4/0003-configure-make-interpreter-detection-more-verbose.patch
new file mode 100644
index 000000000..a1bfc3ade
--- /dev/null
+++ 
b/patches/cups-2.2.4/0003-configure-make-interpreter-detection-more-verbose.patch
@@ -0,0 +1,88 @@
+From: Roland Hieber <r.hie...@pengutronix.de>
+Date: Mon, 25 Sep 2017 16:17:03 +0200
+Subject: [PATCH] configure: make interpreter detection more verbose
+
+Forwarded: https://github.com/apple/cups/pull/5122
+Signed-off-by: Roland Hieber <r.hie...@pengutronix.de>
+---
+ config-scripts/cups-scripting.m4 | 16 ++++++++++++++++
+ 1 file changed, 16 insertions(+)
+
+diff --git a/config-scripts/cups-scripting.m4 
b/config-scripts/cups-scripting.m4
+index f73d5310a3ae..4b1b6a80c5ac 100644
+--- a/config-scripts/cups-scripting.m4
++++ b/config-scripts/cups-scripting.m4
+@@ -16,6 +16,7 @@ AC_ARG_WITH(java, [  --with-java             set Java 
interpreter for web interf
+       CUPS_JAVA="$withval",
+       CUPS_JAVA="auto")
+ 
++AC_MSG_CHECKING([for Java interpreter])
+ if test "x$CUPS_JAVA" = xauto; then
+       AC_PATH_PROG(JAVA,java)
+       CUPS_JAVA="$JAVA"
+@@ -26,7 +27,10 @@ fi
+ AC_DEFINE_UNQUOTED(CUPS_JAVA, "$CUPS_JAVA")
+ 
+ if test "x$CUPS_JAVA" != x; then
++      AC_MSG_RESULT([$CUPS_JAVA])
+       AC_DEFINE(HAVE_JAVA)
++else
++      AC_MSG_RESULT([none])
+ fi
+ 
+ dnl Do we have Perl?
+@@ -34,6 +38,7 @@ AC_ARG_WITH(perl, [  --with-perl             set Perl 
interpreter for web interf
+       CUPS_PERL="$withval",
+       CUPS_PERL="auto")
+ 
++AC_MSG_CHECKING([for Perl interpreter])
+ if test "x$CUPS_PERL" = xauto; then
+       AC_PATH_PROG(PERL,perl)
+       CUPS_PERL="$PERL"
+@@ -44,7 +49,10 @@ fi
+ AC_DEFINE_UNQUOTED(CUPS_PERL, "$CUPS_PERL")
+ 
+ if test "x$CUPS_PERL" != x; then
++      AC_MSG_RESULT([$CUPS_PERL])
+       AC_DEFINE(HAVE_PERL)
++else
++      AC_MSG_RESULT([none])
+ fi
+ 
+ dnl Do we have PHP?
+@@ -52,6 +60,7 @@ AC_ARG_WITH(php, [  --with-php              set PHP 
interpreter for web interfac
+       CUPS_PHP="$withval",
+       CUPS_PHP="auto")
+ 
++AC_MSG_CHECKING([for PHP interpreter])
+ if test "x$CUPS_PHP" = xauto; then
+       AC_PATH_PROG(PHPCGI,php-cgi)
+       if test "x$PHPCGI" = x; then
+@@ -67,7 +76,10 @@ fi
+ AC_DEFINE_UNQUOTED(CUPS_PHP, "$CUPS_PHP")
+ 
+ if test "x$CUPS_PHP" != x; then
++      AC_MSG_RESULT([$CUPS_PHP])
+       AC_DEFINE(HAVE_PHP)
++else
++      AC_MSG_RESULT([none])
+ fi
+ 
+ dnl Do we have Python?
+@@ -75,6 +87,7 @@ AC_ARG_WITH(python, [  --with-python           set Python 
interpreter for web in
+       CUPS_PYTHON="$withval",
+       CUPS_PYTHON="auto")
+ 
++AC_MSG_CHECKING([for Python interpreter])
+ if test "x$CUPS_PYTHON" = xauto; then
+       AC_PATH_PROG(PYTHON,python)
+       CUPS_PYTHON="$PYTHON"
+@@ -85,5 +98,8 @@ fi
+ AC_DEFINE_UNQUOTED(CUPS_PYTHON, "$CUPS_PYTHON")
+ 
+ if test "x$CUPS_PYTHON" != x; then
++      AC_MSG_RESULT([$CUPS_PYTHON])
+       AC_DEFINE(HAVE_PYTHON)
++else
++      AC_MSG_RESULT([none])
+ fi
diff --git a/patches/cups-2.2.4/autogen.sh b/patches/cups-2.2.4/autogen.sh
new file mode 100755
index 000000000..1c70286be
--- /dev/null
+++ b/patches/cups-2.2.4/autogen.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+autoconf \
+        --force \
+        --warnings=cross \
+        --warnings=syntax \
+        --warnings=obsolete \
+        --warnings=unsupported
diff --git a/patches/cups-2.2.4/series b/patches/cups-2.2.4/series
new file mode 100644
index 000000000..8ed7533f1
--- /dev/null
+++ b/patches/cups-2.2.4/series
@@ -0,0 +1,6 @@
+# generated by git-ptx-patches
+#tag:base --start-number 1
+0001-configure-allow-explicit-disabling-of-Java-PHP-Perl-.patch
+0002-configure-remove-leftover-check-for-empty-CUPS_PHP.patch
+0003-configure-make-interpreter-detection-more-verbose.patch
+# c7ecb5f5cc92f09bc09802d57507070b  - git-ptx-patches magic
diff --git a/projectroot/etc/cups/classes.conf 
b/projectroot/etc/cups/classes.conf
new file mode 100644
index 000000000..dea737751
--- /dev/null
+++ b/projectroot/etc/cups/classes.conf
@@ -0,0 +1 @@
+# classes.conf - class configuration file for cups
diff --git a/projectroot/etc/cups/client.conf b/projectroot/etc/cups/client.conf
new file mode 100644
index 000000000..f8f0b6832
--- /dev/null
+++ b/projectroot/etc/cups/client.conf
@@ -0,0 +1,2 @@
+# CUPS client configuration
+ServerName localhost
diff --git a/projectroot/etc/cups/cups-files.conf 
b/projectroot/etc/cups/cups-files.conf
new file mode 100644
index 000000000..2cc2d5a5b
--- /dev/null
+++ b/projectroot/etc/cups/cups-files.conf
@@ -0,0 +1,22 @@
+# File/directory/user/group configuration file for the CUPS scheduler.
+User daemon
+Group lp
+SystemGroup root
+
+AccessLog /var/log/cups/access_log
+ErrorLog /var/log/cups/error_log
+PageLog /var/log/cups/page_log
+
+CacheDir /tmp/cups/cache
+DataDir /usr/share/cups
+DocumentRoot /usr/share/doc/cups
+RequestRoot /tmp/cups/spool
+ServerBin /usr/lib/cups
+ServerRoot /etc/cups
+StateDir /var/run/cups
+
+Printcap /etc/printcap
+PrintcapFormat bsd
+
+# SSL/TLS keychain for the scheduler...
+#ServerKeychain ssl
diff --git a/projectroot/etc/cups/mailto.conf b/projectroot/etc/cups/mailto.conf
new file mode 100644
index 000000000..4502adaee
--- /dev/null
+++ b/projectroot/etc/cups/mailto.conf
@@ -0,0 +1 @@
+# mailto.conf - configuration file for cups email notifier
diff --git a/projectroot/etc/cups/ppd/.createdirectory 
b/projectroot/etc/cups/ppd/.createdirectory
new file mode 100644
index 000000000..e69de29bb
diff --git a/projectroot/etc/cups/printers.conf 
b/projectroot/etc/cups/printers.conf
new file mode 100644
index 000000000..bf9879904
--- /dev/null
+++ b/projectroot/etc/cups/printers.conf
@@ -0,0 +1 @@
+# printers.conf - printer configuration file for cups
diff --git a/projectroot/etc/cups/ssl/.createdirectory 
b/projectroot/etc/cups/ssl/.createdirectory
new file mode 100644
index 000000000..e69de29bb
diff --git a/projectroot/etc/printcap b/projectroot/etc/printcap
new file mode 100644
index 000000000..e74f358e1
--- /dev/null
+++ b/projectroot/etc/printcap
@@ -0,0 +1,3 @@
+# This file was automatically generated by cupsd(8) from the
+# /etc/cups/printers.conf file.  All changes to this file
+# will be lost.
diff --git a/projectroot/usr/lib/systemd/system/cups.service 
b/projectroot/usr/lib/systemd/system/cups.service
new file mode 100644
index 000000000..ff94f69d2
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/cups.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=CUPS Scheduler service
+Documentation=man:cupsd(8)
+Requires=systemd-tmpfiles-setup.service
+Requires=cups.socket
+
+[Service]
+User=daemon
+Group=lp
+ExecStart=/usr/sbin/cupsd -l -c /etc/cups/cupsd.conf -s 
/etc/cups/cups-files.conf
+Type=simple
+
+[Install]
+Also=cups.socket
+WantedBy=printer.target
diff --git a/projectroot/usr/lib/systemd/system/cups.socket 
b/projectroot/usr/lib/systemd/system/cups.socket
new file mode 100644
index 000000000..de9f43b6b
--- /dev/null
+++ b/projectroot/usr/lib/systemd/system/cups.socket
@@ -0,0 +1,14 @@
+[Unit]
+Description=CUPS Scheduler socket
+PartOf=cups.service
+
+[Socket]
+ListenStream=/run/cups.sock
+ListenStream=[::1]:631
+ListenStream=127.0.0.1:631
+BindIPv6Only=No
+SocketUser=daemon
+SocketGroup=lp
+
+[Install]
+WantedBy=sockets.target
diff --git a/projectroot/usr/lib/tmpfiles.d/cups.conf 
b/projectroot/usr/lib/tmpfiles.d/cups.conf
new file mode 100644
index 000000000..c000cf255
--- /dev/null
+++ b/projectroot/usr/lib/tmpfiles.d/cups.conf
@@ -0,0 +1,6 @@
+#Type  Path                    Mode    UID     GID     Age     Argument
+d      /var/log/cups           750     daemon  lp      -
+d      /tmp/cups/cache/        750     daemon  lp      -
+d      /tmp/cups/spool/        750     daemon  lp      -
+d      /tmp/cups/spool/tmp/    750     daemon  lp      -
+d      /var/run/cups           750     daemon  lp      -
diff --git a/rules/cups-bbinit.in b/rules/cups-bbinit.in
new file mode 100644
index 000000000..86b6f649a
--- /dev/null
+++ b/rules/cups-bbinit.in
@@ -0,0 +1,8 @@
+## SECTION=initmethod_bbinit
+
+config CUPS_BBINIT_LINK
+        string "cups"
+        depends on CUPS_STARTSCRIPT
+        default "S90cups"
+
+# vim: ft=kconfig ts=8 noet tw=80
diff --git a/rules/cups.in b/rules/cups.in
new file mode 100644
index 000000000..e77149920
--- /dev/null
+++ b/rules/cups.in
@@ -0,0 +1,140 @@
+## SECTION=applications
+
+menuconfig CUPS
+       tristate
+       prompt "cups                          "
+
+       select ROOTFS_VAR_LOG
+       select ROOTFS_VAR_RUN
+       select LIBC_M
+       select LIBC_CRYPT
+       select ZLIB
+
+       select LIBC_PTHREAD             if CUPS_THREADING
+       select SYSTEMD                  if CUPS_SYSTEMD_UNIT
+       select LIBPAPER                 if CUPS_LIBPAPER
+       select LIBUSB                   if CUPS_LIBUSB
+       select DBUS                     if CUPS_DBUS
+       select GNUTLS                   if CUPS_SSL
+       select AVAHI                    if CUPS_AVAHI
+       select AVAHI_LIBAVAHI_CLIENT    if CUPS_AVAHI
+       select ORACLE_JAVA7_JRE         if CUPS_JAVA
+       select PERL                     if CUPS_PERL
+       select PHP5                     if CUPS_PHP
+       select PYTHON                   if CUPS_PYTHON
+
+       help
+         CUPS is the standards-based, open source printing system. It uses the
+         Internet Printing Protocol (IPP) to support printing to local and
+         network printers.
+
+if CUPS
+
+comment "--- CUPS Features ---"
+
+config CUPS_THREADING
+       bool "enable multithreading"
+       default y
+       help
+          Enable multi-threading support
+
+config CUPS_WEBINTERFACE
+       bool "enable web interface"
+       help
+          Enable CUPS printer management via HTTP(S). Only required for hosts
+          which should act as a printing server.
+
+          If you overwrite the config files for CUPS, be sure to have
+          "WebInterface Yes" in your projectroot/etc/cups/cupsd.conf.
+
+config CUPS_SYSTEMD_UNIT
+       bool "install systemd unit file"
+       default y
+       depends on INITMETHOD_SYSTEMD
+       help
+         Installs a systemd service file so that CUPS can be started as a
+         systemd service.
+
+config CUPS_STARTSCRIPT
+       bool "install init.d script"
+       depends on INITMETHOD_BBINIT
+       help
+         Install /etc/init.d/cups
+
+config CUPS_TEST_TOOLS
+       bool "install cupstest* tools"
+       default n
+       help
+         Install cupstestdsc and cupstestppd on the target.
+
+comment "--- External Libraries ---"
+
+config CUPS_LIBPAPER
+       bool "libpaper support"
+       help
+         Build with support for libpaper's collection of paper sizes
+
+config CUPS_LIBUSB
+       bool "libusb support"
+       help
+         Build with libusb support. This is needed for the usb backend in order
+         to use USB printers.
+
+config CUPS_DBUS
+       bool "DBus support"
+       help
+         Builds CUPS with support for sending event notifications over DBUS
+
+config CUPS_SSL
+       bool "enable TLS support"
+       help
+         Enables SSL support over IPP and HTTP, also for the web interface.
+
+config CUPS_AVAHI
+       bool "enable Avahi support"
+       help
+         Enables support for discovery of network printers over Avahi/zeroconf.
+
+config CUPS_JAVA
+       bool "enable Java support for web interface"
+       depends on CUPS_WEBINTERFACE
+
+config CUPS_PERL
+       bool "enable Perl support for web interface"
+       depends on CUPS_WEBINTERFACE
+
+config CUPS_PHP
+       bool "enable PHP support for web interface"
+       depends on CUPS_WEBINTERFACE
+
+if CUPS_PHP && !PHP5_SAPI_CLI && !PHP5_SAPI_CGI
+       comment "Please also select PHP5_SAPI_CLI or PHP5_SAPI_CGI!"
+endif
+
+config CUPS_PYTHON
+       bool "enable Python support for web interface"
+       depends on CUPS_WEBINTERFACE
+
+comment "--- Debugging ---"
+
+config CUPS_DEBUG
+       bool "enable debug build"
+       default n
+       help
+         Pay attention: this will slow down CUPS drastically and increases the
+         memory footprint. Don't enable this on a production system!
+
+config CUPS_DEBUG_PRINTF
+       bool "enable debug output"
+       help
+         Enable much more debug messages. These messages are logged into a
+         separate file, the output is controlled over the following environment
+         variables:
+
+         - CUPS_DEBUG_LOG: contains the file name to write the messages to
+         - CUPS_DEBUG_LEVEL: defines the loglevel (0...9, with 9 very noisy)
+         - CUPS_DEBUG_FILTER: defines a regular expression to filter out
+           unwanted debug messages.
+
+endif
+# vim: ft=kconfig ts=8 noet tw=80
diff --git a/rules/cups.make b/rules/cups.make
new file mode 100644
index 000000000..e7c9bba12
--- /dev/null
+++ b/rules/cups.make
@@ -0,0 +1,243 @@
+# -*-makefile-*-
+#
+# Copyright (C) 2017 by Roland Hieber <r.hie...@pengutronix.de>
+#
+# See CREDITS for details about who has contributed to this project.
+#
+# For further information about the PTXdist project and license conditions
+# see the README file.
+#
+
+#
+# We provide this package
+#
+PACKAGES-$(PTXCONF_CUPS) += cups
+
+#
+# Paths and names
+#
+CUPS_VERSION   := 2.2.4
+CUPS           := cups-$(CUPS_VERSION)
+CUPS_MD5       := d26e5a0a574a69fe1d01079b2931fc49
+CUPS_SUFFIX    := tar.gz
+CUPS_URL       := 
https://github.com/apple/cups/releases/download/v$(CUPS_VERSION)/$(CUPS)-source.$(CUPS_SUFFIX)
+CUPS_SOURCE    := $(SRCDIR)/$(CUPS)-source.$(CUPS_SUFFIX)
+CUPS_DIR       := $(BUILDDIR)/cups-$(CUPS_VERSION)
+CUPS_LICENSE   := LGPLv2 AND GPLv2
+
+# ----------------------------------------------------------------------------
+# Prepare
+# ----------------------------------------------------------------------------
+
+CUPS_CONF_ENV  := \
+       $(CROSS_ENV) \
+       DSTROOT=$(PKGDIR)/$(CUPS)
+
+#
+# autoconf
+#
+# The --with-* options are only used to specify strings, --without-* does
+# mostly nothing. So we're omitting them here.
+#
+# We have to set --exec-prefix and --libdir, otherwise the libs end up in
+# ${prefix}/lib64 due to broken autoconf magic, which is not what we want.
+#
+# --enable-mallinfo is currently broken, see
+#  https://github.com/apple/cups/issues/5051
+#
+# libtool support is unsupported upstream. Don't enable it, it will break
+# things, until https://github.com/apple/cups/pull/5062 is merged.
+#
+# --disable-dnssd only refers to Apple's mDNSResponder, not Avahi.
+#
+# Java, PHP, Perl and Python support for the webinterface is only a runtime
+# option, there are no real bindings for it except calling the interpreters.
+#
+CUPS_CONF_TOOL := autoconf
+CUPS_CONF_OPT  := \
+       $(CROSS_AUTOCONF_USR) \
+       --exec-prefix=/usr/ \
+       --libdir=/usr/lib/ \
+       --disable-static \
+       --disable-mallinfo \
+       --$(call ptx/endis,PTXCONF_CUPS_LIBPAPER)-libpaper \
+       --$(call ptx/endis,PTXCONF_CUPS_LIBUSB)-libusb \
+       --disable-tcp-wrappers \
+       --disable-acl \
+       --$(call ptx/endis,PTXCONF_CUPS_DBUS)-dbus \
+       --enable-shared \
+       --disable-libtool-unsupported \
+       --$(call ptx/endis,PTXCONF_CUPS_DEBUG)-debug \
+       --$(call ptx/endis,PTXCONF_CUPS_DEBUG)-debug-guards \
+       --$(call ptx/endis,PTXCONF_CUPS_DEBUG_PRINTF)-debug-printfs \
+       --disable-unit-tests \
+       --$(call ptx/endis,PTXCONF_TARGET_HARDEN_RELRO)-relro \
+       --disable-gssapi \
+       --$(call ptx/endis,PTXCONF_CUPS_THREADING)-threads \
+       --$(call ptx/endis,PTXCONF_CUPS_SSL)-ssl \
+       --disable-cdsassl \
+       --$(call ptx/endis,PTXCONF_CUPS_SSL)-gnutls \
+       --disable-pam \
+       $(GLOBAL_LARGE_FILE_OPTION) \
+       --$(call ptx/endis,PTXCONF_CUPS_AVAHI)-avahi \
+       --disable-dnssd \
+       --disable-launchd \
+       --$(call ptx/endis,PTXCONF_CUPS_SYSTEMD_UNIT)-systemd \
+       --disable-upstart
+
+# Default config file settings (probably overwritten via projectroot 
anyways...)
+CUPS_CONF_OPT  += \
+       --disable-page-logging \
+       --disable-browsing \
+       --disable-default-shared \
+       --disable-raw-printing \
+       --$(call ptx/endis,PTXCONF_CUPS_WEBINTERFACE)-webif \
+       --with-components=all \
+       --with-cachedir=/var/cache \
+       --with-logdir=/var/log \
+       --with-rundir=/run \
+       --with-rcdir=/etc \
+       --with-languages=none \
+       --with-cups-user=daemon \
+       --with-cups-group=lp
+
+# scripting integrations
+CUPS_PHP_PATH  := \
+       $(if PTXCONF_PHP5_SAPI_CLI,/usr/bin/php5, \
+       $(if PTXCONF_PHP5_SAPI_CGI,/usr/bin/php-cgi))
+
+CUPS_CONF_OPT  += \
+       $(call 
ptx/ifdef,PTXCONF_CUPS_JAVA,--with-java=/usr/bin/java,--without-java) \
+       $(call 
ptx/ifdef,PTXCONF_CUPS_PERL,--with-perl=/usr/bin/perl,--without-perl) \
+       $(call 
ptx/ifdef,PTXCONF_CUPS_PHP,--with-php=$(CUPS_PHP_PATH),--without-php) \
+       $(call 
ptx/ifdef,PTXCONF_CUPS_PYTHON,--with-python=/usr/bin/python,--without-python)
+
+# ----------------------------------------------------------------------------
+# Install
+# ----------------------------------------------------------------------------
+
+CUPS_MAKE_ENV  := \
+       DSTROOT=$(PKGDIR)/$(CUPS)
+
+# ----------------------------------------------------------------------------
+# Target-Install
+# ----------------------------------------------------------------------------
+
+# CUPS drops many files into its PKGDIR, but instead of patching the build
+# system, be explicitly picky about what to install.
+
+$(STATEDIR)/cups.targetinstall:
+       @$(call targetinfo)
+
+       @$(call install_init, cups)
+       @$(call install_fixup, cups,PRIORITY,optional)
+       @$(call install_fixup, cups,SECTION,base)
+       @$(call install_fixup, cups,AUTHOR,"Roland Hieber 
<r.hie...@pengutronix.de>")
+       @$(call install_fixup, cups,DESCRIPTION,missing)
+
+# ----- config files, install as daemon:lp
+       @$(call install_copy, cups, daemon, lp, 750, /etc/cups)
+       @$(call install_alternative, cups, daemon, lp, 0640, 
/etc/cups/cups-files.conf)
+       @$(call install_alternative, cups, daemon, lp, 0640, 
/etc/cups/cupsd.conf)
+       @$(call install_alternative, cups, daemon, lp, 0600, 
/etc/cups/classes.conf)
+       @$(call install_alternative, cups, daemon, lp, 0600, 
/etc/cups/client.conf)
+       @$(call install_alternative, cups, daemon, lp, 0640, 
/etc/cups/mailto.conf)
+       @$(call install_copy, cups, daemon, lp, 0750, /etc/cups/ppd/)
+       @$(call install_alternative_tree, cups, daemon, lp,  /etc/cups/ppd/)
+       @$(call install_alternative, cups, daemon, lp, 0600, 
/etc/cups/printers.conf)
+       @$(call install_alternative, cups, daemon, lp, 0640, 
/etc/cups/snmp.conf)
+       @$(call install_alternative, cups, daemon, lp, 0640, /etc/printcap)
+       @$(call install_alternative, cups, root, root, 0644, 
/usr/share/cups/mime/mime.convs)
+       @$(call install_alternative, cups, root, root, 0644, 
/usr/share/cups/mime/mime.types)
+
+ifdef PTXCONF_CUPS_SSL
+       @$(call install_copy, cups, daemon, lp, /etc/cups/ssl/)
+       @$(call install_alternative_tree, cups, daemon, lp, /etc/cups/ssl/)
+endif
+
+ifdef PTXCONF_CUPS_DBUS
+       @$(call install_alternative, cups, root, root, 0644, 
/etc/dbus-1/system.d/cups.conf)
+endif
+
+# ----- libraries
+       @$(call install_lib, cups, root, root, 0755, libcups)
+       @$(call install_lib, cups, root, root, 0755, libcupsimage)
+       @$(call install_lib, cups, root, root, 0755, libcupsmime)
+       @$(call install_lib, cups, root, root, 0755, libcupsppdc)
+
+# ----- user and system binaries, with the correct access rights
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cancel)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cups-config)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/ipptool)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lp)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpoptions)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpq)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpr)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lprm)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/lpstat)
+
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsaccept)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsaddsmb)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsctl)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsd)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/cupsfilter)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpadmin)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpc)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpinfo)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/sbin/lpmove)
+
+       @$(call install_link, cups, cupsaccept, /usr/sbin/accept)
+       @$(call install_link, cups, cupsaccept, /usr/sbin/cupsdisable)
+       @$(call install_link, cups, cupsaccept, /usr/sbin/cupsenable)
+       @$(call install_link, cups, cupsaccept, /usr/sbin/cupsreject)
+       @$(call install_link, cups, cupsaccept, /usr/sbin/reject)
+
+ifdef PTXCONF_CUPS_TEST_TOOLS
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cupstestdsc)
+       @$(call install_copy, cups, root, root, 0755, -, /usr/bin/cupstestppd)
+endif
+
+# ----- backends, filters, cgi-bin (if enabled), etc.
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/backend)
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/daemon)
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/filter)
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/monitor)
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/notifier)
+
+ifdef PTXCONF_CUPS_LIBUSB
+       @$(call install_alternative, cups, root, root, 0644, \
+               /usr/share/cups/usb/org.cups.usb-quirks)
+endif
+
+ifdef PTXCONF_CUPS_WEBINTERFACE
+       @$(call install_lib, cups, root, root, 0755, libcupscgi)
+       @$(call install_tree, cups, root, root, -, /usr/lib/cups/cgi-bin)
+       @$(call install_tree, cups, root, root, -, /usr/share/cups/templates)
+       @$(call install_tree, cups, root, root, -, /usr/share/doc/cups)
+endif
+
+# ----- startup files
+ifdef PTXCONF_CUPS_SYSTEMD_UNIT
+       @$(call install_alternative, cups, root, root, 0644, \
+               /usr/lib/tmpfiles.d/cups.conf)
+       @$(call install_alternative, cups, root, root, 0644, \
+               /usr/lib/systemd/system/cups.service)
+       @$(call install_alternative, cups, root, root, 0644, \
+               /usr/lib/systemd/system/cups.socket)
+       @$(call install_link, cups, ../cups.service, \
+               /usr/lib/systemd/system/printer.target.wants/cups.service)
+       @$(call install_link, cups, ../cups.socket, \
+               /usr/lib/systemd/system/sockets.target.wants/cups.socket)
+endif
+
+ifdef PTXCONF_CUPS_STARTSCRIPT
+       @$(call install_alternative, cups, root, root, 0755, /etc/init.d/cups)
+       @$(call install_link, cups, ../init.d/cups, \
+               /etc/rc.d/$(PTXCONF_CUPS_BBINIT_LINK))
+endif
+
+       @$(call install_finish, cups)
+
+       @$(call touch)
+
+# vim: ft=make ts=8 tw=80
-- 
2.11.0


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de

Reply via email to