-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
60 lines (48 loc) · 1.58 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
.PHONY: build_dirs
CFLAGS := -Os -g -Wall
ifeq ($(ARCH),)
export ARCH := $(shell uname -m)
endif
ifeq ($(ARCH),x86_64)
export ARCH = x86
endif
$(info Architecture: $(ARCH))
# NixOS uses the $out variable to indicate build output location
ifeq "$(out)" ""
export LIB_DIR := /usr/lib/os-prober
export BIN_DIR := /usr/bin/os-prober
else
export LIB_DIR := $(out)/lib
export BIN_DIR := $(out)/bin
endif
all: build/bin/os-prober build/bin/linux-boot-prober build/lib/newns
build_dirs:
mkdir -p build/bin build/lib
build/lib/newns: build_dirs src/newns.c
$(CC) $(CFLAGS) $(LDFLAGS) src/newns.c -o build/lib/newns
build/bin/os-prober: build/lib/common.sh src/os-prober
./do-build-replace < src/os-prober > build/bin/os-prober
chmod +x build/bin/os-prober
build/bin/linux-boot-prober: build/lib/common.sh src/linux-boot-prober
./do-build-replace < src/linux-boot-prober > build/bin/linux-boot-prober
chmod +x build/bin/linux-boot-prober
build/lib/common.sh: build_dirs src/common.sh
./do-build-replace < src/common.sh > build/lib/common.sh
check: build/lib/newns
./build/bin/os-prober
./build/bin/os-prober | grep ':'
./build/bin/linux-boot-prover
./build/bin/linux-boot-prover | grep ':'
install: all
mkdir -p $(LIB_DIR) $(BIN_DIR)
cp -r build/lib/* $(LIB_DIR)
cp -a build/bin/* $(BIN_DIR)
for probes in os os/init os/mounted; do \
mkdir -p $(LIB_DIR)/probes/$$probes; \
cp src/probes/$$probes/common/* $(LIB_DIR)/probes/$$probes; \
if [ -e "src/probes/$$probes/$(ARCH)" ]; then \
cp -r src/probes/$$probes/$(ARCH)/* $(LIB_DIR)/probes/$$probes; \
fi; \
done
clean:
rm -f newns