forked from FunKey-Project/FunKey-OS
-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
167 lines (141 loc) · 5.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
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# Makefile for FunKey-OS
#
# Copyright (C) 2020 by Michel Stempin <[email protected]>
#
# This program 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 2 of the License, or
# (at your option) any later version.
#
# This program 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 this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
BRMAKE = buildroot/utils/brmake -C buildroot
BR = make -C buildroot
# Strip quotes and then whitespaces
qstrip = $(strip $(subst ",,$(1)))
#"))
# MESSAGE Macro -- display a message in bold type
MESSAGE = echo "$(shell date +%Y-%m-%dT%H:%M:%S) $(TERM_BOLD)\#\#\# $(call qstrip,$(1))$(TERM_RESET)"
TERM_BOLD := $(shell tput smso 2>/dev/null)
TERM_RESET := $(shell tput rmso 2>/dev/null)
.PHONY: fun source image update defconfig clean distclean
.IGNORE: _Makefile_
all: image update
@:
_Makefile_:
@:
%/Makefile:
@:
buildroot: buildroot/.git
@:
buildroot/.git:
@$(call MESSAGE,"Getting buildroot")
@git submodule init
@git submodule update
fun: buildroot Recovery/output/.config FunKey/output/.config
@$(call MESSAGE,"Making fun")
@$(call MESSAGE,"Making fun in Recovery")
@$(BRMAKE) BR2_EXTERNAL=../Recovery O=../Recovery/output
@$(call MESSAGE,"Making fun in FunKey")
@$(BRMAKE) BR2_EXTERNAL=../FunKey O=../FunKey/output
sdk: buildroot SDK/output/.config
@$(call MESSAGE,"Making FunKey SDK")
@$(BRMAKE) BR2_EXTERNAL=../SDK O=../SDK/output prepare-sdk
@$(call MESSAGE,"Generating SDK tarball")
@export LC_ALL=C; \
SDK=FunKey-sdk-DrUm78; \
grep -lr "$(shell pwd)/SDK/output/host" SDK/output/host | while read -r FILE ; do \
if file -b --mime-type "$${FILE}" | grep -q '^text/'; then \
sed -i "s|$(shell pwd)/SDK/output/host|/opt/$${SDK}|g" "$${FILE}"; \
fi; \
done; \
mkdir -p images; \
tar czf "images/$${SDK}.tar.gz" \
--owner=0 --group=0 --numeric-owner \
--transform="s#^$(patsubst /%,%,$(shell pwd))/SDK/output/host#$${SDK}#" \
-C / "$(patsubst /%,%,$(shell pwd))/SDK/output/host"; \
rm -f download/toolchain-external-custom/$${SDK}.tar.gz; \
mkdir -p download/toolchain-external-custom; \
ln -s ../../images/$${SDK}.tar.gz download/toolchain-external-custom/
FunKey/%: FunKey/output/.config
@$(call MESSAGE,"Making $(notdir $@) in $(subst /,,$(dir $@))")
@$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $(notdir $@)
Recovery/%: Recovery/output/.config
@$(call MESSAGE,"Making $(notdir $@) in $(subst /,,$(dir $@))")
@$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output $(notdir $@)
SDK/%: SDK/output/.config
@$(call MESSAGE,"Making $(notdir $@) in $(subst /,,$(dir $@))")
@$(BR) BR2_EXTERNAL=../SDK O=../SDK/output $(notdir $@)
#%: FunKey/output/.config
# @$(call MESSAGE,"Making $@ in FunKey")
# @$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output $@
source:
@$(call MESSAGE,"Getting sources")
@$(BR) BR2_EXTERNAL=../SDK O=../SDK/output source
@$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output source
@$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output source
image: fun
@$(call MESSAGE,"Creating disk image")
@rm -rf root tmp
@mkdir -p root tmp
@./Recovery/output/host/bin/genimage --loglevel 0 --inputpath .
@rm -rf root tmp
@mv images/sdcard.img images/FunKey-sdcard-DrUm78.img
image-prod: fun
@$(call MESSAGE,"Creating disk image")
@rm -rf root tmp
@mkdir -p root tmp
@./Recovery/output/host/bin/genimage --loglevel 0 --config "genimage-prod.cfg" --inputpath .
@rm -rf root tmp
@mv images/sdcard-prod.img images/FunKey-sdcard-prod-DrUm78.img
update: fun
@$(call MESSAGE,"Creating update file")
@rm -rf tmp
@mkdir -p tmp
@cp FunKey/board/funkey/sw-description tmp/
@cp FunKey/board/funkey/update_partition tmp/
@cd FunKey/output/images && \
rm -f rootfs.ext2.gz && \
gzip -k rootfs.ext2 &&\
mv rootfs.ext2.gz ../../../tmp/
@cd tmp && \
echo sw-description rootfs.ext2.gz update_partition | \
tr " " "\n" | \
cpio -o -H crc --quiet > ../images/FunKey-rootfs-DrUm78.fwu
@rm -rf tmp
defconfig:
@$(call MESSAGE,"Updating default configs")
@$(call MESSAGE,"Updating default configs in SDK")
@$(BR) BR2_EXTERNAL=../SDK O=../SDK/output savedefconfig
@$(call MESSAGE,"Updating default configs in Recovery")
@$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output savedefconfig linux-update-defconfig uboot-update-defconfig busybox-update-config
@$(call MESSAGE,"Updating default configs in FunKey")
@$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output savedefconfig linux-update-defconfig busybox-update-config
clean:
@$(call MESSAGE,"Clean everything")
@$(BR) BR2_EXTERNAL=../SDK O=../SDK/output distclean
@$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output distclean
@$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output distclean
@rm -f br.log
distclean: clean
@$(call MESSAGE,"Really clean everything")
@rm -rf download images
FunKey/output/.config:
@$(call MESSAGE,"Configure FunKey")
@mkdir -p FunKey/board/funkey/patches
@$(BR) BR2_EXTERNAL=../FunKey O=../FunKey/output funkey_defconfig
Recovery/output/.config:
@$(call MESSAGE,"Configure Recovery")
@mkdir -p Recovery/board/funkey/patches
@$(BR) BR2_EXTERNAL=../Recovery O=../Recovery/output recovery_defconfig
SDK/output/.config:
@$(call MESSAGE,"Configure SDK")
@mkdir -p SDK/board/funkey/patches
@$(BR) BR2_EXTERNAL=../SDK O=../SDK/output funkey_defconfig