Makefile.in 9.76 KB
Newer Older
1 2

# Makefile to install foomatic-db-engine
3
# $Revision$
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26

# PREFIX defaults to /usr/local for manually installed progs, so that they
# are not messed up on a system upgrade.
#
# `architecture independent', static data files i.e. perl libs go into
#   $(PREFIX)/share/foomatic
# (user) executables into $(PREFIX)/bin/
# system binaries go into $(PREFIX)/sbin
# configuration files into /etc/foomatic/*.
#
# The PERLPREFIX allows a seperate prefix for the Perl libraries. Use this
# when Perl libraries in /usr/local are not found.

# Variables

DEBUG=

prefix=@prefix@
exec_prefix=@exec_prefix@
libdir=@libdir@
bindir=@bindir@
sbindir=@sbindir@
mandir=@mandir@
27
datarootdir=@datarootdir@
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
datadir=@datadir@
sysconfdir=@sysconfdir@

SRC=@srcdir@
INSTALL=@INSTALL@
PREFIX=$(prefix)
PERLPREFIX=@PERLPREFIX@

# Foomatic database location for a regular installation
LIBDIR=@LIBDIR@

# Foomatic database location for a "make inplace" installation
LOCAL_LIBDIR=@LOCAL_LIBDIR@

# foomatic-rip path for a regular installation
FOOMATIC_RIP=@FOOMATIC_RIP@

# foomatic-rip path for a "make inplace" installation
LOCAL_FOOMATIC_RIP=@LOCAL_FOOMATIC_RIP@

# Locations for installing the components of this package
BINDIR=$(bindir)
SBINDIR=$(sbindir)
MANDIR=$(mandir)
ETCDIR=$(sysconfdir)/foomatic

## C settings
CC=@CC@
CFLAGS=@CFLAGS@
XML_CFLAGS=@XML_CFLAGS@
XML_LIBS=@XML_LIBS@

## Settings for Perl
# Where to find the perl binary
PERL=@PERL@
# How to install the perl libs, may be either "site" or "perl" 
# details in the ExtUtils::MakeMaker manpage
PERL_INSTALLDIRS=@PERL_INSTALLDIRS@

# Genereal paths for all filter scripts
EXEC_PATH=/usr/local/bin:/usr/bin:/bin
LOG_PATH=/tmp

# Paths for LPD and LPRng
LPD_SPOOL=@LPD_SPOOL@
LPD_LOG=@LPD_LOG@
LPD_BIN=@LPD_BIN@
PRINTCAP=@PRINTCAP@
LPRNG_CONF=@LPRNG_CONF@
LPD_LPR=@LPD_LPR@
LPD_LPQ=@LPD_LPQ@
LPD_LPRM=@LPD_LPRM@
LPD_LPC=@LPD_LPC@
LPRNG_CHECKPC=@LPRNG_CHECKPC@

# Paths and other settings for CUPS
CUPS_ETC=@CUPS_ETC@
CUPS_ADMIN=@CUPS_ADMIN@
CUPS_LPSTAT=@CUPS_LPSTAT@
CUPS_PPDS=@CUPS_PPDS@
CUPS_FILTERS=@CUPS_FILTERS@
CUPS_BACKENDS=@CUPS_BACKENDS@
90 91
LIB_CUPS=@LIB_CUPS@
CUPS_DRIVER=@LIB_CUPS@/driver
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
CUPS_PCONF=@CUPS_PCONF@
CUPS_LPR=@CUPS_LPR@
CUPS_LPQ=@CUPS_LPQ@
CUPS_LPRM=@CUPS_LPRM@
CUPS_LPC=@CUPS_LPC@
CUPS_LP=@CUPS_LP@
CUPS_CANCEL=@CUPS_CANCEL@
CUPS_ENABLE=@CUPS_ENABLE@
CUPS_DISABLE=@CUPS_DISABLE@
CUPS_ACCEPT=@CUPS_ACCEPT@
CUPS_REJECT=@CUPS_REJECT@
CUPS_LPMOVE=@CUPS_LPMOVE@
CUPS_LPOPTIONS=@CUPS_LPOPTIONS@
CUPS_LPINFO=@CUPS_LPINFO@

# Paths for PDQ
PDQ_CONF=@PDQ_CONF@
PDQ_PRINTRC=@PDQ_PRINTRC@
PDQ_FOOMATIC=$(PDQ_CONF)/drivers/foomatic
PDQ_PRINT=@PDQ_PRINT@
PDQ_JOBDIR=~/.printjobs

# Paths for PPR
PPR_PPRD=@PPR_PPRD@
PPR_INTERFACES=@PPR_INTERFACES@
PPR_PPDFILES=@PPR_PPDFILES@
PPR_ETC=@PPR_ETC@
PPR_PPR=@PPR_PPR@
PPR_PPAD=@PPR_PPAD@
PPR_PPOP=@PPR_PPOP@

# Paths for direct, spoolerless printing
DIRECT_ETC=$(ETCDIR)/direct
DIRECT_CONFIG=$(DIRECT_ETC)/.config

# Other paths
NC=@NC@
RLPR=@RLPR@
SMBCLIENT=@SMBCLIENT@
NPRINT=@NPRINT@
PTAL_CONNECT=@PTAL_CONNECT@
PTAL_PIPES=@PTAL_PIPES@
MTINK_PIPES=@MTINK_PIPES@
CAT=@CAT@
GZIP=@GZIP@
WGET=@WGET@
CURL=@CURL@

# This is mainly useful for building a binary foomatic package
DESTDIR=/

### Probably nothing to fiddle past here

# Files generated by the AC_OUTPUT call of "./configure"
AC_OUTPUT_FILES:=Makefile makeDefaults makeMan \
	foomatic-configure foomatic-printjob \
	foomatic-kitload foomatic-ppdfile foomatic-preferred-driver \
	foomatic-cleanupdrivers foomatic-getpjloptions \
	foomatic-addpjloptions foomatic-compiledb foomatic-fix-xml \
	foomatic-nonumericalids foomatic-replaceoldprinterids \
152
	foomatic-ppd-options foomatic-printermap-to-gutenprint-xml \
153
	foomatic-extract-text foomatic-searchprinter foomatic-ppd-to-xml
154 155 156 157 158

# User programs and helper programs
BINFILES:=foomatic-printjob foomatic-configure \
	foomatic-combo-xml foomatic-perl-data \
	foomatic-ppdfile foomatic-compiledb \
159
	foomatic-ppd-options foomatic-searchprinter foomatic-ppd-to-xml
160 161 162 163 164 165

# Administrative commands, only useful for admins
SBINFILES:=foomatic-kitload \
	foomatic-getpjloptions foomatic-addpjloptions \
	foomatic-preferred-driver foomatic-fix-xml \
	foomatic-nonumericalids foomatic-replaceoldprinterids \
166
	foomatic-printermap-to-gutenprint-xml \
167
	foomatic-cleanupdrivers foomatic-extract-text
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

# Foomatic XML templates
TEMPLATES:=pjl_enum_choice.xml pjl_enum_option.xml pjl_num_option.xml

# Masks for trash files which have to be removed before packaging Foomatic
TRASHFILES:="*~" "*\#*" ".??*" "*.rej"

all: build

# The install rule should check for kitloads and avoid stomping.  It doesn't
install: install-bin install-man

check-config:
	@if [ -f .testing-stamp ] ; then \
	   echo 'Cowardly refusing to install testing Defaults.pm.' ;\
	   echo 'Use "make testing-clean; make defaults" to get a proper one.' ;\
	   exit 1 ;\
	fi

install-bin: check-config lib/Makefile
#	This is the only way to get the Perl-generated Makefile using
#	$(DESTDIR) properly
	( cd lib && \
	  $(MAKE) PREFIX=$(PERLPREFIX) && \
192
	  $(MAKE) PREFIX=$(PERLPREFIX) DESTDIR=$(DESTDIR) pure_install \
193 194 195 196 197 198 199 200 201 202 203 204 205 206
	)
	${SRC}/mkinstalldirs $(DESTDIR)$(BINDIR)
	${SRC}/mkinstalldirs $(DESTDIR)$(SBINDIR)
	${SRC}/mkinstalldirs $(DESTDIR)$(ETCDIR)
	${SRC}/mkinstalldirs $(DESTDIR)$(LIBDIR)/templates
	${INSTALL} -m 755 $(BINFILES) $(DESTDIR)$(BINDIR)
	${INSTALL} -m 755 $(SBINFILES) $(DESTDIR)$(SBINDIR)
	( cd foomatic-templates && \
	  ${INSTALL} -m 644 $(TEMPLATES) $(DESTDIR)$(LIBDIR)/templates \
	)
	$(PERL) -p -i -e "s:foomatic-templates:$(LIBDIR)/templates:g" $(DESTDIR)$(SBINDIR)/foomatic-addpjloptions
#	Link to allow foomatic-ppdfile be called under the old name
#	foomatic-datafile
	ln -sf foomatic-ppdfile $(DESTDIR)$(BINDIR)/foomatic-datafile
207 208 209 210 211 212 213
#	Link foomatic-ppdfile to the CUPS 1.2 PPD generator directory,
#	so that the cups-driverd automatically generates Foomatic PPDs
#	on demand (/usr/lib/cups/driver).
	if [ -d $(LIB_CUPS) ]; then \
	  ${SRC}/mkinstalldirs $(DESTDIR)$(CUPS_DRIVER); \
	  ln -sf $(BINDIR)/foomatic-ppdfile $(DESTDIR)$(CUPS_DRIVER)/foomatic; \
	fi
214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233

install-man: check-config
	${SRC}/mkinstalldirs $(DESTDIR)$(MANDIR)
	${SRC}/mkinstalldirs $(DESTDIR)$(MANDIR)/man1
	${SRC}/mkinstalldirs $(DESTDIR)$(MANDIR)/man8
	${INSTALL} -m 644 *.1 $(DESTDIR)$(MANDIR)/man1
	${INSTALL} -m 644 *.8 $(DESTDIR)$(MANDIR)/man8

# If the Perl scripts have "use lib 'lib/';" lines from a former
# "make testing", we remove them.
build: defaults lib/Makefile foomatic-combo-xml foomatic-perl-data man
	for m in $(BINFILES) $(SBINFILES); do \
	  $(PERL) -p -i -e "s=use lib '.*lib/';\n==s" $$m; \
	done
	chmod a+rx $(AC_OUTPUT_FILES) mkinstalldirs

lib/Makefile: lib/Makefile.PL
	( cd lib && $(PERL) Makefile.PL verbose INSTALLDIRS=$(PERL_INSTALLDIRS) )

foomatic-combo-xml: foomatic-combo-xml.c
234
	$(CC) $(CFLAGS) $(LDFLAGS) -o foomatic-combo-xml foomatic-combo-xml.c
235 236

foomatic-perl-data: foomatic-perl-data.c
237
	$(CC) $(CFLAGS) $(XML_CFLAGS) $(LDFLAGS) -o foomatic-perl-data foomatic-perl-data.c $(XML_LIBS)
238

239
man: lib/Foomatic/Defaults.pm
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
	chmod a+rx ./makeMan
	./makeMan

clean: lib/Makefile remove-trash
	$(MAKE) -C lib clean
	rm -f lib/Makefile.old
	rm -f lib/Foomatic/Defaults.pm
	rm -f *~ .testing-stamp
	rm -f *.o gs_out
	rm -f foomatic-combo-xml
	rm -f foomatic-perl-data
	rm -f Foomatic
	rm -rf foomatic-db
	rm -f $(BINFILES:=.1) $(SBINFILES:=.8)
#	Remove links from inplace installation
	rm -f foomatic-rip foomatic-datafile man
256 257 258
#       Remove foomatic-ppds-<version>.tar.gz package
	rm -rf foomatic-ppds foomatic-ppds-[0-9]*
	rm -rf foomatic-ppds*.tar.gz
259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339

distclean: clean
	rm -f $(AC_OUTPUT_FILES) config.log config.status config.cache
	rm -rf autom*.cache confdefs.h ppd foomatic-db db

maintainer-clean: distclean
	rm -f configure aclocal.m4

# Uninstall an installed Foomatic
uninstall: uninstall-bin uninstall-man

uninstall-bin: check-config lib/Makefile
#	This is the only way to get the Perl-generated Makefile using
#	$(DESTDIR) properly
	( cd lib && \
	  $(MAKE) PREFIX=$(DESTDIR)$(PERLPREFIX) uninstall \
	)
	( cd $(DESTDIR)$(BINDIR) && \
	  rm -f $(BINFILES) \
	)
	rm -f $(DESTDIR)$(BINDIR)/foomatic-datafile
	( cd $(DESTDIR)$(SBINDIR) && \
	  rm -f $(SBINFILES) \
	)
	( cd $(DESTDIR)$(LIBDIR)/templates && \
	  rm -f $(TEMPLATES) \
	)
	rmdir $(DESTDIR)$(LIBDIR)/templates || :
	rmdir $(DESTDIR)$(ETCDIR) || :

uninstall-man: check-config
	for m in $(BINFILES); do \
	  rm -f $(DESTDIR)$(MANDIR)/man1/$$m.*; \
	done
	for m in $(SBINFILES); do \
	  rm -f $(DESTDIR)$(MANDIR)/man8/$$m.*; \
	done

# Various testing/debugging/etc targets
# We insert a "use lib 'lib/';" line into the perl scripts, so that
# they use the local database and libraries, so they also work correctly on
# systems with installed Foomatic.
inplace: testing
testing: INPLACE = --inplace
testing: defaults foomatic-combo-xml foomatic-perl-data man
	ln -sf lib/Foomatic .; \
	for m in $(BINFILES) $(SBINFILES); do \
	  $(PERL) -p -i -e "s=^\#\x21$(PERL)(.*)\n=\#\x21$(PERL)\$$1\nuse lib '`pwd`/lib/';\n=s" $$m; \
	done
	chmod a+rx $(AC_OUTPUT_FILES)
#	Links for more convenient usage of the "inplace" installation
	ln -sf $(LOCAL_FOOMATIC_RIP) foomatic-rip
	ln -sf `pwd`/foomatic-ppdfile foomatic-datafile
#	Script for the man pages
	echo -en '#!/bin/sh\nman ./\044\061.[1-9n] 2>/dev/null || man \044\061\n' > man || :
	chmod a+rx man || :

inplace-clean: testing-clean
testing-clean: clean

# Remove editor backup and temporary files
remove-trash:
	for m in $(TRASHFILES); do \
	  find . -name "$$m" -exec rm "{}" \; ; \
	done

# We need to export all Variables for makeDefaults and the target to
# work.
.EXPORT_ALL_VARIABLES:

# Use INPLACE=--inplace to get the special run-in-place Defaults.
defaults: lib/Foomatic/Defaults.pm

lib/Foomatic/Defaults.pm: Makefile makeDefaults
	chmod a+rx ./makeDefaults
	./makeDefaults $(INPLACE)
	if [ x$(INPLACE) = x--inplace ] ; then touch .testing-stamp ; fi

.PHONY: all defaults check-config build install install-bin \
	man inplace testing clean inplace-clean testing-clean distclean \
	maintainer-clean