forked from nerves-project/nerves_system_br
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
127 lines (106 loc) · 4.68 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
TOPDIR := $(shell pwd)
NERVES_BR_VERSION = 2015.02
NERVES_BR_URL = git://git.buildroot.net/buildroot
NERVES_DEFCONFIG = $(shell grep BR2_DEFCONFIG= buildroot/.config | sed -e 's/.*"\(.*\)"/\1/')
# Optional place to download files to so that they don't need
# to be redownloaded when working a lot with buildroot
# Try the default directory first and if that doesn't work, use
# a directory in the Nerves folder..
OLD_DEFAULT_DL_DIR = $(HOME)/dl
DEFAULT_DL_DIR = $(HOME)/.nerves-cache
IN_TREE_DL_DIR = $(TOPDIR)/dl
NERVES_BR_DL_DIR ?= $(if $(wildcard $(DEFAULT_DL_DIR)), $(DEFAULT_DL_DIR), $(if $(wildcard $(OLD_DEFAULT_DL_DIR)), $(OLD_DEFAULT_DL_DIR), $(IN_TREE_DL_DIR)))
MAKE_BR = make -C buildroot BR2_EXTERNAL=$(TOPDIR)
all: br-make
.buildroot-downloaded:
@echo "Caching downloaded files in $(NERVES_BR_DL_DIR)."
@mkdir -p $(NERVES_BR_DL_DIR)
@echo "Downloading Buildroot..."
@scripts/clone_or_dnload.sh $(NERVES_BR_URL) $(NERVES_BR_VERSION) $(NERVES_BR_DL_DIR)
@touch .buildroot-downloaded
# Apply our patches that either haven't been submitted or merged upstream yet
.buildroot-patched: .buildroot-downloaded
buildroot/support/scripts/apply-patches.sh buildroot patches || exit 1
touch .buildroot-patched
# If there's a user dl directory, symlink it to avoid the big download
if [ -d $(NERVES_BR_DL_DIR) -a ! -e buildroot/dl ]; then \
ln -s $(NERVES_BR_DL_DIR) buildroot/dl; \
fi
reset-buildroot: .buildroot-downloaded
# Reset buildroot to a pristine condition so that the
# patches can be applied again.
cd buildroot && git clean -fdx && git reset --hard
rm -f .buildroot-patched
update-patches: reset-buildroot .buildroot-patched
%_defconfig: $(TOPDIR)/configs/%_defconfig .buildroot-patched
$(MAKE_BR) $@
buildroot/.config: .buildroot-patched
@echo
@echo 'ERROR: Please choose a Nerves SDK configuration and run'
@echo ' "make <platform>_defconfig"'
@echo
@echo 'Run "make help" or look in the configs directory for options'
@false
br-make: buildroot/.config
$(MAKE_BR)
@echo
@echo SDK is ready to use. Demo images are in buildroot/output/images.
# Replace everything on the SDCard with new bits
burn-complete:
sudo buildroot/output/host/usr/bin/fwup -a -i $(firstword $(wildcard buildroot/output/images/*.fw)) -t complete
# Upgrade the image on the SDCard (app data won't be removed)
# This is usually the fastest way to update an SDCard that's already
# been programmed. It won't update bootloaders, so if something is
# really messed up, burn-complete may be better.
burn-upgrade:
sudo buildroot/output/host/usr/bin/fwup -a -i $(firstword $(wildcard buildroot/output/images/*.fw)) -t upgrade
sudo buildroot/output/host/usr/bin/fwup -y -a -i /tmp/finalize.fw -t on-reboot
sudo rm /tmp/finalize.fw
menuconfig: buildroot/.config
$(MAKE_BR) menuconfig
@echo
@echo "!!! Important !!!"
@echo "1. $(subst $(shell pwd)/,,$(NERVES_DEFCONFIG)) has NOT been updated."
@echo " Changes will be lost if you run 'make distclean'."
@echo " Run 'make savedefconfig' to update."
@echo "2. Buildroot normally requires you to run 'make clean' and 'make' after"
@echo " changing the configuration. You don't technically have to do this,"
@echo " but if you're new to Buildroot, it's best to be safe."
savedefconfig: buildroot/.config
$(MAKE_BR) savedefconfig
linux-menuconfig: buildroot/.config
$(MAKE_BR) linux-menuconfig
$(MAKE_BR) linux-savedefconfig
@echo
@echo Going to update your boards/.../linux-x.y.config. If you do not have one,
@echo you will get an error shortly. You will then have to make one and update,
@echo your buildroot configuration to use it.
$(MAKE_BR) linux-update-defconfig
busybox-menuconfig: buildroot/.config
$(MAKE_BR) busybox-menuconfig
@echo
@echo Going to update your boards/.../busybox-x.y.config. If you do not have one,
@echo you will get an error shortly. You will then have to make one and update
@echo your buildroot configuration to use it.
$(MAKE_BR) busybox-update-config
clean: realclean
distclean: realclean
realclean:
-rm -fr buildroot .buildroot-patched .buildroot-downloaded
help:
@echo 'Nerves SDK Help'
@echo '---------------'
@echo
@echo 'Targets:'
@echo ' all - Build the current configuration'
@echo ' burn-complete - Burn the most recent build to an SDCard (requires sudo)'
@echo ' burn-upgrade - Upgrade the contents an SDCard (requires sudo)'
@echo ' clean - Clean everything - run make xyz_defconfig after this'
@echo
@echo 'Configuration:'
@echo " menuconfig - Run Buildroot's menuconfig"
@echo ' linux-menuconfig - Run menuconfig on the Linux kernel'
@echo
@echo 'Nerves built-in configs:'
@$(foreach b, $(sort $(notdir $(wildcard configs/*_defconfig))), \
printf " %-29s - Build for %s\\n" $(b) $(b:_defconfig=);)