summaryrefslogtreecommitdiff
path: root/release/tool-Makefile
blob: 375042e440e306408d364b97a30515e9d901eaa5 (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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# Makefile for hurd image frobnication.

export GNUTARGET=elf32-i386
export OBJCOPY=i386-gnu-objcopy

BF=bfloppy-image
RF=rfloppy-image

bfloppy-files = $(bfloppy-bootfs:%=hurd/%) $(bfloppy-bootprogs:%=boot/%) \
	       lib/ld.so boot/servers.boot
bfloppy-bootfs = ufs
bfloppy-bootprogs = kernel bootstrap

$(BF)/boot/servers.boot: hurd-image/boot/floppy.boot
	-rm -f $@
	@test -d $(@D) || mkdir -p $(@D)
	cp $< $@

$(BF)/%/: hurd-image/%/
	test -d $@ || mkdir -p $@
$(BF)/%: hurd-image/%
	-rm -f $@
	@test -d $(@D) || mkdir -p $(@D)
	ln $< $@ || cp $< $@

$(BF): $(bfloppy-files:%=$(BF)/%)
$(BF).tar: $(bfloppy-files:%=$(BF)/%)
	rm -f $@
	cd $(BF); tar covf ../$@ $(^:$(BF)/%=%)

rfloppy-files = $(rfloppy-hurd:%=hurd/%) $(rfloppy-progs:%=bin/%) \
	        $(rfloppy-solib:%=lib/%.so) hurd/exec \
	        lib/libc.so lib/libhurduser.so lib/libmachuser.so \
		servers/exec servers/socket/1 \
	        README tmp/ dev/MAKEDEV
rfloppy-hurd = auth devio null init proc term
rfloppy-progs = sh ls cat settrans # mkfs
rfloppy-solib = libtrivfs libthreads libshouldbeinlibc libports	\
	       libpager libioserver libihash libfshelp ld

libc-satisfies = $(rfloppy-hurd:%=hurd/%) $(rfloppy-progs:%=bin/%) $(rfloppy-solib:%=lib/%.so)

libc-obj-dir = /gd4/gnu/libc/i386
smallso-LDFLAGS = -Wl,-rpath-link=/lib

libc-USERS =
libc-DEPS =

$(RF)/lib/libc.so: hurd-image/lib/libc.so hurd-image/lib/libhurduser.so hurd-image/lib/libmachuser.so $(libc-satisfies:%=hurd-image/%)
	mksmallso $(smallso-LDFLAGS) \
	  $@ $(libc-obj-dir)/libc_pic.a '-Lhurd-image/lib -lhurduser -lmachuser' \
	  $(filter-out $(firstword $^),$^)

$(RF)/lib/libhurduser.so: $(RF)/lib/libc.so $(libc-satisfies:%=hurd-image/%)
	mksmallso $(smallso-LDFLAGS) $@ $(libc-obj-dir)/libhurduser_pic.a -Lhurd-image/lib -lmachuser $(filter-out $(firstword $^),$^)

$(RF)/lib/libmachuser.so: $(RF)/lib/libc.so $(RF)/lib/libhurduser.so $(libc-satisfies:%=hurd-image/%)
	mksmallso $(smallso-LDFLAGS) $@ $(libc-obj-dir)/libmachuser_pic.a '' $(filter-out $(firstword $^),$^)

$(addprefix $(RF)/,$(rfloppy-hurd:%=hurd/%) $(rfloppy-progs:%=bin/%)): \
  $(RF)/%: hurd-image/%
	@test -d $(@D) || mkdir -p $(@D)
	gzip -9v -c $< > $@.new
	chmod 555 $@.new
	mv -f $@.new $@

$(RF)/%/: hurd-image/%/
	test -d $@ || mkdir -p $@
$(RF)/%: hurd-image/%
	-rm -f $@
	@test -d $(@D) || mkdir -p $(@D)
	ln $< $@ || cp $< $@

$(RF): $(rfloppy-files:%=$(RF)/%)
$(RF).tar: $(rfloppy-files:%=$(RF)/%)
	rm -f $@
	cd $(RF); tar covf ../$@ $(^:$(RF)/%=%)

MOUNT_POINT = /mnt
VND = vnd0
VND_DEV = /dev/${VND}a
VND_RDEV = /dev/r${VND}a
MDEC = /usr/mdec

floppy%-image.fs: /tmp/floppy%-image.fs; cp -f $< $@

/tmp/floppy%-image.fs: floppy%-image.tar
	dd if=/dev/zero of=$@.new bs=10k count=144
	vnconfig -v -c ${VND_DEV} $@.new
	disklabel -w -B -b ${MDEC}/fdboot -s ${MDEC}/bootfd ${VND} floppy3
	newfs -O -m 0 -o space -i 5120 -c 80 ${VND_RDEV} floppy3
	mount ${VND_DEV} ${MOUNT_POINT}
	tar -f $< -C ${MOUNT_POINT} -xv
	df -i ${MOUNT_POINT}
	umount ${MOUNT_POINT}
	vnconfig -u ${VND_DEV} $@.new
	mv -f $@.new $@

hurd-image.tar: hurd-image hurd-image.stamp
	tar cof $@ $<

%.gz: %
	gzip -9v -c $< > $@.new
	mv -f $@.new $@

%:: %.gz
	gunzip -c $< > $@.new
	mv -f $@.new $@


instdirs := $(patsubst ../hurdinst/%,%,\
		       $(filter-out ../hurdinst,\
				    $(shell find ../hurdinst -type d -print \
					    | sort -r)))

hurd-image/%/.stamp: ../hurdinst/%
	@./install-stripped -N $@ $< $(@D)
	@echo $< `date` > $@
	@echo updated $(@D)/
hurd-image.stamp: $(instdirs:%=hurd-image/%/.stamp); touch $@
hurd-image: hurd-image.stamp