aboutsummaryrefslogtreecommitdiff
path: root/release/Makefile.arm
blob: 8bc58a89327ad52906bce3d504ca49c84bffd7ac (plain) (blame)
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
110
111
112
113
114
115
116
117
118
#
# $FreeBSD$
#

BOARDS?=	BEAGLEBONE \
		RPI-B \
		PANDABOARD \
		WANDBOARD-QUAD \
		ZEDBOARD

ARMTARGETS?=
ARMSIZE?=	1G
BOOTSIZE?=	4m
ARM_WFLAGS?=	CROSS_TOOLCHAIN=armv6-gcc
ARMPORTS?=

WITH_ARM_IMAGES?=1
CLEANFILES+=	arm-all

.if defined(WITH_ARM_IMAGES) && !empty(WITH_ARM_IMAGES) && !empty(BOARDS)
. for BOARD in ${BOARDS}
ARMTARGETS+=		arm-${BOARD:tl}
ARMBEFORECLEAN+=	arm-mdclean${BOARD:tl}
CLEANDIRS+=		arm-${BOARD:tl} \
			arm-${BOARD:tl}-boot
CLEANFILES+=		arm-buildworld${BOARD:tl} \
			arm-buildkernel${BOARD:tl} \
			arm-installworld${BOARD:tl} \
			arm-installkernel${BOARD:tl} \
			${${BOARD:tu}IMAGE} \
			${${BOARD:tu}MDDEV} \
			${${BOARD:tu}MDFILE} \
			${${BOARD:tu}BOOTDEV} \
			${${BOARD:tu}BOOTFILE} \
			build-arm-${BOARD:tl} \
			build-arm-ports${BOARD:tl}
${BOARD:tu}IMAGE=	arm-${BOARD:tu}.img
${BOARD:tu}MDDEV=	arm-${BOARD:tu}.mddev
${BOARD:tu}MDFILE=	arm-${BOARD:tu}.raw
${BOARD:tu}BOOTDEV=	arm-${BOARD:tu}.bootdev
${BOARD:tu}BOOTFILE=	arm-${BOARD:tu}.boot
.  if exists(${.CURDIR}/arm/Makefile.${BOARD})
.   include "${.CURDIR}/arm/Makefile.${BOARD}"
.  endif

arm-mdclean${BOARD:tl}:
.if exists(${${BOARD:tu}MDDEV})
	umount ${${BOARD:tu}MDFILE} || true
	mdconfig -d -u $$(cat ${${BOARD:tu}MDDEV})
.endif
.if exists(${${BOARD:tu}BOOTDEV})
	umount ${${BOARD:tu}BOOTFILE} || true
	mdconfig -d -u $$(cat ${${BOARD:tu}BOOTDEV})
.endif

arm-${BOARD:tl}: arm-buildworld${BOARD:tl} arm-buildkernel${BOARD:tl} \
	arm-installworld${BOARD:tl} arm-installkernel${BOARD:tl}
	${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} build-${.TARGET}

arm-buildworld${BOARD:tl}:
	@echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
		buildworld
	touch ${.TARGET}

arm-buildkernel${BOARD:tl}:
	@echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
		KERNCONF=${BOARD} buildkernel
	touch ${.TARGET}

arm-installworld${BOARD:tl}: arm-mkfs${BOARD:tl}
	@echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
		DESTDIR=${.OBJDIR}/arm-${BOARD:tl} installworld distribution
	touch ${.TARGET}

arm-installkernel${BOARD:tl}:
	@echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
		DESTDIR=${.OBJDIR}/arm-${BOARD:tl} KERNCONF=${BOARD} \
		installkernel
	touch ${.TARGET}

arm-mkfs${BOARD:tl}:
.if !exists(${${BOARD:tu}MDDEV})
	mkdir -p ${.OBJDIR}/arm-${BOARD:tl}
	truncate -s ${ARMSIZE} ${.OBJDIR}/${${BOARD:tu}MDFILE}
	echo $$(mdconfig -f ${.OBJDIR}/${${BOARD:tu}MDFILE}) > \
		${.OBJDIR}/${${BOARD:tu}MDDEV}
	newfs -S 4096 /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}MDDEV})
	mount /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}MDDEV}) \
		${.OBJDIR}/arm-${BOARD:tl}
.endif
.if !exists(${${BOARD:tu}BOOTDEV})
	mkdir -p ${.OBJDIR}/arm-${BOARD:tl}-boot
	truncate -s ${BOOTSIZE} ${.OBJDIR}/${${BOARD:tu}BOOTFILE}
	echo $$(mdconfig -f ${.OBJDIR}/${${BOARD:tu}BOOTFILE}) > \
		${.OBJDIR}/${${BOARD:tu}BOOTDEV}
	newfs_msdos -S 4096 /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}BOOTDEV})
	mount /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}BOOTDEV}) \
		${.OBJDIR}/arm-${BOARD:tl}-boot
.endif

build-arm-ports${BOARD:tl}:
.  if defined(ARMPORTS) && !empty(ARMPORTS)
.   if !exists(${PORTSDIR}/Makefile)
.    error "Ports tree (${PORTSDIR}) is required."
.   endif
.   for AP in ${ARMPORTS}
	@echo ${MAKE} -C ${PORTSDIR}/${AP} all install clean distclean
.   endfor
.  endif
	touch ${.TARGET}

. endfor		# main loop
.endif			# !WITH_ARM_IMAGES

beforeclean: ${ARMBEFORECLEAN}

arm-all: ${ARMTARGETS}
	touch ${.TARGET}