Makefile revision 47e71ac4
1#	$NetBSD: Makefile,v 1.38 2003/05/30 13:05:58 tron Exp $
2#
3# Targets & Variables
4#
5# build: Clean out xsrc, and build and install everything that goes
6#	under /usr/X11R6.
7#
8#  DESTDIR -- Set to an alternative directory to install under.
9#  UPDATE --  If set, don't make clean first, plus attempt to make
10#	only the targets that are out of date.
11#
12# release snapshot: Same as build, plus tar up the X sets and install
13#	them under the ${RELEASEDIR}/binary/sets directory (NetBSD <=1.6)
14#	or the ${RELEASEDIR}/${MACHINE}/binary/sets directory (NetBSD >1.6).
15#
16#  DESTDIR -- Same as for build. Mandatory for building a release.
17#  RELEASEDIR -- As explained above.
18#  BUILD_DONE -- If set, assume build is already done.
19#  INSTALL_DONE -- If set, assume binaries to tar up are to be found
20#	in ${DESTDIR} already.
21#  NETBSDSRCDIR -- Set to the full path to the main source tree, /usr/src
22#	by default. Needed to find ./distrib/sets.
23#
24# cleandir distclean: Remove all generated files from under xsrc.
25#
26# clean: Remove object files, but keep imake generated makefiles.
27
28.include <bsd.own.mk>
29
30# Backwards compatibility with NetBSD 1.5 and 1.5.x where NETBSDSRCDIR
31# doesn't get defined by  "bsd.own.mk".
32NETBSDSRCDIR?=	${BSDSRCDIR}
33
34.if defined(USE_XF86_4) && (${USE_XF86_4} != no)
35XCDIR=	xfree/xc
36.else
37XCDIR=	xc
38.endif
39
40.MAIN: all
41.if defined(USE_XF86_4) && (${USE_XF86_4} != no)
42all: all-xc all-local
43.else
44all: all-xc all-contrib all-local
45.endif
46
47all-xc:
48.if exists(${XCDIR}/xmakefile) && defined(UPDATE)
49	@cd ${XCDIR} && ${MAKE} Everything
50.else
51	@-rm -f ${XCDIR}/xmakefile
52	@cd ${XCDIR} && ${MAKE} World
53.endif
54
55all-contrib:
56	@if [ ! -f contrib/Makefile ]; then \
57	  cd contrib && PATH=../${XCDIR}/config/imake:$$PATH \
58	    sh ../${XCDIR}/config/util/xmkmf -a ../${XCDIR} \
59	       ${.CURDIR}/contrib; \
60	fi
61	@cd contrib && ${MAKE}
62
63all-local:
64	@if [ ! -f local/Makefile ]; then \
65	  cd local && PATH=../${XCDIR}/config/imake:$$PATH \
66	    sh ../${XCDIR}/config/util/xmkmf -a ../${XCDIR} \
67	      ${.CURDIR}/local; \
68	fi
69	@cd local && ${MAKE}
70
71.if defined(USE_XF86_4) && (${USE_XF86_4} != no)
72install: install-xc install-local
73.else
74install: install-xc install-contrib install-local
75.endif
76
77install-xc:
78	@cd ${XCDIR} && \
79	  ${MAKE} DESTDIR="${DESTDIR}" install && \
80	  ${MAKE} DESTDIR="${DESTDIR}" install.man
81
82install-contrib:
83	@cd contrib && \
84	  ${MAKE} DESTDIR="${DESTDIR}" install && \
85	  ${MAKE} DESTDIR="${DESTDIR}" install.man
86
87install-local:
88	@cd local && \
89	  ${MAKE} DESTDIR="${DESTDIR}" install && \
90	  ${MAKE} DESTDIR="${DESTDIR}" install.man
91
92clean:
93.if defined(USE_XF86_4) && (${USE_XF86_4} != no)
94	@-cd ${XCDIR} && ${MAKE} clean
95	@-cd local && ${MAKE} clean
96.else
97	@-cd ${XCDIR} && ${MAKE} clean
98	@-cd contrib && ${MAKE} clean
99	@-cd local && ${MAKE} clean
100.endif
101
102cleandir distclean: clean
103	find ${XCDIR} contrib local -name .depend | xargs -n5 rm
104	find ${XCDIR} contrib local -name 'Makefile*' | \
105	    xargs -n5 grep -l "Makefile generated by imake" | xargs rm
106	-rmdir ${XCDIR}/exports
107	rm -f ${XCDIR}/xmakefile
108
109build:
110.if defined(UPDATE)
111	@${MAKE} all && ${MAKE} install
112.else
113	@${MAKE} cleandir && ${MAKE} all && ${MAKE} install
114.endif
115
116# release goo
117#
118.if !defined(DESTDIR)
119release snapshot:
120	@echo setenv DESTDIR before doing that!
121	@false
122.elif !defined(RELEASEDIR)
123release snapshot:
124	@echo setenv RELEASEDIR before doing that!
125	@false
126#
127.else
128#
129.if defined(INSTALL_DONE)
130release snapshot:
131.elif defined(BUILD_DONE)
132release snapshot: install
133.else
134release snapshot: build
135#
136.endif # INSTALL_DONE or BUILD_DONE
137#
138	${INSTALL} -d -m 755 -o root -g wheel ${RELEASEDIR}/${MACHINE}/binary/sets
139.if (${MACHINE} == "amiga") && !(defined(USE_XF86_4) && (${USE_XF86_4} != no))
140	cd ${XCDIR}/programs/Xserver/hw/netbsd/amiga && \
141		${INSTALL} -c -m 644 INSTALL.X11 ${RELEASEDIR}/${MACHINE}
142.endif
143.if defined(METALOG.add) && !exists(${DESTDIR}/etc)
144	cd ${NETBSDSRCDIR}/distrib/sets && \
145	    sh ./maketars -x -d ${DESTDIR:S,^$,/,} -N ${NETBSDSRCDIR}/etc -t ${RELEASEDIR}/${MACHINE}/binary/sets
146.else
147	cd ${NETBSDSRCDIR}/distrib/sets && \
148	    sh ./maketars -x -d ${DESTDIR:S,^$,/,} -t ${RELEASEDIR}/${MACHINE}/binary/sets
149.endif
150	cd ${RELEASEDIR}/${MACHINE}/binary/sets && \
151		cksum -o 1 *.tgz >BSDSUM && \
152		cksum *.tgz >CKSUM && \
153		cksum -m *.tgz >MD5 && \
154		cksum -o 2 *.tgz >SYSVSUM
155#
156.endif # DESTDIR and RELEASEDIR check
157