Makefile 8.64 KB
Newer Older
Ryan Jackson's avatar
Ryan Jackson committed
1
2
3
4
include ../../variables.mk

BUILDROOT	:=	$(PWD)/$(BUILDROOT)

5
PROGS	:= imageunzip imagezip frisbee growdisk tmcc.bin binoffset groklilo teachswitch dhcp_packet_dump sethostname.dhclient
Ryan Jackson's avatar
Ryan Jackson committed
6
7
8
9
10
11
12
BUILD_TARGETS := $(PROGS)
INSTALL_TARGETS := $(addsuffix -install,$(PROGS))

.PHONY: clean
.PHONY: $(BUILD_TARGETS) all
.PHONY: $(INSTALL_TARGETS) script-install install

Ryan Jackson's avatar
Ryan Jackson committed
13
TESTBED_PATH = /home/rdjackso/gits/testbed
Ryan Jackson's avatar
Ryan Jackson committed
14
15
16
17
18
19
20
21
TESTBED_BUILD_PATH = $(TARGET_BUILD_PATH)/testbed
TMCD_PATH = $(TESTBED_PATH)/tmcd
GROKLILO_PATH = $(TESTBED_PATH)/cdrom/groklilo
GROWDISK_PATH = $(TESTBED_PATH)/os/growdisk
TESTBEDOBJ_PATH = /home/rdjackso/testbed-obj
FRISBEE_PATH = $(TESTBED_PATH)/os/frisbee.redux
BINOFFSET_PATH = $(TESTBED_PATH)/tools/binoffset
IMAGEZIP_PATH = $(TESTBED_PATH)/os/imagezip
Ryan Jackson's avatar
Ryan Jackson committed
22
TEACHSWITCH_PATH = $(TESTBED_PATH)/tools/teachswitch
23
DHCP_PACKET_DUMP_PATH = $(TESTBED_PATH)/tools/dhcp_packet_dump
Ryan Jackson's avatar
Ryan Jackson committed
24
25
26
CFLAGS = -Os

INSTALLED_BINS	:= $(addprefix $(TARGET_PATH)/usr/, \
27
			$(addprefix bin/, binoffset imagezip imageunzip tmcc.bin frisbee teachswitch dhcp_packet_dump) \
Ryan Jackson's avatar
Ryan Jackson committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
			$(addprefix sbin/, groklilo growdisk))

all: $(BUILD_TARGETS)

# Use GNU make's second-expansion feature to simplify the installed binary targets.
# This target needs to be declared here, so do not move it.
.SECONDEXPANSION:

$(BUILD_TARGETS): $(TESTBED_BUILD_PATH)/$$@

# Install all of the compiled binaries.  Put them in sane locations like
# /usr/bin and /usr/sbin, but put symlinks for them in $BINDIR for
# compatibility.
$(INSTALLED_BINS): $(TESTBED_BUILD_PATH)/$$(notdir $$@)
	mkdir -p $(dir $@)
	install -m 755 $< $@
	mkdir -p $(TARGET_PATH)/etc/testbed
	ln -sf $(subst $(TARGET_PATH),,$@) $(TARGET_PATH)/etc/testbed

47
script-install:
Ryan Jackson's avatar
Ryan Jackson committed
48
	mkdir -p $(TARGET_PATH)/etc/testbed
49
50
51
52
53
54
55
56
	mkdir -p $(TARGET_PATH)/etc/testbed/rc
	mkdir -p $(TARGET_PATH)/etc/emulab
	mkdir -p $(TARGET_PATH)/usr/bin
	mkdir -p $(TARGET_PATH)/usr/local/etc
	mkdir -p $(TARGET_PATH)/var/emulab/logs
	mkdir -p $(TARGET_PATH)/var/emulab/lock
	mkdir -p $(TARGET_PATH)/var/emulab/boot
	mkdir -p $(TARGET_PATH)/var/emulab/db
57
	mkdir -p $(TARGET_PATH)/usr/share/udhcpc
58
	rm -f $(TARGET_PATH)/usr/local/etc/emulab
59
	ln -sf /etc/testbed $(TARGET_PATH)/usr/local/etc/emulab
60
	install -m 755 $(TESTBED_BUILD_PATH)/sethostname.dhclient $(TARGET_PATH)/usr/share/udhcpc
Ryan Jackson's avatar
Ryan Jackson committed
61
	install -m 755 $(TMCD_PATH)/linux/control_interface $(TARGET_PATH)/etc/testbed
62
63
	install -m 755 $(TMCD_PATH)/linux/rc.frisbee $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/linux/rc.ipod $(TARGET_PATH)/etc/testbed/rc
Ryan Jackson's avatar
Ryan Jackson committed
64
65
	install -m 755 $(TMCD_PATH)/linux/slicefix $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/linux/freebsd_to_linux_disk $(TARGET_PATH)/etc/testbed
66
	install -m 755 $(TMCD_PATH)/linux/mount_bsd_slice $(TARGET_PATH)/etc/testbed
Ryan Jackson's avatar
Ryan Jackson committed
67
68
	install -m 755 $(TMCD_PATH)/linux/check_disklabel $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/linux/remap_ide_disks $(TARGET_PATH)/etc/testbed
Ryan Jackson's avatar
Ryan Jackson committed
69
70
71
72
73
	install -m 755 $(TMCD_PATH)/linux/get_edd_map.pl $(TARGET_PATH)/etc/testbed
	#install -m 755 $(TMCD_PATH)/linux/extract_kernel_info $(TARGET_PATH)/etc/testbed
	#install -m 755 $(TMCD_PATH)/linux/extract_image_info $(TARGET_PATH)/etc/testbed
	#install -m 755 $(TMCD_PATH)/linux/extract_initrd_info $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/linux/linux_slicefix.pl $(TARGET_PATH)/etc/testbed
Ryan Jackson's avatar
Ryan Jackson committed
74
	install -m 755 $(TESTBED_PATH)/install/newclient $(TARGET_PATH)/etc/testbed
Ryan Jackson's avatar
Ryan Jackson committed
75
	install -m 755 $(TMCD_PATH)/common/paths.sh $(TARGET_PATH)/etc/emulab
76
77
78
79
80
81
82
83
	install -m 755 $(TMCD_PATH)/common/paths.pm $(TARGET_PATH)/etc/emulab
	install -m 644 $(TMCD_PATH)/common/libsetup.pm $(TARGET_PATH)/etc/testbed
	install -m 644 $(TMCD_PATH)/common/libtestbed.pm $(TARGET_PATH)/etc/testbed
	install -m 644 $(TMCD_PATH)/common/libtmcc.pm $(TARGET_PATH)/etc/testbed
	install -m 644 $(TMCD_PATH)/linux/liblocsetup.pm $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/common/watchdog $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/common/update $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/common/tmcc.pl $(TARGET_PATH)/usr/bin/tmcc
Ryan Jackson's avatar
Ryan Jackson committed
84
	install -m 755 $(TMCD_PATH)/common/osconfig $(TARGET_PATH)/etc/testbed
85
86
87
	ln -sf /usr/bin/tmcc $(TARGET_PATH)/etc/testbed/tmcc
	install -m 755 $(TMCD_PATH)/common/config/librc.pm $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/common/config/rc.config $(TARGET_PATH)/etc/testbed/rc
88
	install -m 755 $(TMCD_PATH)/linux/rc.mfs $(TARGET_PATH)/etc/testbed/rc
89
90
91
92
93
94
	install -m 755 $(TMCD_PATH)/common/config/rc.misc $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/config/rc.localize $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/config/rc.mounts $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/config/rc.accounts $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/config/rc.hostnames $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/config/rc.keys $(TARGET_PATH)/etc/testbed/rc
95
96
97
98
99
100
	install -m 755 $(TMCD_PATH)/common/config/rc.startcmd $(TARGET_PATH)/etc/testbed/rc
	install -m 755 $(TMCD_PATH)/common/runstartup $(TARGET_PATH)/etc/testbed
	install -m 755 $(TMCD_PATH)/linux/create-image $(TARGET_PATH)/etc/testbed
	mkdir -p $(TARGET_PATH)/usr/local/bin
	ln -sf /usr/bin/imagezip $(TARGET_PATH)/usr/local/bin
	ln -sf /etc/testbed/create-image $(TARGET_PATH)/usr/local/bin
101
	touch $(TARGET_PATH)/etc/emulab/ismfs
Ryan Jackson's avatar
Ryan Jackson committed
102
103
104

imageunzip-install: $(TARGET_PATH)/usr/bin/imageunzip

Ryan Jackson's avatar
Ryan Jackson committed
105
106
imagezip-install: $(TARGET_PATH)/usr/bin/imagezip

Ryan Jackson's avatar
Ryan Jackson committed
107
108
109
110
111
112
113
114
frisbee-install: $(TARGET_PATH)/usr/bin/frisbee

growdisk-install: $(TARGET_PATH)/usr/sbin/growdisk

binoffset-install: $(TARGET_PATH)/usr/bin/binoffset

groklilo-install: $(TARGET_PATH)/usr/sbin/groklilo

115
tmcc.bin-install: $(TARGET_PATH)/usr/bin/tmcc.bin
Ryan Jackson's avatar
Ryan Jackson committed
116

Ryan Jackson's avatar
Ryan Jackson committed
117
118
teachswitch-install: $(TARGET_PATH)/usr/bin/teachswitch

119
120
dhcp_packet_dump-install: $(TARGET_PATH)/usr/bin/dhcp_packet_dump

Ryan Jackson's avatar
Ryan Jackson committed
121
122
123
124
125
clean:
		rm -rf $(TESTBED_BUILD_PATH)

install: $(INSTALL_TARGETS) script-install

126
127
128
129
130
$(TESTBED_BUILD_PATH)/sethostname.dhclient:
	mkdir -p $(TESTBED_BUILD_PATH)
	sed -e 's/@DISABLE_NAMED_SETUP@/0/g' \
	$(TMCD_PATH)/linux/sethostname.dhclient.in > $@

Ryan Jackson's avatar
Ryan Jackson committed
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
$(TESTBED_BUILD_PATH)/groklilo:
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
	-o $@ \
	$(GROKLILO_PATH)/groklilo.c
	$(STRIPCMD) --strip-unneeded $@

$(TESTBED_BUILD_PATH)/binoffset:
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
	-o $@ \
	$(BINOFFSET_PATH)/binoffset.c
	$(STRIPCMD) --strip-unneeded $@

$(TESTBED_BUILD_PATH)/growdisk:
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
		-o $@ \
		-I $(TESTBED_PATH)/os/imagezip \
		-Os \
		$(GROWDISK_PATH)/growdisk.c
	$(STRIPCMD) --strip-unneeded $@

Ryan Jackson's avatar
Ryan Jackson committed
157
158
159
160
161
162
163
164
165
$(TESTBED_BUILD_PATH)/teachswitch:
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
		-o $@ \
		-Os \
		$(TEACHSWITCH_PATH)/teachswitch.c
	$(STRIPCMD) --strip-unneeded $@

166
167
168
169
170
171
172
173
174
175
$(TESTBED_BUILD_PATH)/dhcp_packet_dump:
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
		-o $@ \
		-Os \
		-I$(DHCP_PACKET_DUMP_PATH) \
		$(DHCP_PACKET_DUMP_PATH)/dhcp_packet_dump.c
	$(STRIPCMD) --strip-unneeded $@

Ryan Jackson's avatar
Ryan Jackson committed
176
177
178
# ARGH! tmcc wants to link against libtb just for the errorc function in libtb/log.c.
# libtb in turn wants libmysql.  There's no point building all of libtb and its
# required libs under uclibc, so I'm going to skip the testbed makefiles and
179
# build tmcc here.
Ryan Jackson's avatar
Ryan Jackson committed
180

181
$(TESTBED_BUILD_PATH)/tmcc.bin:
Ryan Jackson's avatar
Ryan Jackson committed
182
183
184
185
	mkdir -p $(TESTBED_BUILD_PATH)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(CROSS_COMPILER_PREFIX)gcc \
		-o $@ \
186
		-I. \
Ryan Jackson's avatar
Ryan Jackson committed
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
		-I$(TESTBED_PATH)/lib/libtb \
		-Os \
		$(TESTBED_PATH)/tmcd/tmcc.c \
		$(TESTBED_PATH)/lib/libtb/log.c
	$(STRIPCMD) --strip-unneeded $@

$(TESTBED_BUILD_PATH)/frisbee: $(SYSROOT_ZLIB_SHARED)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(MAKE) -C $(FRISBEE_PATH) -f Makefile-linux.sa \
		CC=$(CROSS_COMPILER_PREFIX)gcc \
		PATH=$(STAGING_DIR)/usr/bin:$(PATH) frisbee
	mkdir -p $(dir $@)
	mv $(FRISBEE_PATH)/frisbee $@
	$(MAKE) -C $(FRISBEE_PATH) -f Makefile-linux.sa clean
	$(STRIPCMD) --strip-unneeded $@

$(TESTBED_BUILD_PATH)/imageunzip: $(SYSROOT_ZLIB_SHARED)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(MAKE) -C $(IMAGEZIP_PATH) -f Makefile-linux.sa \
		CC=$(CROSS_COMPILER_PREFIX)gcc \
		imageunzip
	mkdir -p $(dir $@)
	mv $(IMAGEZIP_PATH)/imageunzip $@
	$(MAKE) -C $(IMAGEZIP_PATH) -f Makefile-linux.sa clean
	$(STRIPCMD) --strip-unneeded $@

$(TESTBED_BUILD_PATH)/imagezip: $(SYSROOT_ZLIB_SHARED)
	PATH=$(STAGING_DIR)/usr/bin:$(PATH) \
	$(MAKE) -C $(IMAGEZIP_PATH) -f Makefile-linux.sa \
		CC=$(CROSS_COMPILER_PREFIX)gcc \
		PATH=$(STAGING_DIR)/usr/bin:$(PATH) imagezip
	mkdir -p $(dir $@)
Ryan Jackson's avatar
Ryan Jackson committed
219
220
	mv $(IMAGEZIP_PATH)/imagezip $@
	$(MAKE) -C $(IMAGEZIP_PATH) -f Makefile-linux.sa clean
Ryan Jackson's avatar
Ryan Jackson committed
221
222
	$(STRIPCMD) --strip-unneeded $@