Makefile revision dabe2211
1#	$NetBSD: Makefile,v 1.41 2004/03/12 20:20:49 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 ${USE_XF86_4:Uno} != "no"
35XCDIR=	xfree/xc
36.else
37XCDIR=	xc
38.endif
39
40
41.MAIN: all
42.if ${USE_XF86_4:Uno} != "no"
43all: all-xc all-local
44.else
45all: all-xc all-contrib all-local
46.endif
47
48all-xc:
49.if exists(${XCDIR}/xmakefile) && defined(UPDATE)
50	@cd ${XCDIR} && ${MAKE} Everything
51.else
52	@-rm -f ${XCDIR}/xmakefile
53	@cd ${XCDIR} && ${MAKE} World
54.endif
55
56all-contrib:
57	@if [ ! -f contrib/Makefile ]; then \
58	  cd contrib && PATH=../${XCDIR}/config/imake:$$PATH \
59	    sh ../${XCDIR}/config/util/xmkmf -a ../${XCDIR} \
60	       ${.CURDIR}/contrib; \
61	fi
62	@cd contrib && ${MAKE}
63
64all-local:
65	@if [ ! -f local/Makefile ]; then \
66	  cd local && PATH=../${XCDIR}/config/imake:$$PATH \
67	    sh ../${XCDIR}/config/util/xmkmf -a ../${XCDIR} \
68	      ${.CURDIR}/local; \
69	fi
70	@cd local && ${MAKE}
71
72.if ${USE_XF86_4:Uno} != "no"
73install: install-xc install-local
74.else
75install: install-xc install-contrib install-local
76.endif
77
78install-xc:
79	@cd ${XCDIR} && \
80	  ${MAKE} DESTDIR="${DESTDIR}" install && \
81	  ${MAKE} DESTDIR="${DESTDIR}" install.man
82
83install-contrib:
84	@cd contrib && \
85	  ${MAKE} DESTDIR="${DESTDIR}" install && \
86	  ${MAKE} DESTDIR="${DESTDIR}" install.man
87
88install-local:
89	@cd local && \
90	  ${MAKE} DESTDIR="${DESTDIR}" install && \
91	  ${MAKE} DESTDIR="${DESTDIR}" install.man
92
93clean:
94.if ${USE_XF86_4:Uno} != "no"
95	@-cd ${XCDIR} && ${MAKE} clean
96	@-cd local && ${MAKE} clean
97.else
98	@-cd ${XCDIR} && ${MAKE} clean
99	@-cd contrib && ${MAKE} clean
100	@-cd local && ${MAKE} clean
101.endif
102
103cleandir distclean: clean
104	find ${XCDIR} contrib local -name .depend | xargs -n5 rm
105	find ${XCDIR} contrib local -name 'Makefile*' | \
106	    xargs -n5 grep -l "Makefile generated by imake" | xargs rm
107	-rmdir ${XCDIR}/exports
108	rm -f ${XCDIR}/xmakefile
109
110build:
111.if defined(UPDATE)
112	@${MAKE} all && ${MAKE} install
113.else
114	@${MAKE} cleandir && ${MAKE} all && ${MAKE} install
115.endif
116
117# release goo
118#
119.if !defined(DESTDIR)
120release snapshot:
121	@echo setenv DESTDIR before doing that!
122	@false
123.elif !defined(RELEASEDIR)
124release snapshot:
125	@echo setenv RELEASEDIR before doing that!
126	@false
127#
128.else
129#
130.if defined(INSTALL_DONE)
131release snapshot:
132.elif defined(BUILD_DONE)
133release snapshot: install
134.else
135release snapshot: build
136#
137.endif # INSTALL_DONE or BUILD_DONE
138#
139	${INSTALL} -d -m 755 -o root -g wheel ${RELEASEDIR}/${MACHINE}/binary/sets
140.if (${MACHINE} == "amiga") && ${USE_XF86_4:Uno} == "no"
141	cd ${XCDIR}/programs/Xserver/hw/netbsd/amiga && \
142		${INSTALL} -c -m 644 INSTALL.X11 ${RELEASEDIR}/${MACHINE}
143.endif
144	${INSTALL} -d -m 755 -o root -g wheel ${DESTDIR}/etc/mtree
145.if defined(METALOG.add) && !exists(${DESTDIR}/etc/master.passwd)
146	cd ${NETBSDSRCDIR}/distrib/sets && \
147	    sh ./maketars -x -d ${DESTDIR:S,^$,/,} -N ${NETBSDSRCDIR}/etc -t ${RELEASEDIR}/${MACHINE}/binary/sets
148.else
149	cd ${NETBSDSRCDIR}/distrib/sets && \
150	    sh ./maketars -x -d ${DESTDIR:S,^$,/,} -t ${RELEASEDIR}/${MACHINE}/binary/sets
151.endif
152	cd ${RELEASEDIR}/${MACHINE}/binary/sets && \
153		cksum -o 1 *.tgz >BSDSUM && \
154		cksum *.tgz >CKSUM && \
155		cksum -m *.tgz >MD5 && \
156		cksum -o 2 *.tgz >SYSVSUM
157#
158.endif # DESTDIR and RELEASEDIR check
159