-
Notifications
You must be signed in to change notification settings - Fork 9
/
common.mk
92 lines (71 loc) · 3.11 KB
/
common.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
# This file is part of buildroot-submodule.
#
# buildroot-submodule is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# buildroot-submodule is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with buildroot-submodule. If not, see <http://www.gnu.org/licenses/>. 2
#location of the buildroot sources
MAKEARGS := -C $(CURDIR)/buildroot
#location to store build files
MAKEARGS += O=$(CURDIR)/$(PROJECT_NAME)/output
# location to store extra config options and buildroot packages
MAKEARGS += BR2_EXTERNAL=$(CURDIR)
#transmit project name to be able to use it in kconfig
MAKEARGS += PROJECT_NAME=$(PROJECT_NAME)
# location of default defconfig
DEFCONFIG_FILE=$(CURDIR)/$(PROJECT_NAME)/defconfig
DEFCONFIG := BR2_DEFCONFIG=$(DEFCONFIG_FILE)
ALT_DEFCONFIG := BR2_DEFCONFIG=$(CURDIR)/defconfig
MAKEFLAGS += --no-print-directory
#these targets change the config file
config_change_targets:=menuconfig nconfig xconfig gconfig oldconfig \
silentoldconfig randconfig allyesconfig allnoconfig randpackageconfig \
allyespackageconfig allnopackageconfig
special_target:=$(config_change_targets) Makefile defconfig savedefconfig %_defconfig
all := $(filter-out $(special_target),$(MAKECMDGOALS))
default:
$(MAKE) $(MAKEARGS) $(DEFCONFIG) defconfig
$(MAKE) $(MAKEARGS) $(DEFCONFIG)
.PHONY: $(special_target) $(all)
# update from current config and save it as defconfig
defconfig:
$(MAKE) $(MAKEARGS) $(ALT_DEFCONFIG) $@
$(MAKE) $(MAKEARGS) $(DEFCONFIG) savedefconfig
# update from defconfig and save it as current configuration
savedefconfig:
$(MAKE) $(MAKEARGS) $(DEFCONFIG) defconfig
$(MAKE) $(MAKEARGS) $(ALT_DEFCONFIG) savedefconfig
# generate from a defconfig then save as current configuration
%_defconfig:
$(MAKE) $(MAKEARGS) $(DEFCONFIG) $@
$(MAKE) $(MAKEARGS) $(DEFCONFIG) savedefconfig
$(call UPDATE_DEFCONFIG)
# update from current configuration, run the command, then save the result
$(config_change_targets): $(DEFCONFIG_FILE)
$(MAKE) $(MAKEARGS) $(DEFCONFIG) defconfig $@
$(MAKE) $(MAKEARGS) $(DEFCONFIG) savedefconfig
_all:
$(MAKE) $(MAKEARGS) $(DEFCONFIG) $(all)
$(all): _all
@:
%/: _all
@:
Makefile:;
$(DEFCONFIG_FILE):
$(call UPDATE_DEFCONFIG)
define UPDATE_DEFCONFIG
echo 'BR2_DL_DIR="$$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/dl"' >> $(DEFCONFIG_FILE)
echo 'BR2_ROOTFS_OVERLAY="$$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/overlay"' >> $(DEFCONFIG_FILE)
echo 'BR2_PACKAGE_OVERRIDE_FILE="$$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/local.mk"' >> $(DEFCONFIG_FILE)
echo 'BR2_GLOBAL_PATCH_DIR="$$(BR2_EXTERNAL_BUILDROOT_SUBMODULE_PATH)/patch"' >> $(DEFCONFIG_FILE)
$(MAKE) $(MAKEARGS) $(DEFCONFIG) defconfig
$(MAKE) $(MAKEARGS) $(DEFCONFIG) savedefconfig
endef