summaryrefslogtreecommitdiff
path: root/libre/linux-libre-firmware/0001-Add-offline-files-and-a-toolchain-option-in-Makefile.patch
blob: a5dae8afa0b8fbd185dab1ccf1c47923398ec008 (plain)
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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
From 5ceda644200c8c84b9c1ea66f2ee677d374c34cb Mon Sep 17 00:00:00 2001
From: David P <megver83@parabola.nu>
Date: Fri, 7 Sep 2018 21:28:40 -0300
Subject: [PATCH] Add offline files, and a toolchain option in Makefile

The *.offline files are so if you want to build offline, you just have to
pass toolchains= unset, or toolchains=1 for downloading them (which is the
default). Read the INSTALL file for more.

Signed-off-by: David P <megver83@parabola.nu>
---
 INSTALL                                     | 20 +++++++
 Makefile                                    | 33 +++++++++--
 ath9k_htc/Makefile.offline                  |  8 +++
 ath9k_htc/target_firmware/configure.offline | 64 +++++++++++++++++++++
 carl9170fw/extra/sh-elf-linux.cmake.offline | 22 +++++++
 5 files changed, 143 insertions(+), 4 deletions(-)
 create mode 100644 ath9k_htc/Makefile.offline
 create mode 100755 ath9k_htc/target_firmware/configure.offline
 create mode 100644 carl9170fw/extra/sh-elf-linux.cmake.offline

diff --git a/INSTALL b/INSTALL
index 74c5cfd..733aab8 100644
--- a/INSTALL
+++ b/INSTALL
@@ -6,6 +6,14 @@ also specify targets to make. For example:
 
 Please see the included Makefile for a list of all available targets.
 
+Some firmwares download toolchains. If you want this, run "make"
+passing the "toolchains=1" option (this is the default). If, however,
+you want to build these firmwares using your system's cross-compilers,
+then run "make" with the "toolchains=" option unset (anything different
+from "1" works), like this:
+
+    make toolchains=
+
 Once the desired things are built, "make install" will put them into
 the appropriate place, which is /lib/firmware by default although you
 can override this with something like:
@@ -35,6 +43,18 @@ On GNU/Linux distros that use apt you can install these with:
     apt install binutils-arm-linux-gnueabi binutils-arm-none-eabi bison \
     cmake flex g++ gcc gcc-arm-linux-gnueabi gcc-arm-none-eabi gperf make wget
 
+And if you pretend to build everything offline, you will also need:
+
+    * GNU C cross-compiler for Xtensa:
+        - xtensa-elf-gcc
+        - xtensa-elf-ld
+        - xtensa-elf-objcopy
+    * GNU C cross-compiler for SuperH:
+        - sh-elf-gcc (with newlib support)
+        - sh-elf-ld
+        - sh-elf-objcopy
+    * Newlib for SuperH (sh-elf)
+
 CARL9170 Firmware Configuration
 When building the carl9170 firmware you will be prompted with
 configuration questions.
diff --git a/Makefile b/Makefile
index 21d16fb..3805eaf 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,7 @@
 shell=/bin/sh
 prefix=/lib/firmware
 install_program=install
+toolchains=1
 
 .PHONY:	all test clean install a56 as31 aica ath9k_htc_toolchain ath9k_htc av7110 b43-tools carl9170fw-toolchain carl9170fw cis-tools cis dsp56k ihex2fw isci keyspan_pda openfwwf usbdux
 
@@ -31,10 +32,22 @@ aica:
 	cd aica/arm && $(MAKE)
 
 ath9k_htc_toolchain:
-	cd ath9k_htc && $(MAKE) toolchain
+	if [[ "$(toolchains)" = 1 ]]; then \
+	  cd ath9k_htc && $(MAKE) toolchain; \
+	else \
+	  for f in $(shell find ath9k_htc -type f -name "*.offline") ; do \
+	    if [ "$(shell find ath9k_htc -type f -name "*.bak")" = "" ]; then \
+	      cp -v $${f%.offline} $${f%.offline}.bak ; \
+	      cp -v $$f $${f%.offline} ; \
+	    fi; \
+	  done; \
+	fi
 
 ath9k_htc: ath9k_htc_toolchain
-	cd ath9k_htc && $(MAKE) -C target_firmware
+	cd ath9k_htc && $(MAKE) -C target_firmware && \
+	for f in $(shell find -type f -name "*.bak") ; do \
+	  mv -v ../$$f ../$${f%.bak}; \
+	done
 
 av7110:
 	cd av7110 && $(MAKE)
@@ -43,10 +56,22 @@ b43-tools:
 	cd b43-tools/assembler && $(MAKE)
 
 carl9170fw-toolchain:
-	cd carl9170fw && $(MAKE) -C toolchain
+	if [[ "$(toolchains)" = 1 ]]; then \
+	  cd carl9170fw && $(MAKE) -C toolchain; \
+	else \
+	  for f in $(shell find carl9170fw -type f -name "*.offline") ; do \
+	    if [ "$(shell find carl9170fw -type f -name "*.bak")" = "" ]; then \
+	      cp -v $${f%.offline} $${f%.offline}.bak ; \
+	      cp -v $$f $${f%.offline} ; \
+	    fi; \
+	  done; \
+	fi
 
 carl9170fw: carl9170fw-toolchain
-	cd carl9170fw && ./autogen.sh
+	cd carl9170fw && ./autogen.sh && \
+	for f in $(shell find -type f -name "*.bak") ; do \
+	  mv -v ../$$f ../$${f%.bak}; \
+	done
 
 cis: cis-tools
 	cd cis && $(MAKE)
diff --git a/ath9k_htc/Makefile.offline b/ath9k_htc/Makefile.offline
new file mode 100644
index 0000000..958eaaa
--- /dev/null
+++ b/ath9k_htc/Makefile.offline
@@ -0,0 +1,8 @@
+all: firmware
+clean:
+	$(MAKE) -C target_firmware clean
+
+firmware:
+	+$(MAKE) -C target_firmware
+
+.PHONY: all clean firmware
diff --git a/ath9k_htc/target_firmware/configure.offline b/ath9k_htc/target_firmware/configure.offline
new file mode 100755
index 0000000..6e49093
--- /dev/null
+++ b/ath9k_htc/target_firmware/configure.offline
@@ -0,0 +1,64 @@
+#!/bin/sh
+##
+ # Copyright (c) 2013 Qualcomm Atheros, Inc.
+ #
+ # All rights reserved.
+ #
+ # Redistribution and use in source and binary forms, with or without
+ # modification, are permitted (subject to the limitations in the
+ # disclaimer below) provided that the following conditions are met:
+ #
+ #  * Redistributions of source code must retain the above copyright
+ #    notice, this list of conditions and the following disclaimer.
+ #
+ #  * Redistributions in binary form must reproduce the above copyright
+ #    notice, this list of conditions and the following disclaimer in the
+ #    documentation and/or other materials provided with the
+ #    distribution.
+ #
+ #  * Neither the name of Qualcomm Atheros nor the names of its
+ #    contributors may be used to endorse or promote products derived
+ #    from this software without specific prior written permission.
+ #
+ # NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
+ # GRANTED BY THIS LICENSE.  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT
+ # HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
+ # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ # BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ # IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ ##
+
+TARGET=xtensa-elf
+
+[ -z "$CROSS_COMPILE" ] &&
+    CROSS_COMPILE="$TARGET-"
+
+TOOLCHAIN_FILE="$PWD/build/toolchain.cmake"
+
+set -e
+rm -rf build
+mkdir -p build
+
+cat > "$TOOLCHAIN_FILE" <<EOF
+SET(CMAKE_SYSTEM_NAME Generic)
+SET(CMAKE_C_COMPILER  "${CROSS_COMPILE}gcc")
+EOF
+
+do_cmake() {
+	cmake -DCMAKE_TOOLCHAIN_FILE="$TOOLCHAIN_FILE" "$@"
+}
+
+mkdir -p build/k2 build/magpie
+cd build/k2
+do_cmake -DTARGET_K2=ON ../..
+cd -
+cd build/magpie
+do_cmake -DTARGET_MAGPIE=ON ../..
+cd -
diff --git a/carl9170fw/extra/sh-elf-linux.cmake.offline b/carl9170fw/extra/sh-elf-linux.cmake.offline
new file mode 100644
index 0000000..c0b1e84
--- /dev/null
+++ b/carl9170fw/extra/sh-elf-linux.cmake.offline
@@ -0,0 +1,22 @@
+set(CMAKE_SYSTEM_NAME "Generic")
+set(CMAKE_SYSTEM_PROCESSOR "sh2")
+
+set_property(DIRECTORY PROPERTY TARGET_SUPPORTS_SHARED_LIBS FALSE)
+
+set(CMAKE_FIND_ROOT_PATH /)
+
+set(CMAKE_C_FLAGS "-m2 -ml -Os -ffreestanding -nostartfiles")
+set(CMAKE_C_LINK_FLAGS "-Wl,-static,-EL,-x,--gc-sections")
+set(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
+
+set(OBJCOPY sh-elf-objcopy)
+set(CMAKE_C_COMPILER "sh-elf-gcc")
+set(CMAKE_AR sh-elf-ar)
+set(CMAKE_ASM_COMPILER sh-elf-as)
+set(CMAKE_ASM-ATT_COMPILER sh-elf-as)
+set(CMAKE_LINKER sh-elf-ld)
+set(CMAKE_C_LINK_EXECUTABLE "sh-elf-gcc <OBJECTS> ${CMAKE_C_FLAGS} <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -o <TARGET>")
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-- 
2.18.0