summaryrefslogtreecommitdiff
path: root/Makefile
blob: d4293b619f669b57400a05904d813add6c541f48 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#	$OpenBSD: Makefile,v 1.15 1997/02/28 23:22:07 niklas Exp $
#	$NetBSD: Makefile,v 1.25 1995/10/09 02:11:28 thorpej Exp $

.include <bsd.own.mk>	# for NOMAN, if it's there.

# NOTE THAT etc *DOES NOT* BELONG IN THE LIST BELOW

SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share games
SUBDIR+= gnu

SUBDIR+= sys lkm

.if defined(KERBEROS)
SUBDIR+= kerberosIV
.endif

.if exists(regress)
.ifmake !(install)
SUBDIR+= regress
.endif

regression-tests:
	@echo Running regression tests...
	@(cd ${.CURDIR}/regress && ${MAKE} regress)
.endif

includes:
	(cd ${.CURDIR}/include; ${MAKE} includes)	

beforeinstall:
.ifndef DESTDIR
	(cd ${.CURDIR}/etc && ${MAKE} DESTDIR=/ distrib-dirs)
.else
	(cd ${.CURDIR}/etc && ${MAKE} distrib-dirs)
.endif
	(cd ${.CURDIR}/include; ${MAKE} includes)

afterinstall:
.ifndef NOMAN
	(cd ${.CURDIR}/share/man && ${MAKE} makedb)
.endif

build:
	(cd ${.CURDIR}/share/mk && ${MAKE} install)
	(cd ${.CURDIR}/include; ${MAKE} includes)
	${MAKE} cleandir
	(cd ${.CURDIR}/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
	(cd ${.CURDIR}/gnu/lib && ${MAKE} depend && ${MAKE} && ${MAKE} install)
.if (${MACHINE_ARCH} == "mips")
	ldconfig
.endif
.if defined(KERBEROS)
	(cd ${.CURDIR}/kerberosIV && ${MAKE} build)
.endif
	${MAKE} depend && ${MAKE} && ${MAKE} install

.if !defined(TARGET)
cross-tools:
	echo "TARGET must be set"; exit 1
.else
cross-tools:	cross-helpers cross-includes cross-binutils cross-gcc

CROSSDIR=	${DESTDIR}/usr/cross/${TARGET}

cross-helpers:
	-mkdir -p ${CROSSDIR}/usr/include
	echo _MACHINE_ARCH | \
	    cat ${.CURDIR}/sys/arch/${TARGET}/include/param.h - | \
	    ${CPP} -E |sed -n '$$p' >${CROSSDIR}/TARGET_ARCH
	eval `grep '^osr=' sys/conf/newvers.sh`; \
	   sed "s/\$$/-unknown-openbsd$$osr/" ${CROSSDIR}/TARGET_ARCH > \
	   ${CROSSDIR}/TARGET_CANON

cross-includes:
	${MAKE} MACHINE=${TARGET} MACHINE_ARCH=`cat ${CROSSDIR}/TARGET_ARCH` \
	    DESTDIR=${CROSSDIR} includes

cross-binutils:
	-mkdir -p ${CROSSDIR}/usr/obj
	export BSDSRCDIR=`pwd`; \
	    (cd ${.CURDIR}/gnu/usr.bin/binutils; \
	    BSDOBJDIR=${CROSSDIR}/usr/obj \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    ${MAKE} -f Makefile.bsd-wrapper obj); \
	    (cd ${CROSSDIR}/usr/obj/gnu/usr.bin/binutils; \
	    ${BSDSRCDIR}/gnu/usr.bin/binutils/configure \
	    --prefix ${CROSSDIR}/usr \
	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
	    ${MAKE} && ${MAKE} install)
	${INSTALL} -c -o ${BINOWN} -g ${BINGRP} -m 755 \
	    ${.CURDIR}/usr.bin/lorder/lorder.sh.gnm \
	    ${CROSSDIR}/usr/bin/`cat ${CROSSDIR}/TARGET_CANON`-lorder

cross-gcc:
	-mkdir -p ${CROSSDIR}/usr/obj
	(cd gnu/usr.bin/gcc; \
	    BSDOBJDIR=${CROSSDIR}/usr/obj BSDSRCDIR=${.CURDIR} \
	    MAKEOBJDIR=obj.${MACHINE}.${TARGET} \
	    ${MAKE} -f Makefile.bsd-wrapper obj)
	(cd ${CROSSDIR}/usr/obj/gnu/usr.bin/gcc; \
	    ${.CURDIR}/gnu/usr.bin/gcc/configure \
	    --prefix ${CROSSDIR}/usr \
	    --target `cat ${CROSSDIR}/TARGET_CANON` && \
	    ${MAKE} BISON=yacc LANGUAGES=c \
	    GCC_FOR_TARGET="./xgcc -B./ -I${CROSSDIR}/usr/include" && \
	    ${MAKE} LANGUAGES=c install)
.endif

.include <bsd.subdir.mk>