1#
2# Top-level Makefile for CUPS.
3#
4# Copyright © 2020 by Michael R Sweet
5# Copyright © 2007-2019 by Apple Inc.
6# Copyright © 1997-2007 by Easy Software Products, all rights reserved.
7#
8# Licensed under Apache License v2.0.  See the file "LICENSE" for more
9# information.
10#
11
12include Makedefs
13
14
15#
16# Directories to make...
17#
18
19DIRS	=	cups $(BUILDDIRS)
20
21
22#
23# Test suite options - normally blank, override with make command...
24#
25
26TESTOPTIONS	=
27
28
29#
30# Make all targets...
31#
32
33all:
34	chmod +x cups-config
35	echo Using ARCHFLAGS="$(ARCHFLAGS)"
36	echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
37	echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
38	echo Using CC="$(CC)"
39	echo Using CXX="$(CC)"
40	echo Using DSOFLAGS="$(DSOFLAGS)"
41	echo Using LDFLAGS="$(LDFLAGS)"
42	echo Using LIBS="$(LIBS)"
43	for dir in $(DIRS); do\
44		echo Making all in $$dir... ;\
45		(cd $$dir ; $(MAKE) $(MFLAGS) all $(UNITTESTS)) || exit 1;\
46	done
47
48
49#
50# Make library targets...
51#
52
53libs:
54	echo Using ARCHFLAGS="$(ARCHFLAGS)"
55	echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
56	echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
57	echo Using CC="$(CC)"
58	echo Using CXX="$(CC)"
59	echo Using DSOFLAGS="$(DSOFLAGS)"
60	echo Using LDFLAGS="$(LDFLAGS)"
61	echo Using LIBS="$(LIBS)"
62	for dir in $(DIRS); do\
63		echo Making libraries in $$dir... ;\
64		(cd $$dir ; $(MAKE) $(MFLAGS) libs) || exit 1;\
65	done
66
67
68#
69# Make unit test targets...
70#
71
72unittests:
73	echo Using ARCHFLAGS="$(ARCHFLAGS)"
74	echo Using ALL_CFLAGS="$(ALL_CFLAGS)"
75	echo Using ALL_CXXFLAGS="$(ALL_CXXFLAGS)"
76	echo Using CC="$(CC)"
77	echo Using CXX="$(CC)"
78	echo Using DSOFLAGS="$(DSOFLAGS)"
79	echo Using LDFLAGS="$(LDFLAGS)"
80	echo Using LIBS="$(LIBS)"
81	for dir in $(DIRS); do\
82		echo Making all in $$dir... ;\
83		(cd $$dir ; $(MAKE) $(MFLAGS) unittests) || exit 1;\
84	done
85
86
87#
88# Remove object and target files...
89#
90
91clean:
92	for dir in $(DIRS); do\
93		echo Cleaning in $$dir... ;\
94		(cd $$dir; $(MAKE) $(MFLAGS) clean) || exit 1;\
95	done
96
97
98#
99# Remove all non-distribution files...
100#
101
102distclean:	clean
103	$(RM) Makedefs config.h config.log config.status
104	$(RM) conf/cups-files.conf conf/cupsd.conf conf/mime.convs conf/pam.std conf/snmp.conf
105	$(RM) cups-config
106	$(RM) desktop/cups.desktop
107	$(RM) doc/index.html
108	$(RM) packaging/cups.list
109	$(RM) scheduler/cups-lpd.xinetd scheduler/cups.sh scheduler/cups.xml scheduler/org.cups.cups-lpd.plist scheduler/org.cups.cups-lpdAT.service scheduler/org.cups.cupsd.path scheduler/org.cups.cupsd.service scheduler/org.cups.cupsd.socket
110	$(RM) templates/header.tmpl
111	-$(RM) doc/*/index.html
112	-$(RM) templates/*/header.tmpl
113	-$(RM) -r autom4te*.cache cups/charmaps cups/locale
114
115
116#
117# Make dependencies
118#
119
120depend:
121	for dir in $(DIRS); do\
122		echo Making dependencies in $$dir... ;\
123		(cd $$dir; $(MAKE) $(MFLAGS) depend) || exit 1;\
124	done
125
126
127#
128# Run the STACK tool on the sources, available here:
129#
130#    http://css.csail.mit.edu/stack/
131#
132# Do the following to pass options to configure:
133#
134#    make CONFIGFLAGS="--foo --bar" stack
135#
136
137.PHONY: stack
138stack:
139	stack-build ./configure $(CONFIGFLAGS)
140	stack-build $(MAKE) $(MFLAGS) clean all
141	poptck
142	$(MAKE) $(MFLAGS) distclean
143	$(RM) */*.ll
144	$(RM) */*.ll.out
145
146
147#
148# Generate a ctags file...
149#
150
151ctags:
152	ctags -R .
153
154
155#
156# Install everything...
157#
158
159install:	install-data install-headers install-libs install-exec
160
161
162#
163# Install data files...
164#
165
166install-data:
167	echo Making all in cups...
168	(cd cups; $(MAKE) $(MFLAGS) all)
169	for dir in $(DIRS); do\
170		echo Installing data files in $$dir... ;\
171		(cd $$dir; $(MAKE) $(MFLAGS) install-data) || exit 1;\
172	done
173	echo Installing cups-config script...
174	$(INSTALL_DIR) -m 755 $(BINDIR)
175	$(INSTALL_SCRIPT) cups-config $(BINDIR)/cups-config
176
177
178#
179# Install header files...
180#
181
182install-headers:
183	for dir in $(DIRS); do\
184		echo Installing header files in $$dir... ;\
185		(cd $$dir; $(MAKE) $(MFLAGS) install-headers) || exit 1;\
186	done
187	if test "x$(privateinclude)" != x; then \
188		echo Installing config.h into $(PRIVATEINCLUDE)...; \
189		$(INSTALL_DIR) -m 755 $(PRIVATEINCLUDE); \
190		$(INSTALL_DATA) config.h $(PRIVATEINCLUDE)/config.h; \
191	fi
192
193
194#
195# Install programs...
196#
197
198install-exec:	all
199	for dir in $(DIRS); do\
200		echo Installing programs in $$dir... ;\
201		(cd $$dir; $(MAKE) $(MFLAGS) install-exec) || exit 1;\
202	done
203
204
205#
206# Install libraries...
207#
208
209install-libs:	libs
210	for dir in $(DIRS); do\
211		echo Installing libraries in $$dir... ;\
212		(cd $$dir; $(MAKE) $(MFLAGS) install-libs) || exit 1;\
213	done
214
215
216#
217# Uninstall object and target files...
218#
219
220uninstall:
221	for dir in $(DIRS); do\
222		echo Uninstalling in $$dir... ;\
223		(cd $$dir; $(MAKE) $(MFLAGS) uninstall) || exit 1;\
224	done
225	echo Uninstalling cups-config script...
226	$(RM) $(BINDIR)/cups-config
227	-$(RMDIR) $(BINDIR)
228
229
230#
231# Run the test suite...
232#
233
234testserver:	all unittests
235	echo Running CUPS test server...
236	cd test; ./run-stp-tests.sh $(TESTOPTIONS)
237
238
239check test:	all unittests
240	echo Running CUPS test suite...
241	cd test; ./run-stp-tests.sh 1 0 n n
242
243debugcheck debugtest:	all unittests
244	echo Running CUPS test suite with debug printfs...
245	cd test; ./run-stp-tests.sh 1 0 n y
246
247
248#
249# Create HTML documentation using codedoc (http://www.msweet.org/codedoc)...
250#
251
252apihelp:
253	for dir in cups filter; do\
254		echo Generating API help in $$dir... ;\
255		(cd $$dir; $(MAKE) $(MFLAGS) apihelp) || exit 1;\
256	done
257
258
259#
260# Lines of code computation...
261#
262
263sloc:
264	for dir in cups scheduler; do \
265		(cd $$dir; $(MAKE) $(MFLAGS) sloc) || exit 1;\
266	done
267
268
269#
270# Make software distributions using EPM (http://www.msweet.org/)...
271#
272
273EPMFLAGS	=	-v --output-dir dist $(EPMARCH)
274
275bsd deb epm pkg rpm slackware:
276	epm $(EPMFLAGS) -f $@ cups packaging/cups.list
277
278.PHONY:	dist
279dist:	all
280	$(RM) -r dist
281	$(MAKE) $(MFLAGS) epm
282	case `uname` in \
283		*BSD*) $(MAKE) $(MFLAGS) bsd;; \
284		Linux*) test ! -x /usr/bin/rpm || $(MAKE) $(MFLAGS) rpm;; \
285		SunOS*) $(MAKE) $(MFLAGS) pkg;; \
286	esac
287
288
289#
290# Don't run top-level build targets in parallel...
291#
292
293.NOTPARALLEL:
294