forked from arnobroekhof/flashboot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
183 lines (146 loc) · 4.94 KB
/
Makefile
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# Adapted from distrib/i386/common/Makefile.inc:
# $OpenBSD: Makefile.inc,v 1.8 2002/09/23 18:31:03 markus Exp $
# NB. the disktab specified in ${DISKPROTO}, the ramdisk size specified in
# ${NBLKS} and the MINIROOTSIZE in the kernel config (${KERNEL}) must
# *ALL* match
ALL_KCONF= WRAP12 COMMELL-LE564 SOEKRIS4501 SOEKRIS4801 SOEKRIS5501 GENERIC-RD
KCONF= COMMELL-LE564
TTYSPEED= 19200
# WRAP has an even sillier default console speed than Soekris :)
.if ${KCONF} == "WRAP12"
TTYSPEED= 38400
.endif
# Change the default conspeed of Generic to 9600
.if ${KCONF} == "GENERIC-RD"
TTYSPEED= 9600
.endif
.include <bsd.own.mk>
# Build options
#NBLKS= 16384 # disktab.8mb
#NBLKS= 19456 # disktab.9.5mb
#NBLKS= 20480 # disktab.10mb
#NBLKS= 24576 # disktab.12mb
#NBLKS= 30720 # disktab.15mb
NBLKS= 98304 # disktab.48mb
NEWFSARGS= -m 0 -o space
KOPTS= #-Os
TERMTYPES= dumb unknown vt100 vt100-nav vt220 xterm xterm-new \
xterm-xfree86 cygwin gnome vt102 ansi screen
.PATH: ${.CURDIR}
TOP= ${.CURDIR}
# Local config files
KERNEL= ${.CURDIR}/${KCONF}
LIST= ${.CURDIR}/list
EXTRACONF= ${.CURDIR}/conf
#DISKPROTO= ${.CURDIR}/disktabs/disktab.8mb
#DISKPROTO= ${.CURDIR}/disktabs/disktab.9.5mb
#DISKPROTO= ${.CURDIR}/disktabs/disktab.10mb
#DISKPROTO= ${.CURDIR}/disktabs/disktab.12mb
#DISKPROTO= ${.CURDIR}/disktabs/disktab.15mb
DISKPROTO= ${.CURDIR}/disktabs/disktab.48mb
MTREE= ${DESTDIR}/etc/mtree/4.4BSD.dist
MTREE_CUST= ${.CURDIR}/mtree.conf
# Paths to various things, probably don't need to touch
MOUNT_POINT= /mnt
SRCDIR?= /usr/src
KSRC= ${SRCDIR}/sys
VND= vnd0
DESTDIR?= /
# Shouldn't need to touch these
IMAGE= mr.fs
CBIN= instbin
CRUNCHCONF= ${CBIN}.conf
UTILS= ${.CURDIR}/tools
VND_DEV= /dev/${VND}a
VND_RDEV= /dev/r${VND}a
PID!= echo $$$$
REALIMAGE!= echo /var/tmp/image.${PID}
all: bsd.gz
ls -l bsd.rd bsd.gz
everything:
set -xe ; for kconf in ${ALL_KCONF} ; do \
cd ${.CURDIR} && make cleandir ; \
cd ${.CURDIR} && make KCONF=$$kconf ; \
mv ${.OBJDIR}/bsd.gz ${.OBJDIR}/bsd.$$kconf ; \
done
bsd.gz: bsd.rd
gzip -c9 bsd.rd > bsd.gz
bsd.rd: termdefs bsd ${IMAGE} rdsetroot
cp bsd bsd.rd
${.OBJDIR}/rdsetroot bsd.rd < ${IMAGE}
bsd: ${KCONF}/bsd
cp ${KCONF}/bsd .
${KCONF}/bsd: ${KERNEL}
-test -f ${KCONF} && (echo ""; make clean obj; echo "Missing obj/ dir (created). Now rerun 'make'."; exit 1)
test -d ${KCONF} || mkdir ${KCONF}
cd ${KCONF} && config -s ${KSRC} -b . ${KERNEL}
cd ${KCONF} && make clean && make depend && COPTS="${KOPTS}" make
strip -g -X -x ${KCONF}/bsd
cp ${KCONF}/bsd .
${IMAGE}: ${CBIN} rd_setup do_files zerofill rd_teardown
rd_setup: ${CBIN}
dd if=/dev/zero of=${REALIMAGE} bs=512 count=${NBLKS}
${SUDO} vnconfig -v -c ${VND} ${REALIMAGE}
${SUDO} disklabel -R ${VND} ${DISKPROTO}
${SUDO} newfs ${NEWFSARGS} ${VND_RDEV}
${SUDO} fsck ${VND_RDEV}
${SUDO} mount ${VND_DEV} ${MOUNT_POINT}
rd_teardown:
@df -ki ${MOUNT_POINT}
-${SUDO} umount ${MOUNT_POINT}
-${SUDO} vnconfig -u ${VND}
${SUDO} cp ${REALIMAGE} ${IMAGE}
${SUDO} rm ${REALIMAGE}
rdsetroot: ${UTILS}/elfrdsetroot.c
${HOSTCC} -DDEBUG -o rdsetroot ${UTILS}/elfrdsetroot.c
unconfig:
-${SUDO} umount -f ${MOUNT_POINT}
-${SUDO} vnconfig -u ${VND}
.PRECIOUS: ${IMAGE}
${CBIN}.mk ${CBIN}.cache ${CBIN}.c: ${CRUNCHCONF}
crunchgen -E -D ${BSDSRCDIR} -L ${DESTDIR}/usr/lib \
-c ${CBIN}.c -e ${CBIN} -m ${CBIN}.mk ${CRUNCHCONF}
${CBIN}: ${CBIN}.mk ${CBIN}.cache ${CBIN}.c
make -f ${CBIN}.mk all
${CRUNCHCONF}: ${LIST}
awk -f ${UTILS}/makeconf.awk CBIN=${CBIN} ${LIST} > ${CRUNCHCONF}
do_files:
-${SUDO} mtree -def ${MTREE_CUST} -p ${MOUNT_POINT}/ -u
-${SUDO} mtree -def ${MTREE} -p ${MOUNT_POINT}/ -u
${SUDO} env \
TOPDIR=${TOP} CURDIR=${.CURDIR} OBJDIR=${.OBJDIR} SRCDIR=${SRCDIR} \
TARGDIR=${MOUNT_POINT} UTILS=${UTILS} DESTDIR=${DESTDIR} \
TTYSPEED=${TTYSPEED} \
sh ${UTILS}/runlist.sh ${LIST}
${SUDO} rm -f ${MOUNT_POINT}/${CBIN}
# Zero out unused space on virtual disk to help compression
zerofill:
-${SUDO} dd if=/dev/zero of=${MOUNT_POINT}/zero.temp >/dev/null 2>&1
-${SUDO} rm -f ${MOUNT_POINT}/zero.temp
# targets to build minimal termcap/terminfo databases
terminfo.mini:
-rm -f terminfo.mini
for termtype in ${TERMTYPES} ; do \
infocmp $$termtype >> terminfo.mini ;\
done
termcap.mini: terminfo.mini
infotocap terminfo.mini > termcap.mini
terminfo.db: terminfo.mini
cap_mkdb -i -f terminfo terminfo.mini
termcap.db: termcap.mini
cap_mkdb -f termcap termcap.mini
termdefs: termcap.db terminfo.db
rm -rf termdefs
mkdir -p termdefs/usr/share/misc
install -m 0444 termcap.mini termdefs/usr/share/misc/termcap
install -m 0444 termcap.db termdefs/usr/share/misc/termcap.db
install -m 0444 terminfo.db termdefs/usr/share/misc/terminfo.db
halfclean:
/bin/rm -f core ${IMAGE} ${CBIN} ${CBIN}.mk ${CBIN}*.cache \
*.o *.lo *.c bsd bsd.rd bsd.gz bsd.strip rdsetroot ${CRUNCHCONF} \
*.tar *.tgz
/bin/rm -rf term*
clean cleandir: halfclean
-test -d ${KCONF} && /bin/rm -rf ${KCONF}
.include <bsd.obj.mk>
.include <bsd.subdir.mk>