Ensure resolv.conf exists on the build host before attempting
[freebsd.git] / release / Makefile.arm
1 #
2 # $FreeBSD$
3 #
4
5 BOARDS?=        BEAGLEBONE \
6                 RPI-B \
7                 PANDABOARD \
8                 WANDBOARD-QUAD \
9                 ZEDBOARD
10
11 ARMTARGETS?=
12 ARMSIZE?=       1G
13 BOOTSIZE?=      4m
14 ARM_WFLAGS?=    CROSS_TOOLCHAIN=armv6-gcc
15 ARMPORTS?=
16
17 WITH_ARM_IMAGES?=1
18 CLEANFILES+=    arm-all
19
20 .if defined(WITH_ARM_IMAGES) && !empty(WITH_ARM_IMAGES) && !empty(BOARDS)
21 . for BOARD in ${BOARDS}
22 ARMTARGETS+=            arm-${BOARD:tl}
23 ARMBEFORECLEAN+=        arm-mdclean${BOARD:tl}
24 CLEANDIRS+=             arm-${BOARD:tl} \
25                         arm-${BOARD:tl}-boot
26 CLEANFILES+=            arm-buildworld${BOARD:tl} \
27                         arm-buildkernel${BOARD:tl} \
28                         arm-installworld${BOARD:tl} \
29                         arm-installkernel${BOARD:tl} \
30                         ${${BOARD:tu}IMAGE} \
31                         ${${BOARD:tu}MDDEV} \
32                         ${${BOARD:tu}MDFILE} \
33                         ${${BOARD:tu}BOOTDEV} \
34                         ${${BOARD:tu}BOOTFILE} \
35                         build-arm-${BOARD:tl} \
36                         build-arm-ports${BOARD:tl}
37 ${BOARD:tu}IMAGE=       arm-${BOARD:tu}.img
38 ${BOARD:tu}MDDEV=       arm-${BOARD:tu}.mddev
39 ${BOARD:tu}MDFILE=      arm-${BOARD:tu}.raw
40 ${BOARD:tu}BOOTDEV=     arm-${BOARD:tu}.bootdev
41 ${BOARD:tu}BOOTFILE=    arm-${BOARD:tu}.boot
42 .  if exists(${.CURDIR}/arm/Makefile.${BOARD})
43 .   include "${.CURDIR}/arm/Makefile.${BOARD}"
44 .  endif
45
46 arm-mdclean${BOARD:tl}:
47 .if exists(${${BOARD:tu}MDDEV})
48         umount ${${BOARD:tu}MDFILE} || true
49         mdconfig -d -u $$(cat ${${BOARD:tu}MDDEV})
50 .endif
51 .if exists(${${BOARD:tu}BOOTDEV})
52         umount ${${BOARD:tu}BOOTFILE} || true
53         mdconfig -d -u $$(cat ${${BOARD:tu}BOOTDEV})
54 .endif
55
56 arm-${BOARD:tl}: arm-buildworld${BOARD:tl} arm-buildkernel${BOARD:tl} \
57         arm-installworld${BOARD:tl} arm-installkernel${BOARD:tl}
58         ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} build-${.TARGET}
59
60 arm-buildworld${BOARD:tl}:
61         @echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
62                 buildworld
63         touch ${.TARGET}
64
65 arm-buildkernel${BOARD:tl}:
66         @echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
67                 KERNCONF=${BOARD} buildkernel
68         touch ${.TARGET}
69
70 arm-installworld${BOARD:tl}: arm-mkfs${BOARD:tl}
71         @echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
72                 DESTDIR=${.OBJDIR}/arm-${BOARD:tl} installworld distribution
73         touch ${.TARGET}
74
75 arm-installkernel${BOARD:tl}:
76         @echo ${MAKE} -C ${.CURDIR} ${.MAKEFLAGS} ${ARM_WFLAGS} \
77                 DESTDIR=${.OBJDIR}/arm-${BOARD:tl} KERNCONF=${BOARD} \
78                 installkernel
79         touch ${.TARGET}
80
81 arm-mkfs${BOARD:tl}:
82 .if !exists(${${BOARD:tu}MDDEV})
83         mkdir -p ${.OBJDIR}/arm-${BOARD:tl}
84         truncate -s ${ARMSIZE} ${.OBJDIR}/${${BOARD:tu}MDFILE}
85         echo $$(mdconfig -f ${.OBJDIR}/${${BOARD:tu}MDFILE}) > \
86                 ${.OBJDIR}/${${BOARD:tu}MDDEV}
87         newfs -S 4096 /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}MDDEV})
88         mount /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}MDDEV}) \
89                 ${.OBJDIR}/arm-${BOARD:tl}
90 .endif
91 .if !exists(${${BOARD:tu}BOOTDEV})
92         mkdir -p ${.OBJDIR}/arm-${BOARD:tl}-boot
93         truncate -s ${BOOTSIZE} ${.OBJDIR}/${${BOARD:tu}BOOTFILE}
94         echo $$(mdconfig -f ${.OBJDIR}/${${BOARD:tu}BOOTFILE}) > \
95                 ${.OBJDIR}/${${BOARD:tu}BOOTDEV}
96         newfs_msdos -S 4096 /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}BOOTDEV})
97         mount_msdosfs /dev/$$(cat ${.OBJDIR}/${${BOARD:tu}BOOTDEV}) \
98                 ${.OBJDIR}/arm-${BOARD:tl}-boot
99 .endif
100
101 arm-mkimage${BOARD:tl}:
102 .if exists(/dev/$$(cat ${.OBJDIR}/${${BOARD:tu}BOOTDEV})
103         umount ${.OBJDIR}/arm-${BOARD:tl}-boot
104 .endif
105 .if exists(/dev/$$(cat ${.OBJDIR}/${${BOARD:tu}MDDEV})
106         umount ${.OBJDIR}/arm-${BOARD:tl}
107 .endif
108 # FIXME:
109 # Do these things need to be MBR?
110 # I'm also not entirely sure this is correct, anyway.
111 #
112         mkimg -s ${${BOARD}PARTSCHEME} \
113                 -b ${${BOARD:tu}BOOTFILE} \
114                 -p freebsd/rootfs:=${${BOARD:tu}MDFILE} \
115                 -o ${${BOARD:tu}IMAGE}
116
117 build-arm-ports${BOARD:tl}:
118 .  if defined(ARMPORTS) && !empty(ARMPORTS)
119 .   if !exists(${PORTSDIR}/Makefile)
120 .    error "Ports tree (${PORTSDIR}) is required."
121 .   endif
122 .   for AP in ${ARMPORTS}
123         @echo ${MAKE} -C ${PORTSDIR}/${AP} all install clean distclean
124 .   endfor
125 .  endif
126         touch ${.TARGET}
127
128 . endfor                # main loop
129 .endif                  # !WITH_ARM_IMAGES
130
131 beforeclean: ${ARMBEFORECLEAN}
132
133 arm-all: ${ARMTARGETS}
134         touch ${.TARGET}