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