Statistics
| Branch: | Tag: | Revision:

root / images / Makefile @ master

History | View | Annotate | Download (9.9 kB)

1
#
2
# Copyright 2010-2011 Ettus Research LLC
3
#
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
8
#
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
# GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License
15
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
#
17

    
18
all:
19
	@echo "Pick a specific target"
20

    
21
########################################################################
22
# Common Variables
23
########################################################################
24
TOP_DIR = $(shell pwd)
25
TOP_FW_DIR = $(TOP_DIR)/../firmware
26
TOP_FPGA_DIR = $(TOP_DIR)/../fpga
27
BUILT_IMAGES_DIR = $(TOP_DIR)/images
28
CMAKE_BUILD_DIR = $(TOP_DIR)/build
29

    
30
##filled in below
31
IMAGES_LIST =
32

    
33
##little rule to make the images directory
34
$(BUILT_IMAGES_DIR):
35
	mkdir $@
36
	mkdir $@/bit
37

    
38
GLOBAL_DEPS = $(BUILT_IMAGES_DIR)
39

    
40
########################################################################
41
# Utility Checks
42
########################################################################
43
ifeq ($(shell sdcc --help > /dev/null 2>&1 && echo $$?),0)
44
	HAS_SDCC=1
45
endif
46

    
47
ifeq ($(shell zpu-elf-gcc --help > /dev/null 2>&1 && echo $$?),0)
48
	HAS_ZPU_GCC=1
49
endif
50

    
51
ifeq ($(shell xtclsh -h > /dev/null 2>&1 && echo $$?),0)
52
	HAS_XTCLSH=1
53
endif
54

    
55
########################################################################
56
# USRP1 and B100 firmware
57
########################################################################
58
ifdef HAS_SDCC
59

    
60
_usrp1_fw_dir = $(TOP_FW_DIR)/fx2
61
_usrp1_fw_ihx = $(BUILT_IMAGES_DIR)/usrp1_fw.ihx
62
_usrp_b100_fw_ihx = $(BUILT_IMAGES_DIR)/usrp_b100_fw.ihx
63
IMAGES_LIST += $(_usrp1_fw_ihx) $(_usrp_b100_fw_ihx)
64

    
65
$(_usrp1_fw_ihx): $(GLOBAL_DEPS)
66
	cd $(_usrp1_fw_dir) && rm -rf build
67
	cd $(_usrp1_fw_dir) && mkdir build
68
	cd $(_usrp1_fw_dir)/build && cmake ../
69
	cd $(_usrp1_fw_dir)/build && make
70
	cp $(_usrp1_fw_dir)/build/usrp1/usrp1_fw.ihx $@
71

    
72
$(_usrp_b100_fw_ihx): $(_usrp1_fw_ihx)
73
	cp $(_usrp1_fw_dir)/build/b100/b100_fw.ihx $(_usrp_b100_fw_ihx)
74

    
75
endif
76

    
77
########################################################################
78
# USRP1 fpga
79
########################################################################
80
_usrp1_fpga_dir = $(TOP_FPGA_DIR)/usrp1/rbf/rev4
81
_usrp1_fpga_rbf = $(BUILT_IMAGES_DIR)/usrp1_fpga.rbf
82
_usrp1_fpga_4rx_rbf = $(BUILT_IMAGES_DIR)/usrp1_fpga_4rx.rbf
83
IMAGES_LIST += $(_usrp1_fpga_rbf) $(_usrp1_fpga_4rx_rbf)
84

    
85
$(_usrp1_fpga_rbf): $(GLOBAL_DEPS)
86
	cp $(_usrp1_fpga_dir)/std_2rxhb_2tx.rbf $@
87

    
88
$(_usrp1_fpga_4rx_rbf): $(GLOBAL_DEPS)
89
	cp $(_usrp1_fpga_dir)/std_4rx_0tx.rbf $@
90

    
91
########################################################################
92
# USRP-B100 fpga
93
########################################################################
94
ifdef HAS_XTCLSH
95

    
96
_usrp_b100_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/B100
97
_usrp_b100_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_b100_fpga.bin
98
IMAGES_LIST += $(_usrp_b100_fpga_bin)
99

    
100
$(_usrp_b100_fpga_bin): $(GLOBAL_DEPS)
101
	cd $(_usrp_b100_fpga_dir) && make -f Makefile.B100 clean
102
	cd $(_usrp_b100_fpga_dir) && make -f Makefile.B100 bin
103
	cp $(_usrp_b100_fpga_dir)/build-B100/B100.bin $@
104

    
105
endif
106

    
107
########################################################################
108
# USRP2 and N Series firmware
109
########################################################################
110
ifdef HAS_ZPU_GCC
111

    
112
_usrp2_fw_dir = $(TOP_FW_DIR)/zpu
113
_usrp2_fw_bin = $(BUILT_IMAGES_DIR)/usrp2_fw.bin
114
_usrp_n200_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n200_fw.bin
115
_usrp_n210_fw_bin = $(BUILT_IMAGES_DIR)/usrp_n210_fw.bin
116
IMAGES_LIST += $(_usrp2_fw_bin) $(_usrp_n200_fw_bin) $(_usrp_n210_fw_bin)
117

    
118
$(_usrp2_fw_bin): $(GLOBAL_DEPS)
119
	cd $(_usrp2_fw_dir) && rm -rf build
120
	cd $(_usrp2_fw_dir) && mkdir build
121
	cd $(_usrp2_fw_dir)/build && cmake ../
122
	cd $(_usrp2_fw_dir)/build && make
123
	cp $(_usrp2_fw_dir)/build/usrp2/usrp2_txrx_uhd.bin $@
124

    
125
$(_usrp_n200_fw_bin): $(_usrp2_fw_bin)
126
	cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $@
127

    
128
$(_usrp_n210_fw_bin): $(_usrp2_fw_bin)
129
	cp $(_usrp2_fw_dir)/build/usrp2p/usrp2p_txrx_uhd.bin $@
130

    
131
endif
132

    
133
########################################################################
134
# USRP2 fpga
135
########################################################################
136
ifdef HAS_XTCLSH
137

    
138
_usrp2_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/USRP2
139
_usrp2_fpga_bin = $(BUILT_IMAGES_DIR)/usrp2_fpga.bin
140
IMAGES_LIST += $(_usrp2_fpga_bin)
141

    
142
$(_usrp2_fpga_bin): $(GLOBAL_DEPS)
143
	cd $(_usrp2_fpga_dir) && make clean
144
	cd $(_usrp2_fpga_dir) && make bin
145
	cp $(_usrp2_fpga_dir)/build/u2_rev3.bin $@
146

    
147
endif
148

    
149
########################################################################
150
# USRP-N200 R2/R3 fpga
151
########################################################################
152
ifdef HAS_XTCLSH
153

    
154
_usrp_n200_r3_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/N2x0
155
_usrp_n200_r3_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n200_r3_fpga.bin
156
_usrp_n200_r3_fpga_bit = $(BUILT_IMAGES_DIR)/bit/usrp_n200_r3_fpga.bit
157
IMAGES_LIST += $(_usrp_n200_r3_fpga_bin) $(_usrp_n200_r3_fpga_bit)
158

    
159
$(_usrp_n200_r3_fpga_bin): $(GLOBAL_DEPS)
160
	cd $(_usrp_n200_r3_fpga_dir) && make -f Makefile.N200R3 clean
161
	cd $(_usrp_n200_r3_fpga_dir) && make -f Makefile.N200R3 bin
162
	cp $(_usrp_n200_r3_fpga_dir)/build-N200R3/u2plus.bin $@
163

    
164
$(_usrp_n200_r3_fpga_bit): $(_usrp_n200_r3_fpga_bin)
165
	cp $(_usrp_n200_r3_fpga_dir)/build-N200R3/u2plus.bit $@
166

    
167
#its called r2 on the silkscreen, so make an r2
168
_usrp_n200_r2_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n200_r2_fpga.bin
169
IMAGES_LIST += $(_usrp_n200_r2_fpga_bin)
170
$(_usrp_n200_r2_fpga_bin): $(_usrp_n200_r3_fpga_bin)
171
	cp $< $@
172

    
173
endif
174

    
175
########################################################################
176
# USRP-N210 R2/R3 fpga
177
########################################################################
178
ifdef HAS_XTCLSH
179

    
180
_usrp_n210_r3_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/N2x0
181
_usrp_n210_r3_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n210_r3_fpga.bin
182
_usrp_n210_r3_fpga_bit = $(BUILT_IMAGES_DIR)/bit/usrp_n210_r3_fpga.bit
183
IMAGES_LIST += $(_usrp_n210_r3_fpga_bin) $(_usrp_n210_r3_fpga_bit)
184

    
185
$(_usrp_n210_r3_fpga_bin): $(GLOBAL_DEPS)
186
	cd $(_usrp_n210_r3_fpga_dir) && make -f Makefile.N210R3 clean
187
	cd $(_usrp_n210_r3_fpga_dir) && make -f Makefile.N210R3 bin
188
	cp $(_usrp_n210_r3_fpga_dir)/build-N210R3/u2plus.bin $@
189

    
190
$(_usrp_n210_r3_fpga_bit): $(_usrp_n210_r3_fpga_bin)
191
	cp $(_usrp_n210_r3_fpga_dir)/build-N210R3/u2plus.bit $@
192

    
193
#its called r2 on the silkscreen, so make an r2
194
_usrp_n210_r2_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n210_r2_fpga.bin
195
IMAGES_LIST += $(_usrp_n210_r2_fpga_bin)
196
$(_usrp_n210_r2_fpga_bin): $(_usrp_n210_r3_fpga_bin)
197
	cp $< $@
198

    
199
endif
200

    
201
########################################################################
202
# USRP-N200 R4 fpga
203
########################################################################
204
ifdef HAS_XTCLSH
205

    
206
_usrp_n200_r4_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/N2x0
207
_usrp_n200_r4_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n200_r4_fpga.bin
208
_usrp_n200_r4_fpga_bit = $(BUILT_IMAGES_DIR)/bit/usrp_n200_r4_fpga.bit
209
IMAGES_LIST += $(_usrp_n200_r4_fpga_bin) $(_usrp_n200_r4_fpga_bit)
210

    
211
$(_usrp_n200_r4_fpga_bin): $(GLOBAL_DEPS)
212
	cd $(_usrp_n200_r4_fpga_dir) && make -f Makefile.N200R4 clean
213
	cd $(_usrp_n200_r4_fpga_dir) && make -f Makefile.N200R4 bin
214
	cp $(_usrp_n200_r4_fpga_dir)/build-N200R4/u2plus.bin $@
215

    
216
$(_usrp_n200_r4_fpga_bit): $(_usrp_n200_r4_fpga_bin)
217
	cp $(_usrp_n200_r4_fpga_dir)/build-N200R4/u2plus.bit $@
218

    
219
endif
220

    
221
########################################################################
222
# USRP-N210 R4 fpga
223
########################################################################
224
ifdef HAS_XTCLSH
225

    
226
_usrp_n210_r4_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/N2x0
227
_usrp_n210_r4_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_n210_r4_fpga.bin
228
_usrp_n210_r4_fpga_bit = $(BUILT_IMAGES_DIR)/bit/usrp_n210_r4_fpga.bit
229
IMAGES_LIST += $(_usrp_n210_r4_fpga_bin) $(_usrp_n210_r4_fpga_bit)
230

    
231
$(_usrp_n210_r4_fpga_bin): $(GLOBAL_DEPS)
232
	cd $(_usrp_n210_r4_fpga_dir) && make -f Makefile.N210R4 clean
233
	cd $(_usrp_n210_r4_fpga_dir) && make -f Makefile.N210R4 bin
234
	cp $(_usrp_n210_r4_fpga_dir)/build-N210R4/u2plus.bin $@
235

    
236
$(_usrp_n210_r4_fpga_bit): $(_usrp_n210_r4_fpga_bin)
237
	cp $(_usrp_n210_r4_fpga_dir)/build-N210R4/u2plus.bit $@
238

    
239
endif
240

    
241
########################################################################
242
# USRP-E100 fpga
243
########################################################################
244
ifdef HAS_XTCLSH
245

    
246
_usrp_e100_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/E1x0
247
_usrp_e100_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_e100_fpga_v2.bin
248
IMAGES_LIST += $(_usrp_e100_fpga_bin)
249

    
250
$(_usrp_e100_fpga_bin): $(GLOBAL_DEPS)
251
	cd $(_usrp_e100_fpga_dir) && make -f Makefile.E100 clean
252
	cd $(_usrp_e100_fpga_dir) && make -f Makefile.E100 bin
253
	cp $(_usrp_e100_fpga_dir)/build-E100/u1e.bin $@
254

    
255
endif
256

    
257
########################################################################
258
# USRP-E110 fpga
259
########################################################################
260
ifdef HAS_XTCLSH
261

    
262
_usrp_e110_fpga_dir = $(TOP_FPGA_DIR)/usrp2/top/E1x0
263
_usrp_e110_fpga_bin = $(BUILT_IMAGES_DIR)/usrp_e110_fpga.bin
264
IMAGES_LIST += $(_usrp_e110_fpga_bin)
265

    
266
$(_usrp_e110_fpga_bin): $(GLOBAL_DEPS)
267
	cd $(_usrp_e110_fpga_dir) && make -f Makefile.E110 clean
268
	cd $(_usrp_e110_fpga_dir) && make -f Makefile.E110 bin
269
	cp $(_usrp_e110_fpga_dir)/build-E110/u1e.bin $@
270

    
271
endif
272

    
273
########################################################################
274
# Build rules
275
########################################################################
276
images: $(IMAGES_LIST)
277
	find $(BUILT_IMAGES_DIR) -type f | xargs chmod -x
278
	find $(TOP_FPGA_DIR) -name "*.twr" | xargs grep constraint | grep met
279

    
280
package:
281
	mkdir -p $(CMAKE_BUILD_DIR)
282
	cd $(CMAKE_BUILD_DIR) && cmake -DUHD_RELEASE_MODE=OFF ..
283
	cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=TGZ .. && make package
284
	cd $(CMAKE_BUILD_DIR) && cmake -DCPACK_GENERATOR=ZIP .. && make package
285

    
286
clean:
287
	$(RM) -rf $(BUILT_IMAGES_DIR)
288
	$(RM) -rf $(CMAKE_BUILD_DIR)