forked from pixelc-linux/rootfs-builder
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
100 lines (98 loc) · 3.18 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
include vars.mk
include contrib/makefiles/pkg/string/string.mk
include contrib/makefiles/pkg/color/color.mk
include contrib/makefiles/pkg/functions/functions.mk
include contrib/makefiles/target/buildenv/buildenv.mk
# include build/makefiles/target/go/go.mk
THIS_FILE := $(lastword $(MAKEFILE_LIST))
SELF_DIR := $(dir $(THIS_FILE))
DISTROS = $(notdir $(patsubst %/,%,$(dir $(wildcard ./distros/*/.))))
BUILD_TARGETS = $(DISTROS:%=build-%)
UNMOUNT_TARGETS = $(DISTROS:%=unmount-%)
CLEAN_TARGETS = $(DISTROS:%=clean-%)
.PHONY: build clean unmount target
.SILENT: build clean unmount target
target:
- $(call print_running_target)
- $(info $(BUILD_TARGETS))
- $(call print_completed_target)
.PHONY: $(BUILD_TARGETS)
.SILENT: $(BUILD_TARGETS)
$(BUILD_TARGETS): $(CLEAN_TARGETS)
- $(call print_running_target)
- $(eval name=$(@:build-%=%))
- $(eval command=$(PWD)$(PSEP)distros$(PSEP)$(name)$(PSEP)build.sh)
- chmod +x $(command)
- cat "distros/$(name)/logo"
- echo
- $(eval command=$(command) --root-dir $(BUILD_DIR)$(PSEP)$(name))
ifneq (${ARCH}, )
- $(eval command=${command} --arch '$(ARCH)')
endif
ifneq (${HOST_NAME}, )
- $(eval command=${command} --host-name '$(HOST_NAME)')
endif
ifneq (${TIME_ZONE}, )
- $(eval command=${command} --time-zone '$(TIME_ZONE)')
endif
ifneq (${WIFI_SSID}, )
- $(eval command=${command} --wifi-ssid '$(WIFI_SSID)')
endif
ifneq (${WIFI_PASSWORD}, )
- $(eval command=${command} --wifi-password '$(WIFI_PASSWORD)')
endif
ifeq ($(DOCKER_ENV),true)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell \
docker_image="${BUILDER_IMAGE}" \
container_name="${BUILDER_CONTAINER_NAME}" \
mount_point="${BUILDER_CONTAINER_MOUNT_POINT} \
cmd="${command}"
endif
ifeq ($(DOCKER_ENV),false)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell cmd="${command}"
endif
- $(call print_completed_target)
.PHONY: $(UNMOUNT_TARGETS)
.SILENT: $(UNMOUNT_TARGETS)
$(UNMOUNT_TARGETS):
- $(call print_running_target)
- $(eval name=$(@:unmount-%=%))
- $(eval command=find $(BUILD_DIR)$(PSEP)$(name) -type d -exec umount -lvf {} \; || true)
ifeq ($(DOCKER_ENV),true)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell \
docker_image="${BUILDER_IMAGE}" \
container_name="${BUILDER_CONTAINER_NAME}" \
mount_point="${BUILDER_CONTAINER_MOUNT_POINT} \
cmd="${command}"
endif
ifeq ($(DOCKER_ENV),false)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell cmd="${command}"
endif
- $(call print_completed_target)
.PHONY: $(CLEAN_TARGETS)
.SILENT: $(CLEAN_TARGETS)
$(CLEAN_TARGETS): $(UNMOUNT_TARGETS)
- $(call print_running_target)
- $(eval name=$(@:clean-%=%))
- $(eval command=$(RM) $(BUILD_DIR)$(PSEP)$(name))
ifeq ($(DOCKER_ENV),true)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell \
docker_image="${BUILDER_IMAGE}" \
container_name="${BUILDER_CONTAINER_NAME}" \
mount_point="${BUILDER_CONTAINER_MOUNT_POINT} \
cmd="${command}"
endif
ifeq ($(DOCKER_ENV),false)
- @$(MAKE) --no-print-directory \
-f $(THIS_FILE) shell cmd="${command}"
endif
- $(call print_completed_target)
clean:
- $(call print_running_target)
- @$(MAKE) --no-print-directory -f $(THIS_FILE) $(CLEAN_TARGETS)
- $(call print_completed_target)