forked from sysml/mini-os
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stub.mk
665 lines (567 loc) · 21.7 KB
/
stub.mk
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
184
185
186
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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
################################################################################
# Essential definitions
################################################################################
ifndef XEN_ROOT
$(error "Please define XEN_ROOT")
endif
CONFIG_LWIP ?= n
ifeq ($(CONFIG_LWIP),y)
ifndef LWIP_ROOT
$(error "Please define LWIP_ROOT")
endif
endif
ifndef NEWLIB_ROOT
$(error "Please define NEWLIB_ROOT")
endif
verbose ?= n
debug ?= n
default: all
################################################################################
# Xen and build architecture
################################################################################
XEN_COMPILE_ARCH ?= $(shell uname -m | sed -e s/i.86/x86_32/ -e s/i86pc/x86_32/ -e s/amd64/x86_64/)
XEN_TARGET_ARCH ?= $(XEN_COMPILE_ARCH)
XEN_INTERFACE_VERSION := 0x00030205
# Architecture specific variables
ifeq ($(XEN_TARGET_ARCH),x86_32)
GNU_TARGET_ARCH := i686
else
GNU_TARGET_ARCH := $(XEN_TARGET_ARCH)
endif
ifeq ($(findstring x86_,$(XEN_TARGET_ARCH)),x86_)
MINIOS_TARGET_ARCH_FAM := x86
else
$(error "Non x86 target architectures are not yet supported")
endif
################################################################################
# Base commands and functions
################################################################################
LN = ln -sf
MKDIR = mkdir -p
MV = mv -f
RM = rm -f
RMDIR = rm -rf
TOUCH = touch
STRIP = strip
OBJCOPY = objcopy
NM = nm
CXXCOMPILE = $(CXX) $(CDEFINES) $(CINCLUDES) $(CPPFLAGS) $(CXXFLAGS)
CXXLD = $(CXX)
CXXLINK = $(CXXLD) $(CXXFLAGS) $(LDFLAGS) -o $@
COMPILE = $(CC) $(CDEFINES) $(CINCLUDES) $(CPPFLAGS) $(CFLAGS)
ASCOMPILE = $(CC) $(ASDEFINES) $(CDEFINES) $(CINCLUDES) $(ASFLAGS)
CCLD = $(CC)
LINK = $(CCLD) $(CFLAGS) $(LDFLAGS) -o $@
ifneq ($(verbose),y)
ccompile = @/bin/echo ' ' $(2) $< && $(COMPILE) $(DEPCFLAGS) $(1)
ccompile_nodep = @/bin/echo ' ' $(2) $< && $(COMPILE) $(1)
ascompile = @/bin/echo ' ' $(2) $< && $(ASCOMPILE) $(DEPCFLAGS) $(1)
ascompile_nodep = @/bin/echo ' ' $(2) $< && $(ASCOMPILE) $(1)
cxxcompile = @/bin/echo ' ' $(2) $< && $(CXXCOMPILE) $(DEPCFLAGS) $(1)
cxxcompile_nodep = @/bin/echo ' ' $(2) $< && $(CXXCOMPILE) $(1)
cxxlink = @/bin/echo ' ' $(2) $< && $(CXXLINK) $(1)
archive = @/bin/echo ' ' $(2) $@ && $(AR) cr $(1)
x_verbose_cmd = $(if $(2),/bin/echo ' ' $(2) $(3) &&,) $(1) $(3)
verbose_cmd = @$(x_verbose_cmd)
MAKE := $(MAKE) --silent
else
ccompile = $(COMPILE) $(DEPCFLAGS) $(1)
ccompile_nodep = $(COMPILE) $(1)
ascompile = $(ASCOMPILE) $(DEPCFLAGS) $(1)
ascompile_nodep = $(ASCOMPILE) $(1)
cxxcompile = $(CXXCOMPILE) $(DEPCFLAGS) $(1)
cxxcompile_nodep = $(CXXCOMPILE) $(1)
cxxlink = $(CXXLINK) $(1)
archive = $(AR) crv $(1)
x_verbose_cmd = $(1) $(3)
verbose_cmd = $(1) $(3)
endif
define add_cc_buildtarget
$1/%.o: $2/%.c | build-reqs
$$(call ccompile,-c $$< -o $$@,'CC ')
endef
define move-if-changed
if ! cmp -s $(1) $(2); then mv -f $(1) $(2); else rm -f $(1); fi
endef
################################################################################
# Base directory structure
################################################################################
STUBDOM_ROOT ?= $(realpath .)
STUBDOM_BUILD_DIR ?= $(STUBDOM_ROOT)/build
BUILD_DIRS += $(STUBDOM_BUILD_DIR)
################################################################################
# MiniOS build configuration
################################################################################
# Defaults
CONFIG_START_NETWORK ?= n
CONFIG_SPARSE_BSS ?= y
CONFIG_QEMU_XS_ARGS ?= n
CONFIG_PCIFRONT ?= n
CONFIG_BLKFRONT ?= y
CONFIG_BLKFRONT_PERSISTENT_GRANTS ?= n
CONFIG_TPMFRONT ?= n
CONFIG_TPM_TIS ?= n
CONFIG_TPMBACK ?= n
CONFIG_NETMAP ?= n
CONFIG_NETMAP_API ?= 10
CONFIG_NETFRONT ?= y
CONFIG_NETFRONT_STATS ?= n
CONFIG_NETFRONT_POLL ?= n
CONFIG_NETFRONT_POLLTIMEOUT ?= 10000 # usecs
CONFIG_SELECT_POLL ?= n
CONFIG_NETFRONT_PERSISTENT_GRANTS ?= n
CONFIG_NETFRONT_GSO ?= y
CONFIG_NETFRONT_WAITFORTX ?= y
CONFIG_NETFRONT_WAITFORTX_BUSYLOOP ?= n
CONFIG_NETFRONT_LWIP_ONLY ?= n
CONFIG_FBFRONT ?= n
CONFIG_KBDFRONT ?= n
CONFIG_CONSFRONT ?= n
CONFIG_CONSFRONT_SYNC ?= n
CONFIG_XENBUS ?= y
CONFIG_XC ?= y
CONFIG_LWIP_NOTHREADS ?= n
CONFIG_LWIP_HEAP_ONLY ?= n
CONFIG_LWIP_POOLS_ONLY ?= n
CONFIG_LWIP_POOLS_ON_HEAP = y
CONFIG_LWIP_MINIMAL ?= y
CONFIG_LWIP_WND_SCALE ?= n
CONFIG_LWIP_PARTIAL_CHECKSUM ?= $(CONFIG_NETFRONT_GSO)
CONFIG_LWIP_GSO ?= n
CONFIG_LWIP_BATCHTX ?= n
CONFIG_LWIP_SELECT_TIMEOUT ?= 1
CONFIG_SHUTDOWN ?= y
CONFIG_PVH ?= y
MINIOS_SRC_DIR = $(MINIOS_ROOT)
MINIOS_SUBDIRS = lib xenbus console
MINIOS_INCLUDE_DIR = $(MINIOS_OBJ_DIR)/include
MINIOS_OBJ_DIR = $(STUBDOM_BUILD_DIR)/mini-os
MINIOS_OBJS0-y := \
console.o \
ctype.o \
events.o \
gntmap.o \
gnttab.o \
hypervisor.o \
kernel.o \
lock.o \
main.o \
math.o \
mm.o \
printf.o \
sched.o \
shutdown.o \
stack_chk_fail.o \
string.o \
sys.o \
xencons_ring.o \
xmalloc.o
MINIOS_OBJS0-$(CONFIG_XENBUS) += xenbus.o
MINIOS_OBJS0-$(CONFIG_XENBUS) += xs.o
MINIOS_OBJS0-$(CONFIG_BLKFRONT) += blkfront.o
MINIOS_OBJS0-$(CONFIG_TPMFRONT) += tpmfront.o
MINIOS_OBJS0-$(CONFIG_TPM_TIS) += tpm_tis.o
MINIOS_OBJS0-$(CONFIG_TPMBACK) += tpmback.o
MINIOS_OBJS0-$(CONFIG_FBFRONT) += fbfront.o
MINIOS_OBJS0-$(CONFIG_PCIFRONT) += pcifront.o
MINIOS_OBJS0-$(CONFIG_CONSFRONT) += xencons_bus.o
MINIOS_OBJS0-$(CONFIG_NETFRONT) += netfront.o
MINIOS_OPT_FLAGS-$(CONFIG_START_NETWORK) += -DCONFIG_START_NETWORK
MINIOS_OPT_FLAGS-$(CONFIG_INCLUDE_START_NETWORK) += -DCONFIG_INCLUDE_START_NETWORK
MINIOS_OPT_FLAGS-$(CONFIG_SPARSE_BSS) += -DCONFIG_SPARSE_BSS
MINIOS_OPT_FLAGS-$(CONFIG_QEMU_XS_ARGS) += -DCONFIG_QEMU_XS_ARGS
MINIOS_OPT_FLAGS-$(CONFIG_PCIFRONT) += -DCONFIG_PCIFRONT
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_STATS) += -DCONFIG_NETFRONT_STATS
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_GSO) += -DCONFIG_NETFRONT_GSO
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_PERSISTENT_GRANTS) += -DCONFIG_NETFRONT_PERSISTENT_GRANTS
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_WAITFORTX) += -DCONFIG_NETFRONT_WAITFORTX
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_WAITFORTX_BUSYLOOP) += -DCONFIG_NETFRONT_WAITFORTX_BUSYLOOP
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT_LWIP_ONLY) += -DCONFIG_NETFRONT_LWIP_ONLY
MINIOS_OPT_FLAGS-$(CONFIG_NETMAP) += -DCONFIG_NETMAP
MINIOS_OPT_FLAGS-$(CONFIG_BLKFRONT) += -DCONFIG_BLKFRONT
MINIOS_OPT_FLAGS-$(CONFIG_BLKFRONT_PERSISTENT_GRANTS) += -DCONFIG_BLKFRONT_PERSISTENT_GRANTS
MINIOS_OPT_FLAGS-$(CONFIG_TPMFRONT) += -DCONFIG_TPMFRONT
MINIOS_OPT_FLAGS-$(CONFIG_TPM_TIS) += -DCONFIG_TPM_TIS
MINIOS_OPT_FLAGS-$(CONFIG_TPMBACK) += -DCONFIG_TPMBACK
MINIOS_OPT_FLAGS-$(CONFIG_KBDFRONT) += -DCONFIG_KBDFRONT
MINIOS_OPT_FLAGS-$(CONFIG_FBFRONT) += -DCONFIG_FBFRONT
MINIOS_OPT_FLAGS-$(CONFIG_CONSFRONT) += -DCONFIG_CONSFRONT
MINIOS_OPT_FLAGS-$(CONFIG_CONSFRONT_SYNC) += -DCONFIG_CONSFRONT_SYNC
MINIOS_OPT_FLAGS-$(CONFIG_XENBUS) += -DCONFIG_XENBUS
MINIOS_OPT_FLAGS-$(CONFIG_PVH) += -DCONFIG_PVH
MINIOS_OPT_FLAGS-$(CONFIG_SELECT_POLL) += -DCONFIG_SELECT_POLL
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_MM) += -DMM_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_DFS) += -DFS_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_LIBC) += -DLIBC_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_GNT) += -DGNT_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_GNTMAP) += -DGNTMAP_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_XENBUS) += -DXENBUS_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_LWIP) += -DLWIP_DEBUG
MINIOS_OPT_FLAGS-$(CONFIG_DEBUG_LWIP_MALLOC) += -DLWIP_DEBUG_MALLOC
ifeq ($(CONFIG_NETFRONT_POLL),y)
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT_POLL
MINIOS_OPT_FLAGS-$(CONFIG_NETFRONT) += -DCONFIG_NETFRONT_POLLTIMEOUT=$(CONFIG_NETFRONT_POLLTIMEOUT)
endif
MINIOS_OPT_FLAGS-$(CONFIG_NOAVXMEMCPY) += -DNOAVXMEMCPY
MINIOS_OBJS = $(addprefix $(MINIOS_OBJ_DIR)/,$(notdir $(MINIOS_OBJS0-y)))
MINIOS_DEPS = $(patsubst %.o,%.d,$(MINIOS_OBJS))
MINIOS_LDLIBS += -L$(NEWLIB_ROOT)/lib -whole-archive
MINIOS_LDLIBS += -no-whole-archive -lm -lc
MINIOS_LDS := $(MINIOS_ROOT)/app.lds
CDEFINES += -D__MINIOS__ -D__INSIDE_MINIOS__
CDEFINES += $(MINIOS_OPT_FLAGS-y)
CINCLUDES += -isystem $(MINIOS_ROOT)/include
CINCLUDES += -isystem $(MINIOS_INCLUDE_DIR)
CINCLUDES += -isystem $(MINIOS_ROOT)/include/posix
CINCLUDES += -isystem $(MINIOS_ROOT)/include/$(MINIOS_TARGET_ARCH_FAM)
CINCLUDES += -isystem $(MINIOS_ROOT)/include/$(MINIOS_TARGET_ARCH_FAM)/$(XEN_TARGET_ARCH)
BUILD_DIRS += $(MINIOS_INCLUDE_DIR)
BUILD_DIRS += $(MINIOS_OBJ_DIR)
DEPS += $(MINIOS_DEPS)
MINIOS_TARGET_ARCH_DIR := arch/$(MINIOS_TARGET_ARCH_FAM)
MINIOS_ARCH_SRC_DIR := $(MINIOS_SRC_DIR)/$(MINIOS_TARGET_ARCH_DIR)
MINIOS_ARCH_INCLUDE_DIR := $(MINIOS_OBJ_DIR)/include/$(MINIOS_TARGET_ARCH_FAM)
MINIOS_ARCH_OBJ_DIR := $(MINIOS_OBJ_DIR)/arch
MINIOS_ARCH_OBJS0 := \
ioremap.o \
mm.o \
sched.o \
setup.o \
time.o \
traps.o
MINIOS_ARCH_OBJS = $(addprefix $(MINIOS_ARCH_OBJ_DIR)/,$(MINIOS_ARCH_OBJS0))
MINIOS_ARCH_DEPS = $(patsubst %.o,%.d,$(MINIOS_ARCH_OBJS))
MINIOS_ARCH_HEAD_OBJ = $(MINIOS_ARCH_OBJ_DIR)/$(XEN_TARGET_ARCH).o
MINIOS_ARCH_HEAD_DEPS = $(MINIOS_ARCH_HEAD_OBJ:%.o,%.d)
MINIOS_ARCH_LIB0 = $(XEN_TARGET_ARCH)
MINIOS_ARCH_LIB = $(MINIOS_ARCH_OBJ_DIR)/lib$(MINIOS_ARCH_LIB0).a
MINIOS_ARCH_LDLIBS = -L$(MINIOS_ARCH_OBJ_DIR) -l$(MINIOS_ARCH_LIB0)
MINIOS_ARCH_LDS = $(MINIOS_ARCH_SRC_DIR)/minios-$(XEN_TARGET_ARCH).lds
CINCLUDES += -isystem $(MINIOS_ARCH_INCLUDE_DIR)
BUILD_DIRS += $(MINIOS_ARCH_INCLUDE_DIR)
BUILD_DIRS += $(MINIOS_ARCH_OBJ_DIR)
DEPS += $(MINIOS_ARCH_DEPS) $(MINIOS_ARCH_HEAD_DEPS)
# MiniOS links needed for build, UHHH is that ugly :-(
mini-os-links: $(MINIOS_ROOT)/include/list.h build-dirs
@[ -h $(MINIOS_INCLUDE_DIR)/xen ] || \
($(call x_verbose_cmd, \
$(LN) $(XEN_ROOT)/xen/include/public $(MINIOS_INCLUDE_DIR)/xen, \
'LN $(MINIOS_INCLUDE_DIR)/xen'))
@[ -h $(MINIOS_INCLUDE_DIR)/mini-os ] || \
($(call x_verbose_cmd, \
$(LN) $(MINIOS_ROOT)/include $(MINIOS_INCLUDE_DIR)/mini-os, \
'LN $(MINIOS_INCLUDE_DIR)/mini-os'))
@[ -h $(MINIOS_ARCH_INCLUDE_DIR)/mini-os ] || \
($(call x_verbose_cmd, \
$(LN) $(MINIOS_ROOT)/include/$(MINIOS_TARGET_ARCH_FAM) \
$(MINIOS_ARCH_INCLUDE_DIR)/mini-os, \
'LN $(MINIOS_ARCH_INCLUDE_DIR)/mini-os'))
# Build rules for MiniOS
$(foreach buildtarget, $(MINIOS_ROOT) $(addprefix $(MINIOS_ROOT)/, $(MINIOS_SUBDIRS)), \
$(eval $(call add_cc_buildtarget, $(MINIOS_OBJ_DIR), $(buildtarget))))
# We don't put this in build/mini-os/include because it is included as mini-os/list.h
$(MINIOS_ROOT)/include/list.h: $(XEN_ROOT)/tools/include/xen-external/bsd-sys-queue-h-seddery \
$(XEN_ROOT)/tools/include/xen-external/bsd-sys-queue.h
$(call verbose_cmd, perl $^ --prefix=minios >[email protected],'PL [email protected]')
([ -f $@ ] && $(call verbose_cmd, move-if-changed,[email protected],$@,'CHK [email protected]') ) || mv -f [email protected] $@
# Build rules for MiniOS arch lib
$(MINIOS_ARCH_OBJ_DIR)/%.o: $(MINIOS_ARCH_SRC_DIR)/%.c | build-reqs
$(call ccompile,-c $< -o $@,'CC ')
$(MINIOS_ARCH_OBJ_DIR)/%.o: $(MINIOS_ARCH_SRC_DIR)/%.S | build-reqs
$(call ascompile,-c $< -o $@,'CC ')
$(MINIOS_ARCH_LIB): $(MINIOS_ARCH_OBJS)
$(call archive,$@ $^,'AR ')
.PHONY: minios clean-minios clean-minios-links distclean-minios
minios: $(MINIOS_OBJS) $(MINIOS_ARCH_LIB)
clean-minios: clean-minios-links
$(call verbose_cmd,$(RM) \
$(wildcard $(MINIOS_OBJ_DIR)/*.o) \
$(wildcard $(MINIOS_OBJ_DIR)/*.d) \
$(wildcard $(MINIOS_ARCH_OBJ_DIR)/*.o) \
$(wildcard $(MINIOS_ARCH_OBJ_DIR)/*.d), \
'CLN $(MINIOS_OBJ_DIR)')
clean-minios-links:
$(call verbose_cmd,$(RM),'CLN',$(MINIOS_INCLUDE_DIR)/xen)
$(call verbose_cmd,$(RM),'CLN',$(MINIOS_INCLUDE_DIR)/mini-os)
$(call verbose_cmd,$(RM),'CLN',$(MINIOS_ARCH_INCLUDE_DIR)/mini-os)
distclean-minios:
$(call verbose_cmd,$(RMDIR),'CLN',$(MINIOS_OBJ_DIR))
################################################################################
# LWIP
################################################################################
ifeq ($(CONFIG_LWIP),y)
MINIOS_LWIP_SRC_DIR = $(LWIP_ROOT)/src/lwip
MINIOS_LWIP_SUBDIRS = core core/snmp core/ipv4 core/ipv6 netif netif/ppp api
MINIOS_LWIP_OBJ_DIR = $(MINIOS_OBJ_DIR)/lwip
MINIOS_OBJS0-$(CONFIG_LWIP) += lwip-net.o \
lwip-arch.o
MINIOS_LWIP_OBJS0 := api_msg.o \
netifapi.o \
err.o \
netdb.o \
sockets.o \
api_lib.o \
tcpip.o \
netbuf.o \
icmp.o \
igmp.o \
inet_chksum.o \
ip4_addr.o \
ip4.o \
ip_frag.o \
tcp_out.o \
stats.o \
dns.o \
pbuf.o \
tcp_in.o \
sys.o \
tcp.o \
mem.o \
def.o \
timers.o \
netif.o \
init.o \
memp.o \
dhcp.o \
udp.o \
raw.o \
ethernetif.o \
etharp.o
ifneq ($(CONFIG_LWIP_MINIMAL),y)
MINIOS_LWIP_OBJS0 += autoip.o \
slipif.o \
ppp_oe.o \
ppp.o \
randm.o \
magic.o \
ipcp.o \
chpms.o \
vj.o \
md5.o \
auth.o \
lcp.o \
fsm.o \
pap.o \
chap.o \
asn1_enc.o \
mib_structs.o \
msg_in.o \
mib2.o \
msg_out.o \
asn1_dec.o
endif
MINIOS_LWIP_OBJS = $(addprefix $(MINIOS_LWIP_OBJ_DIR)/,$(MINIOS_LWIP_OBJS0))
MINIOS_LWIP_DEPS = $(patsubst %.o,%.d,$(MINIOS_LWIP_OBJS))
MINIOS_LWIP_LIB = $(MINIOS_LWIP_OBJ_DIR)/liblwip.a
LWIP_OPT_FLAGS-$(CONFIG_LWIP_NOTHREADS) += -DCONFIG_LWIP_NOTHREADS
LWIP_OPT_FLAGS-$(CONFIG_LWIP_HEAP_ONLY) += -DCONFIG_LWIP_HEAP_ONLY
LWIP_OPT_FLAGS-$(CONFIG_LWIP_POOLS_ONLY) += -DCONFIG_LWIP_POOLS_ONLY
LWIP_OPT_FLAGS-$(CONFIG_LWIP_POOLS_ON_HEAP) += -DCONFIG_LWIP_POOLS_ON_HEAP
LWIP_OPT_FLAGS-$(CONFIG_LWIP_MINIMAL) += -DCONFIG_LWIP_MINIMAL
LWIP_OPT_FLAGS-$(CONFIG_LWIP_WND_SCALE) += -DCONFIG_LWIP_WND_SCALE
LWIP_OPT_FLAGS-$(CONFIG_LWIP_PARTIAL_CHECKSUM) += -DCONFIG_LWIP_PARTIAL_CHECKSUM
LWIP_OPT_FLAGS-$(CONFIG_LWIP_GSO) += -DCONFIG_LWIP_GSO
LWIP_OPT_FLAGS-$(CONFIG_LWIP_BATCHTX) += -DCONFIG_LWIP_BATCHTX
LWIP_OPT_FLAGS-$(CONFIG_LWIP) += -DCONFIG_LWIP_SELECT_TIMEOUT=$(CONFIG_LWIP_SELECT_TIMEOUT)
CINCLUDES += -isystem $(LWIP_ROOT)/include/lwip
CINCLUDES += -isystem $(LWIP_ROOT)/include/lwip/ipv4
CINCLUDES += -isystem $(LWIP_ROOT)/include/lwip/ipv6
CDEFINES += -DHAVE_LWIP
CDEFINES += $(LWIP_OPT_FLAGS-y)
BUILD_DIRS += $(MINIOS_LWIP_OBJ_DIR)
DEPS += $(MINIOS_LWIP_DEPS)
# Build rules for lwip lib
$(foreach buildtarget, $(MINIOS_LWIP_SRC_DIR) \
$(addprefix $(MINIOS_LWIP_SRC_DIR)/, $(MINIOS_LWIP_SUBDIRS)), \
$(eval $(call add_cc_buildtarget, $(MINIOS_LWIP_OBJ_DIR), $(buildtarget))))
$(MINIOS_LWIP_LIB): $(MINIOS_LWIP_OBJS)
$(call archive,$@ $^,'AR ')
.PHONY: lwip clean-lwip distclean-lwip
lwip: $(MINIOS_LWIP_LIB)
clean-lwip:
$(call verbose_cmd,$(RM) \
$(wildcard $(MINIOS_LWIP_OBJ_DIR)/*.o) \
$(wildcard $(MINIOS_LWIP_OBJ_DIR)/*.d), \
'CLN $(MINIOS_LWIP_OBJ_DIR)')
distclean-lwip:
$(call verbose_cmd,$(RMDIR),'CLN', $(MINIOS_LWIP_OBJ_DIR))
else
MINIOS_LWIP_LIB :=
MINIOS_LWIP_OBJS :=
.PHONY: lwip clean-lwip distclean-lwip
lwip:
clean-lwip:
distclean-lwip:
endif
################################################################################
# General build rules
################################################################################
GCC_INSTALL = $(shell LANG=C gcc -print-search-dirs | sed -n -e 's/install: \(.*\)/\1/p')
CFLAGS += -U __linux__ -U __FreeBSD__ -U __sun__
CFLAGS += -nostdinc
CFLAGS += -isystem $(GCC_INSTALL)include
CFLAGS += -Wall -Wno-format -Wno-redundant-decls -Wno-undef
CFLAGS += -fno-builtin -fno-stack-protector -fgnu89-inline
CXXFLAGS += -Wall -Wno-format -Wno-redundant-decls -Wno-strict-aliasing -Wno-undef -Wno-pointer-arith
CXXFLAGS += -fno-exceptions -fno-rtti -fpermissive -fno-builtin -fno-stack-protector
CDEFINES += -DHAVE_LIBC
CDEFINES += -D__XEN_INTERFACE_VERSION__=$(XEN_INTERFACE_VERSION)
CINCLUDES += -isystem $(XEN_ROOT)/tools/xenstore
CINCLUDES += -isystem $(XEN_ROOT)/tools/xenstore/include
CINCLUDES += -isystem $(NEWLIB_ROOT)/include
ASDEFINES += -D__ASSEMBLY__
LDFLAGS += -nostdlib --omagic
LDLIBS += -L$(NEWLIB_ROOT)/lib -lc -lm
DEPCFLAGS := -MD -MP
STUB_GLOBAL_PREFIX ?= xenos_
#
# Architecture special makerules for x86 family
# (including x86_32, x86_32y and x86_64).
#
ifeq ($(XEN_TARGET_ARCH),x86_32)
CFLAGS += -m32 -march=i686
CXXFLAGS += -m32 -march=i686
ASFLAGS := -m32
LDFLAGS += -m elf_i386
endif
ifeq ($(XEN_TARGET_ARCH),x86_64)
CFLAGS += -m64 -mno-red-zone -fno-reorder-blocks
CFLAGS += -fno-asynchronous-unwind-tables
CXXFLAGS += -m64 -mno-red-zone -fno-reorder-blocks
CXXFLAGS += -fno-asynchronous-unwind-tables
ASFLAGS += -m64
LDFLAGS += -m elf_x86_64
endif
# Configure debuging
ifeq ($(debug),y)
CFLAGS += -g -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls -DDEBUG_BUILD
CXXFLAGS += -g -O0 -fno-omit-frame-pointer -fno-optimize-sibling-calls -DDEBUG_BUILD
else
CFLAGS += -g -O3 -msse4 -fno-omit-frame-pointer -fno-tree-sra -fno-tree-vectorize
CXXFLAGS += -g -O3 -msse4 -fno-omit-frame-pointer -fno-tree-sra -fno-tree-vectorize
endif
################################################################################
# Linking external apps
################################################################################
STUBDOM_NAME ?= stub
STUB_APP_SRC_DIR ?= $(STUBDOM_ROOT)
STUB_APP_OBJ_DIR ?= $(STUBDOM_BUILD_DIR)/$(STUBDOM_NAME)
STUB_APP_OBJS0 ?= $(STUBDOM_NAME).o
STUB_APP_OBJS ?= $(addprefix $(STUB_APP_OBJ_DIR)/,$(STUB_APP_OBJS0))
STUB_APP_DEPS ?= $(patsubst %.o,%.d,$(STUB_APP_OBJS))
STUB_LDLIBS += $(MINIOS_LDLIBS)
STUB_APP ?= $(STUBDOM_BUILD_DIR)/$(STUBDOM_NAME)
STUB_APP_IMG ?= $(STUBDOM_BUILD_DIR)/$(STUBDOM_NAME)_$(XEN_TARGET_ARCH)
STUB_BANNER ?= banner
CFLAGS += $(STUB_CFLAGS)
CPPFLAGS += $(STUB_CPPFLAGS)
CINCLUDES += $(STUB_CINCLUDES)
CDEFINES += $(STUB_CDEFINES)
LDFLAGS += $(STUB_LDFLAGS)
ASFLAGS += $(STUB_ASFLAGS)
ASDEFINES += $(STUB_ASDEFINES)
DEPCFLAGS += $(STUB_DEPCFLAGS)
CXXFLAGS += $(STUB_CXXFLAGS)
CXXINCLUDES += $(STUB_CXXINCLUDES)
CXXDEFINES += $(STUB_CXXDEFINES)
BUILD_DIRS += $(STUB_BUILD_DIRS)
BUILD_DIRS += $(STUB_APP_OBJ_DIR)
DEPS += $(STUB_APP_DEPS)
-include $(DEPS)
# Default build for c/c++ stub objects
$(STUB_APP_OBJ_DIR)/%.o: $(STUB_APP_SRC_DIR)/%.c | build-reqs
$(call ccompile, $(STUB_APP_INCLUDES) -c $< -o $@,'CC ')
$(STUB_APP_OBJ_DIR)/%.o: $(STUB_APP_SRC_DIR)/%.cc | build-reqs
$(call cxxcompile,$(STUB_APP_INCLUDES) -c $< -o $@,'CXX')
$(STUB_APP_OBJ_DIR)/%.o: $(STUB_APP_SRC_DIR)/%.S | build-reqs
$(call ascompile,-c $< -o $@,'CC ')
# $(call ascompile,$(STUB_APP_INCLUDES) -c $< -o $@,'CXX')
# Default linking for stub objects
$(STUB_APP).o: $(STUB_APP_OBJS) $(MINIOS_LDS)
$(call verbose_cmd,$(LD) -r -d $(LDFLAGS) -\( $(STUB_APP_OBJS) -\) $(STUB_LDLIBS) -T $(MINIOS_LDS) --undefined main -o,'LD ',$@)
# Linking the image
$(STUB_APP_IMG)_.o: $(MINIOS_ARCH_LIB) $(MINIOS_ARCH_HEAD_OBJ) $(STUB_APP).o $(MINIOS_OBJS) $(MINIOS_LWIP_LIB)
$(call verbose_cmd,$(LD) -r $(LDFLAGS) $^ $(MINIOS_ARCH_LDLIBS) $(LDLIBS) -o,'LD ',$@)
$(STUB_APP_IMG).o: $(STUB_APP_IMG)_.o
$(call verbose_cmd,$(OBJCOPY) -w -G $(STUB_GLOBAL_PREFIX)* -G _start $^,'OCP',$@)
$(STUB_APP_IMG): $(STUB_APP_IMG).o
$(call verbose_cmd,$(LD) $(LDFLAGS) -T $(MINIOS_ARCH_LDS) [email protected] -o,'LD ',$@)
$(call verbose_cmd,$(NM) -n $@ >,'SYM',[email protected])
ifneq ($(debug),y)
$(call verbose_cmd,cp $@ , 'CP', $@_nostrip)
$(call verbose_cmd,$(STRIP) -s,'STR',$@)
endif
$(STUB_APP_IMG).gz: $(STUB_APP_IMG)
$(call verbose_cmd,gzip -f -9 -c $? >,GZ,$@)
.PHONY: stub clean-stub distclean-stub
stub: $(STUB_BANNER)
+$(call verbose_cmd,$(MAKE) DESTDIR= ,'MK ',$(STUB_APP_IMG).gz)
@echo "================================================================================"
@echo
@echo " Your $(STUBDOM_NAME) build is complete..."
@echo " Get the image from $(STUB_APP_IMG).gz"
@echo
@echo "================================================================================"
clean-stub:
$(call verbose_cmd,$(RM) \
$(wildcard $(STUB_APP_OBJ_DIR)/*.o) \
$(wildcard $(STUB_APP_OBJ_DIR)/*.d), \
'CLN $(STUB_APP_OBJ_DIR)')
distclean-stub:
$(call verbose_cmd,$(RM) \
$(STUB_APP).o $(STUB_APP_IMG).o $(STUB_APP_IMG) $(STUBS_APP_IMG).syms $(STUB_APP_IMG).gz, \
'CLN $(STUB_APP_IMG)')
.PHONY: banner
banner:
@#
################################################################################
# Tags
################################################################################
all_sources_lists = minios.srclist own.srclist xen.srclist newlib.srclist
minios.srclist: ROOT_SRC = $(MINIOS_ROOT)
xen.srclist: ROOT_SRC = $(XEN_ROOT)
newlib.srclist: ROOT_SRC = $(NEWLIB_ROOT)
own.srclist: ROOT_SRC = .
%.srclist:
-$(call verbose_cmd, \
find -L $(ROOT_SRC) \
\( -iname '*.c' -o -iname '*.cpp' -o -iname '*.h' -o -iname '*.hpp' \) \
-exec readlink -f '{}' \; > $@, \
'LST $(ROOT_SRC)')
src.list: $(all_sources_lists)
$(call verbose_cmd, \
cat $(all_sources_lists) | sort -u > $@, \
'GEN $@')
.PHONY: cscope
cscope: src.list
$(call verbose_cmd, \
cscope -c -b -k -i src.list -f cscope.out, \
"GEN scope.out")
.PHONY: TAGS
TAGS: src.list
$(call verbose_cmd, \
rm -f TAGS; xargs -a src.list etags -a, \
'GEN TAGS')
.PHONY: clean-tags
clean-tags:
$(call verbose_cmd, $(RM) \
src.list $(all_sources_lists) cscope.out TAGS, \
'CLN tags')
################################################################################
# Others
################################################################################
.PHONY: all
all: stub
build-reqs-stamp := $(STUBDOM_BUILD_DIR)/build-reqs-stamp
.PHONY: build-reqs
build-reqs: $(build-reqs-stamp) build-dirs
$(build-reqs-stamp): mini-os-links
.PHONY: build-dirs
build-dirs: $(BUILD_DIRS)
$(BUILD_DIRS):
$(call verbose_cmd,$(MKDIR),'MKD',$@);
.PHONY: clean
clean: clean-minios clean-lwip clean-stub
distclean: distclean-minios distclean-lwip distclean-stub clean-tags
$(call verbose_cmd,$(RMDIR),'CLN',$(STUBDOM_BUILD_DIR))