forked from kttec/kunteng-open-platform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
105 lines (86 loc) · 2.72 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
# kunteng openwrt platform for openwrt
# created @ 2016-03-15
DEPEND_PKGS := subversion build-essential \
libncurses5-dev zlib1g-dev gawk git ccache \
gettext libssl-dev xsltproc libxml-parser-perl gengetopt patch
KTOP_ROOT := $(shell pwd)
OPENWRT := $(KTOP_ROOT)/openwrt
CONFIG_FILENAME := config_kt
INSTALL_BIN:=install -m0755
INSTALL_DIR:=install -d -m0755
INSTALL_DATA:=install -m0644
INSTALL_CONF:=install -m0600
LOCAL_PACKAGE_PATH := $(KTOP_ROOT)/package
OPENWRT_PACKAGE_PATH := $(OPENWRT)/package
PACKAGES := $(shell ls $(LOCAL_PACKAGE_PATH))
RUNNING_THREADS := $(shell cat /proc/cpuinfo | grep -i '^processor\s\+:' | wc -l)
define package_install
echo $(PACKAGES)
for p in $(PACKAGES) ;do \
echo $p ;\
cp -vr $(LOCAL_PACKAGE_PATH)/$$p $(OPENWRT_PACKAGE_PATH)/; \
done
endef
define rely_check
# check openwrt-chaos_calmer source from github
@[ -d $(OPENWRT) ] && : || \
git clone http://121.194.169.198:8888/gukaiqiang/openwrt-official.git $(OPENWRT); \
cd $(OPENWRT); \
git checkout -b r47727 c5287f92027e9709262d2424bb0c121ab2a7597e
endef
define hostdepends
# Install required host components
@which dpkg >/dev/null 2>&1 || exit 0; \
for p in $(DEPEND_PKGS); do \
dpkg -s $$p >/dev/null 2>&1 || to_install="$$to_install$$p "; \
done; \
if [ -n "$$to_install" ]; then \
echo "Please install missing packages by running the following commands:"; \
echo " sudo apt-get update"; \
echo " sudo apt-get install $$to_install"; \
exit 1; \
fi;
endef
define do_patching
# patch kunteng routers on openwrt
cd $(OPENWRT); \
cat ../patches/*.patch | patch -p0
endef
define config_check
# check kunteng default config
@if [ ! -e $(OPENWRT)/.config ]; then \
if [ ! -e $(CONFIG_FILENAME) ]; then \
echo "******************************";\
echo "*** configuration file:'$(CONFIG_FILENAME)' and '.config' missing, ";\
echo "*** you need to specify a defaultconfiguration file named '$(CONFIG_FILENAME)'";\
echo "******************************";\
exit 1;\
else \
cp $(CONFIG_FILENAME) $(OPENWRT)/.config; \
fi; \
fi;
endef
kt_router: .kt_config_check
make -C $(OPENWRT) V=s -j$(RUNNING_THREADS)
.kt_config_check:.kt_patched
$(call config_check)
touch .kt_config_check
.kt_patched: .kt_check_openwrt_source
$(call package_install)
$(call do_patching)
@touch .kt_patched
.kt_check_openwrt_source:
$(call hostdepends)
$(call rely_check)
@touch .kt_check_openwrt_source
menuconfig: .kt_config_check
@cd $(OPENWRT); [ -f .config ] && cp .config .config.bak || :
@cp -vf $(CONFIG_FILENAME) $(OPENWRT)/.config
@touch $(CONFIG_FILENAME) # change modification time
@make -C $(OPENWRT) menuconfig
clean:
make clean -C $(OPENWRT) V=s
distclean:
echo $(PACKAGES)
rm -rf .kt_*
rm -rf $(OPENWRT)