-
Notifications
You must be signed in to change notification settings - Fork 30
/
Makefile
58 lines (51 loc) · 1.59 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
TOPDIR:=${CURDIR}
SOURCE_DIR:=$(TOPDIR)/trunk
TOOLCHAIN_DIR:=$(TOPDIR)/toolchain-mipsel
TOOLCHAIN_ROOT:=$(TOOLCHAIN_DIR)/toolchain-3.4.x
TOOLCHAIN_URL:=https://github.com/vipshmily/Padavan-build/releases/download/toolchain/mipsel-linux-uclibc.tar.xz
TEMPLATE_DIR:=$(SOURCE_DIR)/configs/templates
PRODUCTS:=$(shell ls $(TEMPLATE_DIR) | sed 's/.config//g')
CONFIG:=$(SOURCE_DIR)/.config
all: build
toolchain/build:
@echo "Building toolchain..."
@(cd $(TOOLCHAIN_DIR); \
./bootstrap && \
./configure --enable-local && \
make && \
./ct-ng mipsel-linux-uclibc && \
./ct-ng build \
)
toolchain/clean:
@(cd $(TOOLCHAIN_DIR); \
if [ -f ct-ng ]; then ./ct-ng distclean; fi; \
if [ -f Makefile ]; then make distclean; fi; \
if [ -d $(TOOLCHAIN_ROOT) ]; then rm -rf $(TOOLCHAIN_ROOT); fi \
)
toolchain/download:
@if [ ! -d $(TOOLCHAIN_ROOT) ]; then \
echo "Downloading toolchain..."; \
mkdir -p $(TOOLCHAIN_ROOT); \
curl -fSsLo- $(TOOLCHAIN_URL) | tar Jx -C $(TOOLCHAIN_ROOT); \
fi
build: toolchain/download
@if [ ! -f $(CONFIG) ]; then \
echo "Please run 'make PRODUCT_NAME' to start build!"; \
echo "Supported products: $(PRODUCTS)"; \
exit 1; \
fi
$(MAKE) -C $(SOURCE_DIR)
clean:
@if [ ! -f $(CONFIG) ]; then \
echo "Project config file .config not found! Terminate."; \
exit 1; \
fi
$(MAKE) -C $(SOURCE_DIR) clean
@rm -f $(CONFIG)
@(cd $(SOURCE_DIR); ./clear_tree; ./clear_tree_simple)
.PHONY: $(PRODUCTS)
$(PRODUCTS):
cp -f $(TEMPLATE_DIR)/$(@).config $(CONFIG)
@echo "CONFIG_CROSS_COMPILER_ROOT=$(TOOLCHAIN_ROOT)" >> $(CONFIG)
@echo "CONFIG_CCACHE=y" >> $(CONFIG)
@make build