Makefile revision 1.20
1#	$OpenBSD: Makefile,v 1.20 1997/07/29 04:07:35 kstailey Exp $
2#	$NetBSD: Makefile,v 1.25 1995/10/09 02:11:28 thorpej Exp $
3
4#
5# For more information on building in tricky environments, please see
6# the list of possible environment variables described in
7# /usr/share/mk/bsd.README.
8# 
9# Building recommendations:
10# 
11# 1) If at all possible, put this source tree in /usr/src.  If /usr/src
12# must be a symbolic link, setenv BSDSRCDIR to point to the real location.
13#
14# 2) It is also recommended that you compile with objects outside the
15# source tree. To do this, ensure /usr/obj exists or points to some
16# area of disk of sufficient size.  Then do "cd /usr/src; make obj".
17# This will make a symbolic link called "obj" in each directory, as
18# well as populate the /usr/obj properly with directories for the
19# objects.
20#
21# 3) If you are reasonably sure that things will compile OK, use the
22# "make build" target supplied here. Good luck.
23
24.include <bsd.own.mk>	# for NOMAN, if it's there.
25
26SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games
27SUBDIR+= gnu
28
29SUBDIR+= sys lkm
30
31.if (${KERBEROS} == "yes")
32SUBDIR+= kerberosIV
33.endif
34
35.if exists(regress)
36.ifmake !(install)
37SUBDIR+= regress
38.endif
39
40regression-tests:
41	@echo Running regression tests...
42	@(cd ${.CURDIR}/regress && ${MAKE} regress)
43.endif
44
45includes:
46	(cd ${.CURDIR}/include; ${MAKE} includes)	
47
48beforeinstall:
49.ifndef DESTDIR
50	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
51.else
52	(cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
53.endif
54	(cd ${.CURDIR}/include; ${MAKE} includes)
55
56afterinstall:
57.ifndef NOMAN
58	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
59.endif
60
61build:
62.ifdef GLOBAL_AUTOCONF_CACHE
63	rm -f ${GLOBAL_AUTOCONF_CACHE}
64.endif
65	(cd ${.CURDIR}/share/mk && ${MAKE} install)
66	(cd ${.CURDIR}/include; ${MAKE} includes)
67	${MAKE} cleandir
68	(cd ${.CURDIR}/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
69	(cd ${.CURDIR}/gnu/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
70.if (${MACHINE_ARCH} == "mips")
71	ldconfig
72.endif
73.if (${KERBEROS} == "yes")
74	(cd ${.CURDIR}/kerberosIV && ${MAKE} build)
75.endif
76	${MAKE} depend && ${MAKE} && ${MAKE} install
77
78.if !defined(TARGET)
79cross-tools:
80	echo "TARGET must be set"; exit 1
81.else
82cross-tools:	cross-helpers cross-includes cross-binutils cross-gcc
83
84CROSSDIR=	${DESTDIR}/usr/cross/${TARGET}
85
86cross-helpers:
87	-mkdir -p ${CROSSDIR}/usr/include
88	echo _MACHINE_ARCH | \
89	    cat ${.CURDIR}/sys/arch/${TARGET}/include/param.h - | \
90	    ${CPP} -E |sed -n '$$p' >${CROSSDIR}/TARGET_ARCH
91	eval `grep '^osr=' sys/conf/newvers.sh`; \
92	   sed "s/\$$/-unknown-openbsd$$osr/" ${CROSSDIR}/TARGET_ARCH > \
93	   ${CROSSDIR}/TARGET_CANON
94
95cross-includes:
96	${MAKE} MACHINE=${TARGET} MACHINE_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` \
97	    DESTDIR=${CROSSDIR} includes
98
99cross-binutils:
100	-mkdir -p ${CROSSDIR}/usr/obj
101	export BSDSRCDIR=`pwd`; \
102	    (cd ${.CURDIR}/gnu/usr.bin/binutils; \
103	    BSDOBJDIR=${CROSSDIR}/usr/obj \
104	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
105	    ${MAKE} -f Makefile.bsd-wrapper obj); \
106	    (cd ${CROSSDIR}/usr/obj/gnu/usr.bin/binutils; \
107	    ${BSDSRCDIR}/gnu/usr.bin/binutils/configure \
108	    --prefix ${CROSSDIR}/usr \
109	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
110	    ${MAKE} && ${MAKE} install)
111	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 755 \
112	    ${.CURDIR}/usr.bin/lorder/lorder.sh.gnm \
113	    ${CROSSDIR}/usr/bin/`cat ${CROSSDIR}/TARGET_CANON`-lorder
114
115cross-gcc:
116	-mkdir -p ${CROSSDIR}/usr/obj
117	(cd gnu/usr.bin/gcc; \
118	    BSDOBJDIR=${CROSSDIR}/usr/obj BSDSRCDIR=${.CURDIR} \
119	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
120	    ${MAKE} -f Makefile.bsd-wrapper obj)
121	(cd ${CROSSDIR}/usr/obj/gnu/usr.bin/gcc; \
122	    ${.CURDIR}/gnu/usr.bin/gcc/configure \
123	    --prefix ${CROSSDIR}/usr \
124	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
125	    ${MAKE} BISON=yacc LANGUAGES=c \
126	    GCC_FOR_TARGET="./xgcc -B./ -I${CROSSDIR}/usr/include" && \
127	    ${MAKE} LANGUAGES=c install)
128.endif
129
130.include <bsd.subdir.mk>
131