forked from moby/hyperkit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
156 lines (131 loc) · 3.64 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
GIT_VERSION := $(shell git describe --abbrev=6 --dirty --always --tags)
ifeq ($V, 1)
VERBOSE =
else
VERBOSE = @
endif
include config.mk
VMM_SRC := \
src/vmm/x86.c \
src/vmm/vmm.c \
src/vmm/vmm_host.c \
src/vmm/vmm_mem.c \
src/vmm/vmm_lapic.c \
src/vmm/vmm_instruction_emul.c \
src/vmm/vmm_ioport.c \
src/vmm/vmm_callout.c \
src/vmm/vmm_stat.c \
src/vmm/vmm_util.c \
src/vmm/vmm_api.c \
src/vmm/intel/vmx.c \
src/vmm/intel/vmx_msr.c \
src/vmm/intel/vmcs.c \
src/vmm/io/vatpic.c \
src/vmm/io/vatpit.c \
src/vmm/io/vhpet.c \
src/vmm/io/vioapic.c \
src/vmm/io/vlapic.c \
src/vmm/io/vpmtmr.c \
src/vmm/io/vrtc.c
XHYVE_SRC := \
src/acpitbl.c \
src/atkbdc.c \
src/block_if.c \
src/consport.c \
src/dbgport.c \
src/inout.c \
src/ioapic.c \
src/md5c.c \
src/mem.c \
src/mevent.c \
src/mptbl.c \
src/pci_ahci.c \
src/pci_emul.c \
src/pci_hostbridge.c \
src/pci_irq.c \
src/pci_lpc.c \
src/pci_uart.c \
src/pci_virtio_9p.c \
src/pci_virtio_block.c \
src/pci_virtio_net_tap.c \
src/pci_virtio_net_vmnet.c \
src/pci_virtio_rnd.c \
src/pm.c \
src/post.c \
src/rtc.c \
src/smbiostbl.c \
src/task_switch.c \
src/uart_emul.c \
src/xhyve.c \
src/virtio.c \
src/xmsr.c
FIRMWARE_SRC := \
src/firmware/bootrom.c \
src/firmware/kexec.c \
src/firmware/fbsd.c
ifneq ($(LIBVMNETD_DIR),)
VMNETD_SRC := \
src/pci_virtio_net_ipc.c
LDLIBS += $(LIBVMNETD_DIR)/libvmnetd.a
CFLAGS += -I$(LIBVMNETD_DIR)
endif
HAVE_OCAML_QCOW := $(shell if ocamlfind query qcow uri >/dev/null 2>/dev/null ; then echo YES ; else echo NO; fi)
ifeq ($(HAVE_OCAML_QCOW),YES)
CFLAGS += -DHAVE_OCAML=1 -DHAVE_OCAML_QCOW=1 -DHAVE_OCAML=1
OCAML_SRC := \
src/mirage_block_ocaml.ml
OCAML_C_SRC := \
src/mirage_block_c.c
OCAML_WHERE := $(shell ocamlc -where)
OCAML_PACKS := cstruct cstruct.lwt io-page io-page.unix uri mirage-block mirage-block-unix qcow unix threads lwt lwt.unix
OCAML_LDLIBS := -L $(OCAML_WHERE) \
$(shell ocamlfind query cstruct)/cstruct.a \
$(shell ocamlfind query cstruct)/libcstruct_stubs.a \
$(shell ocamlfind query io-page)/io_page.a \
$(shell ocamlfind query io-page)/io_page_unix.a \
$(shell ocamlfind query io-page)/libio_page_unix_stubs.a \
$(shell ocamlfind query lwt.unix)/liblwt-unix_stubs.a \
$(shell ocamlfind query lwt.unix)/lwt-unix.a \
$(shell ocamlfind query lwt.unix)/lwt.a \
$(shell ocamlfind query threads)/libthreadsnat.a \
$(shell ocamlfind query mirage-block-unix)/libmirage_block_unix_stubs.a \
-lasmrun -lbigarray -lunix
build/xhyve.o: CFLAGS += -I$(OCAML_WHERE)
endif
SRC := \
$(VMM_SRC) \
$(XHYVE_SRC) \
$(FIRMWARE_SRC) \
$(VMNETD_SRC) \
$(OCAML_C_SRC)
OBJ := $(SRC:src/%.c=build/%.o) $(OCAML_SRC:src/%.ml=build/%.o)
DEP := $(OBJ:%.o=%.d)
INC := -Iinclude
CFLAGS += -DVERSION=\"$(GIT_VERSION)\"
TARGET = build/com.docker.hyperkit
all: $(TARGET) | build
.PHONY: clean all
.SUFFIXES:
-include $(DEP)
build:
@mkdir -p build
build/%.o: src/%.c
@echo cc $<
@mkdir -p $(dir $@)
$(VERBOSE) $(ENV) $(CC) $(CFLAGS) $(INC) $(DEF) -MMD -MT $@ -MF build/$*.d -o $@ -c $<
$(OCAML_C_SRC:src/%.c=build/%.o): CFLAGS += -I$(OCAML_WHERE)
build/%.o: src/%.ml
@echo ml $<
@mkdir -p $(dir $@)
$(VERBOSE) $(ENV) ocamlfind ocamlopt -thread -package "$(OCAML_PACKS)" -c $< -o build/$*.cmx
$(VERBOSE) $(ENV) ocamlfind ocamlopt -thread -linkpkg -package "$(OCAML_PACKS)" -output-obj -o $@ build/$*.cmx
$(TARGET).sym: $(OBJ)
@echo ld $(notdir $@)
$(VERBOSE) $(ENV) $(LD) $(LDFLAGS) -Xlinker $(TARGET).lto.o -o $@ $(OBJ) $(LDLIBS) $(OCAML_LDLIBS)
@echo dsym $(notdir $(TARGET).dSYM)
$(VERBOSE) $(ENV) $(DSYM) $@ -o $(TARGET).dSYM
$(TARGET): $(TARGET).sym
@echo strip $(notdir $@)
$(VERBOSE) $(ENV) $(STRIP) $(TARGET).sym -o $@
clean:
@rm -rf build