1# Makefile to create LPRng, ifhp, and LPRngTool
2#  targets:
3#   make all       - does unpack, configure, build
4#     make unpack    - untars the latest releases, creates symlinks to distributions
5#     make configure - does configure in distributions, create .configured in subdirectory
6#     make build     - does a make all in the subdirs 
7#   make install     - does a make install in the subdirs 
8#                           and some fixup of files
9#   make printcap    - cd PRINTCAP and makes/installs new printcap...
10#                      see PRINTCAP/Makefile for details
11#   make lpd.perms lpd.conf - cd to LPD_PERMS, LPD_CONF and does install
12#                      - lpd.perms is usually the only thing needed
13#   make clean     - does a make clean in the subdirs 
14
15# what distributions do you want
16dist=ifhp LPRng LPRngTool
17# what configuration files do you want
18config=PRINTCAP LPD_PERMS
19
20sysconfdir=/etc/lpd
21filterdir=/usr/libexec/filters
22#filters=transmeta.bp
23
24#
25#  Directory and file names:
26#    --prefix=PREFIX         install architecture-independent files in PREFIX
27#                            [/usr/local]
28#    --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
29#                            [same as prefix]
30#    --bindir=DIR            user executables in DIR [EPREFIX/bin]
31#    --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
32#    --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
33#    --datadir=DIR           read-only architecture-independent data in DIR
34#                            [PREFIX/share]
35#    --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
36#    --sharedstatedir=DIR    modifiable architecture-independent data in DIR
37#                            [PREFIX/com]
38#    --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
39#    --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
40#    --includedir=DIR        C header files in DIR [PREFIX/include]
41#    --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
42#    --infodir=DIR           info documentation in DIR [PREFIX/info]
43#    --mandir=DIR            man documentation in DIR [PREFIX/man]
44#    --srcdir=DIR            find the sources in DIR [configure dir or ..]
45#    --program-prefix=PREFIX prepend PREFIX to installed program names
46#    --program-suffix=SUFFIX append SUFFIX to installed program names
47#    --program-transform-name=PROGRAM
48#                            run sed PROGRAM on installed program names
49#   --disable-strip                   disable stripping binaries by default
50#   --enable-shared[=PKGS]  build shared libraries [default=yes]
51#   --enable-static[=PKGS]  build static libraries [default=yes]
52#   --enable-fast-install[=PKGS]  optimize for fast installation [default=yes]
53#   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
54#   --disable-libtool-lock  avoid locking (might break parallel builds)
55
56all_config=--prefix=/usr --mandir=/usr/share/man --sysconfdir=${sysconfdir} --with-filterdir=${filterdir} --disable-shared
57
58# LPRng 
59#   --enable-unix_socket              add unix socket for localhost connections
60#   --with-unix_socket_path=DIR       unix socket path (default /var/run/lprng)
61#   --disable-setuid                  do not install client executables setuid root
62#   --enable-priv_ports               require connections from privileged ports
63#   --disable-force_localhost         disable force_localhost default
64#   --disable-require_configfiles     client programs require lpd.conf, printcap
65#   --enable-kerberos                 enable kerberos support
66#   --enable-mit_kerberos4            enable MIT Kerberos 4 support
67#   --disable-kerberos_checks         disable kerberos library location and checking for support
68#   --with-lpddir=DIR                 lpd executable directory (default ${sbindir})
69#   --with-lpd_conf_path=PATH         path of lpd.conf (default: ${sysconfdir}/lpd.conf)
70#   --with-lpd_perms_path=PATH        path of lpd.perms (default: ${sysconfdir}/lpd.perms)
71#   --with-printcap_path=PATH         path of printcap (default ${sysconfdir}/printcap)
72#   --with-lpd_printcap_path=PATH     path of lpd_printcap (default ${sysconfdir}/lpd_printcap)
73#   --with-initpath=PATH              path of lpd startup file (default /usr/local/etc/rc.d/lprng.sh)
74#                                        use 'no' to disable installation and lpd startup
75#   --with-lockfile=PATH              lockfile PATH, default /var/run/lpd 
76#   --with-ld_libary_path=PATH        LD_LIBRARY_PATH value, default /lib:/usr/lib:/usr/local/lib 
77#   --with-filter_path=PATH           filter PATH value, default /bin:/usr/bin:/usr/local/bin 
78#   --with-userid=NAME                run LPRng software as this userid, default daemon 
79#   --with-groupid=NAME               run LPRng software as this groupid, default daemon 
80#   --with-done_jobs=N                retain last N job status, default 1
81#   --with-done_jobs_max_age=N        retain job status N seconds, default 0 - no expiry
82#   --with-chooser_routine=NAME       load balance queue chooser routine name in user object file 
83#   --with-order_routine=NAME         queue order routine name in user object file 
84#   --with-user_objs=NAME             user specified object file 
85#   --with-user_include=NAME          include file with function prototypes for user object file 
86#   --with-filterdir=DIR              filter directory (default ${libexecdir}/filters)
87
88LPRng_config=${all_config} --with-userid=lp --with-groupid=lp
89
90# ifhp
91#  --with-ifhp_conf=path   ifhp.conf config file (default \${sysconfdir}/ifhp.conf)
92
93ifhp_config=${all_config}
94
95# LPRngTool
96#  --with-printcap_path=PATH    location of printcap file (default \${sysconfdir}/printcap)
97#  --with-spool_directory=PATH  location of spool directories (default /var/spool/lpd)
98#  --with-ifhp_path=PATH        location of ifhp filter (default: \${FILTER_DIR}/ifhp)
99#  --with-ifhp_conf=PATH        location of ifhp configuration file (default: \${sysconfdir}/ifhp.conf)
100#  --with-filterdir=DIR         filter directory (default \${libexecdir}/filters)
101
102LPRngTool_config=${all_config} --with-spool_directory=/var/spool/lpd
103
104all: unpack configure build
105.PHONEY: all unpack lpd.conf lpd.perms reconfigure configure build install
106
107unpack: ${dist}
108
109${dist}:
110	set -e; \
111	d=`ls | grep "$@-.*tgz\$$" | tail -1` ; \
112	if [ "$$d" = "" ] ; then \
113		echo "no distribution for $@"; \
114		exit 1; \
115	fi; \
116	dir=`echo $$d |sed -e s/.tgz//` ; \
117	if [ "$$dir" = "" ] ; then \
118		echo "no could be extracted directory for $@" ; \
119		exit 1; \
120	fi; \
121	if [ ! -d $$dir ] ; then tar zxvf $$d; fi ; \
122	if [ ! -d $$dir ] ; then \
123		echo "tar failed to create $$dir"; \
124		exit 1; \
125	fi; \
126	rm -f $@; ln -s $$dir $@
127
128reconfigure:
129	for i in ${dist}; do rm -f $$i/.configured; done;
130
131configure:
132	for i in ${dist} ; do \
133		set -e; \
134		if [ ! -f $$i/.configured ] ; then \
135			set -e; \
136			case $$i in \
137			LPRngTool ) p="${LPRngTool_config}" ;; \
138			ifhp ) p="${ifhp_config}" ;; \
139			LPRng ) p="${LPRng_config}"  ;; \
140			esac ; \
141			if (cd $$i; ./configure $$p ) ; then date > $$i/.configured; else exit 1; fi ; \
142		fi; \
143	done
144
145build:
146	for i in ${dist} ${config} ; do \
147		if [ -f $$i/Makefile ] ; then \
148			( cd $$i; make SYSCONFDIR=${sysconfdir} all) ; \
149		fi ; \
150	done;
151
152install: 
153	for i in ${dist} ; do \
154		if [ -f $$i/Makefile ] ; then \
155			( cd $$i; make SYSCONFDIR=${sysconfdir} install); \
156		fi; \
157	done;
158
159	for i in ${filters} ; do \
160		install -c -m 755 -o root -g bin $$i ${filterdir}/; \
161	done
162
163clean:
164	for i in ${dist}; do \
165		if [ -f $$i/Makefile ] ; then (cd $$i; make clean); fi; \
166	done;
167
168realclean:
169	for i in ${dist}; do rm -rf $${i} $${i}-*[0-9]; done
170
171tar: clean
172	if [ -x /bin/pwd ] ; then DIR=`/bin/pwd`; fi ; \
173	if [ -x /usr/bin/pwd ] ; then DIR=`/usr/bin/pwd`; fi ; \
174	echo $${DIR}; \
175	DIR=`echo $${DIR} | sed 's,.*/,,'`; \
176		cd ..; \
177		tar zcf $${DIR}.tgz $${DIR}; \
178		md5sum $${DIR}.tgz > $${DIR}.tgz.md5
179	@echo ""
180
181