Makefile revision 1.16
1#	$OpenBSD: Makefile,v 1.16 1997/04/18 06:47:08 deraadt 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 defined(KERBEROS)
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	(cd ${.CURDIR}/share/mk && ${MAKE} install)
63	(cd ${.CURDIR}/include; ${MAKE} includes)
64	${MAKE} cleandir
65	(cd ${.CURDIR}/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
66	(cd ${.CURDIR}/gnu/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
67.if (${MACHINE_ARCH} == "mips")
68	ldconfig
69.endif
70.if defined(KERBEROS)
71	(cd ${.CURDIR}/kerberosIV && ${MAKE} build)
72.endif
73	${MAKE} depend && ${MAKE} && ${MAKE} install
74
75.if !defined(TARGET)
76cross-tools:
77	echo "TARGET must be set"; exit 1
78.else
79cross-tools:	cross-helpers cross-includes cross-binutils cross-gcc
80
81CROSSDIR=	${DESTDIR}/usr/cross/${TARGET}
82
83cross-helpers:
84	-mkdir -p ${CROSSDIR}/usr/include
85	echo _MACHINE_ARCH | \
86	    cat ${.CURDIR}/sys/arch/${TARGET}/include/param.h - | \
87	    ${CPP} -E |sed -n '$$p' >${CROSSDIR}/TARGET_ARCH
88	eval `grep '^osr=' sys/conf/newvers.sh`; \
89	   sed "s/\$$/-unknown-openbsd$$osr/" ${CROSSDIR}/TARGET_ARCH > \
90	   ${CROSSDIR}/TARGET_CANON
91
92cross-includes:
93	${MAKE} MACHINE=${TARGET} MACHINE_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` \
94	    DESTDIR=${CROSSDIR} includes
95
96cross-binutils:
97	-mkdir -p ${CROSSDIR}/usr/obj
98	export BSDSRCDIR=`pwd`; \
99	    (cd ${.CURDIR}/gnu/usr.bin/binutils; \
100	    BSDOBJDIR=${CROSSDIR}/usr/obj \
101	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
102	    ${MAKE} -f Makefile.bsd-wrapper obj); \
103	    (cd ${CROSSDIR}/usr/obj/gnu/usr.bin/binutils; \
104	    ${BSDSRCDIR}/gnu/usr.bin/binutils/configure \
105	    --prefix ${CROSSDIR}/usr \
106	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
107	    ${MAKE} && ${MAKE} install)
108	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 755 \
109	    ${.CURDIR}/usr.bin/lorder/lorder.sh.gnm \
110	    ${CROSSDIR}/usr/bin/`cat ${CROSSDIR}/TARGET_CANON`-lorder
111
112cross-gcc:
113	-mkdir -p ${CROSSDIR}/usr/obj
114	(cd gnu/usr.bin/gcc; \
115	    BSDOBJDIR=${CROSSDIR}/usr/obj BSDSRCDIR=${.CURDIR} \
116	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
117	    ${MAKE} -f Makefile.bsd-wrapper obj)
118	(cd ${CROSSDIR}/usr/obj/gnu/usr.bin/gcc; \
119	    ${.CURDIR}/gnu/usr.bin/gcc/configure \
120	    --prefix ${CROSSDIR}/usr \
121	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
122	    ${MAKE} BISON=yacc LANGUAGES=c \
123	    GCC_FOR_TARGET="./xgcc -B./ -I${CROSSDIR}/usr/include" && \
124	    ${MAKE} LANGUAGES=c install)
125.endif
126
127.include <bsd.subdir.mk>
128