-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
63 lines (46 loc) · 1.21 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
MYDIR := $(abspath $(dir $(lastword $(MAKEFILE_LIST))))
CD ?= cd
CP ?= cp
CMAKE ?= cmake
MAKE ?= make
MKDIR ?= mkdir
OBJCOPY ?= objcopy
RM ?= rm
STRIP ?= strip
BUILD_DIR ?= $(MYDIR)/build
NATIVE_DIR := $(BUILD_DIR)/bm
SRC_DIR := $(MYDIR)/src
SRC_CONFIG_FLAGS ?=
ifndef CMAKE_PREFIX_PATH
$(error CMAKE_PREFIX_PATH is undefined)
endif
all: hosted native
clean:
-$(RM) -r $(BUILD_DIR)
hosted: $(BUILD_DIR)/Makefile
$(MAKE) -C $(BUILD_DIR)
native: $(NATIVE_DIR) | $(NATIVE_DIR)/reconstruction.elf32
$(BUILD_DIR)/Makefile: | $(BUILD_DIR)
$(CD) $(BUILD_DIR) && $(CMAKE) \
-DCMAKE_PREFIX_PATH=$(CMAKE_PREFIX_PATH) \
-DCMAKE_BUILD_TYPE=Release $(MYDIR)
# -DCMAKE_BUILD_TYPE=Debug $(MYDIR)
$(BUILD_DIR):
$(MKDIR) $@
$(NATIVE_DIR): | $(BUILD_DIR)
$(MKDIR) $@
check-env:
ifndef EBBRT_SYSROOT
$(error EBBRT_SYSROOT is undefined)
endif
$(SRC_DIR): check-env
$(CD) $(NATIVE_DIR) && $(CMAKE) \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_TOOLCHAIN_FILE=$(EBBRT_SYSROOT)/usr/misc/ebbrt.cmake ../../
$(NATIVE_DIR)/reconstruction.elf: $(SRC_DIR) | $(NATIVE_DIR)
$(MAKE) -C $(NATIVE_DIR)
%.elf.stripped: %.elf
$(STRIP) -s $< -o $@
%.elf32: %.elf.stripped
$(OBJCOPY) -O elf32-i386 $< $@
.PHONY: all check-env clean hosted native