67bb1777bd55d85954135bd8635c825e90b96bf1
[dahdi/linux.git] / drivers / dahdi / firmware / Makefile
1 #
2 # DAHDI
3
4 # Makefile for firmware downloading/installation
5 #
6 # Copyright (C) 2007-2013, Digium, Inc.
7 #
8 # Joshua Colp <jcolp@digium.com>
9 #
10 #
11 # See http://www.asterisk.org for more information about
12 # the Asterisk project. Please do not directly contact
13 # any of the maintainers of this project for assistance;
14 # the project provides a web site, mailing lists and IRC
15 # channels for your use.
16 #
17 # This program is free software, distributed under the terms of
18 # the GNU General Public License Version 2 as published by the
19 # Free Software Foundation. See the LICENSE file included with
20 # this program for more details.
21 #
22
23 .PHONY: dist-clean clean all uninstall have_download install object-build hotplug-install hotplug-dirs hotplug-uninstall make_firmware_object firmware-loaders
24
25 OCT6114_032_VERSION:=1.05.01
26 OCT6114_064_VERSION:=1.05.01
27 OCT6114_128_VERSION:=1.05.01
28 OCT6114_256_VERSION:=1.05.01
29 TC400M_VERSION:=MR6.12
30 VPMADT032_VERSION:=1.25.0
31 HX8_VERSION:=2.06
32 VPMOCT032_VERSION:=1.12.0
33 WCT820_VERSION:=1.76
34 TE133_VERSION:=780017
35 TE134_VERSION:=780017
36 TE435_VERSION:=e0017
37 A8A_VERSION:=1d0017
38 A8B_VERSION:=1d0017
39 A4A_VERSION:=a0017
40 A4B_VERSION:=b0017
41
42 FIRMWARE_URL:=http://downloads.digium.com/pub/telephony/firmware/releases
43
44 ALL_FIRMWARE=FIRMWARE-OCT6114-032 FIRMWARE-OCT6114-064 FIRMWARE-OCT6114-128 FIRMWARE-OCT6114-256
45 ALL_FIRMWARE+=FIRMWARE-TC400M FIRMWARE-HX8 FIRMWARE-VPMOCT032 FIRMWARE-TE820 FIRMWARE-TE133 FIRMWARE-TE134
46 ALL_FIRMWARE+=FIRMWARE-A8A FIRMWARE-A8B FIRMWARE-A4A FIRMWARE-A4B FIRMWARE-TE435
47
48 # Firmware files should use the naming convention: dahdi-fw-<base name>-<sub name>-<version> or dahdi-fw-<base name>-<version>
49 # First example: dahdi-fw-oct6114-064-1.05.01
50 # This means this is version 1.05.01 of the oct6114-064 firmware
51 # Second example: dahdi-fw-tc400m-MR5.6
52 # This means this is version MR5.6 of the tc400m firmware
53
54 # Build a list of firmware package filenames we need
55 FIRMWARE:=$(ALL_FIRMWARE:FIRMWARE-OCT6114-032=dahdi-fw-oct6114-032-$(OCT6114_032_VERSION).tar.gz)
56 FIRMWARE:=$(FIRMWARE:FIRMWARE-OCT6114-064=dahdi-fw-oct6114-064-$(OCT6114_064_VERSION).tar.gz)
57 FIRMWARE:=$(FIRMWARE:FIRMWARE-OCT6114-128=dahdi-fw-oct6114-128-$(OCT6114_128_VERSION).tar.gz)
58 FIRMWARE:=$(FIRMWARE:FIRMWARE-OCT6114-256=dahdi-fw-oct6114-256-$(OCT6114_256_VERSION).tar.gz)
59 FIRMWARE:=$(FIRMWARE:FIRMWARE-TC400M=dahdi-fw-tc400m-$(TC400M_VERSION).tar.gz)
60 FIRMWARE:=$(FIRMWARE:FIRMWARE-HX8=dahdi-fw-hx8-$(HX8_VERSION).tar.gz)
61 FIRMWARE:=$(FIRMWARE:FIRMWARE-VPMOCT032=dahdi-fw-vpmoct032-$(VPMOCT032_VERSION).tar.gz)
62 FIRMWARE:=$(FIRMWARE:FIRMWARE-TE820=dahdi-fw-te820-$(WCT820_VERSION).tar.gz)
63 FIRMWARE:=$(FIRMWARE:FIRMWARE-TE133=dahdi-fw-te133-$(TE133_VERSION).tar.gz)
64 FIRMWARE:=$(FIRMWARE:FIRMWARE-TE134=dahdi-fw-te134-$(TE134_VERSION).tar.gz)
65 FIRMWARE:=$(FIRMWARE:FIRMWARE-TE435=dahdi-fw-te435-$(TE435_VERSION).tar.gz)
66 FIRMWARE:=$(FIRMWARE:FIRMWARE-A8A=dahdi-fw-a8b-$(A8B_VERSION).tar.gz)
67 FIRMWARE:=$(FIRMWARE:FIRMWARE-A8B=dahdi-fw-a8a-$(A8A_VERSION).tar.gz)
68 FIRMWARE:=$(FIRMWARE:FIRMWARE-A4A=dahdi-fw-a4b-$(A4B_VERSION).tar.gz)
69 FIRMWARE:=$(FIRMWARE:FIRMWARE-A4B=dahdi-fw-a4a-$(A4A_VERSION).tar.gz)
70
71 FWLOADERS:=dahdi-fwload-vpmadt032-$(VPMADT032_VERSION).tar.gz
72
73 # Build a list of object files if hotplug will not be used
74 OBJECT_FILES:=$(ALL_FIRMWARE:FIRMWARE-OCT6114-032=dahdi-fw-oct6114-032.o)
75 OBJECT_FILES:=$(ALL_FIRMWARE:FIRMWARE-OCT6114-064=dahdi-fw-oct6114-064.o)
76 OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-OCT6114-128=dahdi-fw-oct6114-128.o)
77 OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-OCT6114-256=dahdi-fw-oct6114-256.o)
78 OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-TC400M=dahdi-fw-tc400m.o)
79 OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-HX8=dahdi-fw-hx8.o)
80 OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-VPMOCT032=dahdi-fw-vpmoct032.o)
81
82 # Force usage of wget, for now
83 DOWNLOAD=wget
84 WGET=wget
85 INSTALL_FIRMWARE=../../../build_tools/install_firmware
86
87 # If "fetch" is used, --continue is not a valid option.
88 ifeq ($(WGET),wget)
89 WGET_ARGS:=--continue
90 endif
91
92 all: $(FIRMWARE)
93
94 # Clean up any downloaded/extracted firmware packages
95 dist-clean: clean
96         rm -f dahdi-fw-*.bin
97         rm -f dahdi-fw-*.tar.gz
98         rm -f dahdi-fwload-*.tar.gz
99         rm -f make_firmware_object
100
101 # Clean up anything we built
102 clean:
103         rm -f dahdi-fw-*.o
104
105 # Download and extract firmware tarballs
106 dahdi-fw-%.tar.gz:
107         @if ( [ "$(HOTPLUG_FIRMWARE)" = "no" ] ) || ( [ -d $(DESTDIR)/usr/lib/hotplug/firmware ] && ! [ -f $(DESTDIR)/usr/lib/hotplug/firmware/.$(subst .tar.gz,,$*) ] ) || ( [ -d $(DESTDIR)/lib/firmware ] && ! [ -f $(DESTDIR)/lib/firmware/.$(subst .tar.gz,,$*) ] ); then \
108                 echo "Attempting to download $@"; \
109                 if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; \
110                 if test ! -f $@; then exit 1; fi; \
111                 (cat $@ | gzip -d | tar --no-same-owner -xf -) \
112         fi
113
114 firmware-loaders: $(FWLOADERS)
115
116 .PHONY: dahdi-fwload-vpmadt032-$(VPMADT032_VERSION).tar.gz
117 dahdi-fwload-vpmadt032-$(VPMADT032_VERSION).tar.gz:
118         @if test ! -f $@; then echo "Attempting to download $@"; $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; \
119         if test ! -f $@; then exit 1; fi; \
120         (cd ../../..; cat drivers/dahdi/firmware/$@ | gzip -d | tar --no-same-owner -xf -)
121
122 # Create object files suitable for linking against
123 object-build: $(FIRMWARE) $(OBJECT_FILES)
124
125 $(DESTDIR)/usr/lib/hotplug/firmware $(DESTDIR)/lib/firmware:
126         mkdir -p $@
127
128 # Install all downloaded firmware images for hotplug usage
129 hotplug-install: $(DESTDIR)/usr/lib/hotplug/firmware $(DESTDIR)/lib/firmware $(FIRMWARE)
130         @$(INSTALL_FIRMWARE) dahdi-fw-oct6114-032 $(OCT6114_032_VERSION)
131         @$(INSTALL_FIRMWARE) dahdi-fw-oct6114-064 $(OCT6114_064_VERSION)
132         @$(INSTALL_FIRMWARE) dahdi-fw-oct6114-128 $(OCT6114_128_VERSION)
133         @$(INSTALL_FIRMWARE) dahdi-fw-oct6114-256 $(OCT6114_256_VERSION)
134         @$(INSTALL_FIRMWARE) dahdi-fw-tc400m $(TC400M_VERSION)
135         @$(INSTALL_FIRMWARE) dahdi-fw-hx8 $(HX8_VERSION)
136         @$(INSTALL_FIRMWARE) dahdi-fw-vpmoct032 $(VPMOCT032_VERSION)
137         @$(INSTALL_FIRMWARE) dahdi-fw-te820 $(WCT820_VERSION)
138         @$(INSTALL_FIRMWARE) dahdi-fw-te133 $(TE133_VERSION)
139         @$(INSTALL_FIRMWARE) dahdi-fw-te134 $(TE134_VERSION)
140         @$(INSTALL_FIRMWARE) dahdi-fw-te435 $(TE435_VERSION)
141         @$(INSTALL_FIRMWARE) dahdi-fw-a8a $(A8A_VERSION)
142         @$(INSTALL_FIRMWARE) dahdi-fw-a8b $(A8B_VERSION)
143         @$(INSTALL_FIRMWARE) dahdi-fw-a4a $(A4A_VERSION)
144         @$(INSTALL_FIRMWARE) dahdi-fw-a4b $(A4B_VERSION)
145
146 # Uninstall any installed dahdi firmware images from hotplug firmware directories
147 hotplug-uninstall:
148         if [ -d $(DESTDIR)/usr/lib/hotplug/firmware ]; then \
149                 rm -f $(DESTDIR)/usr/lib/hotplug/firmware/dahdi-fw-*.bin; \
150                 rm -f $(DESTDIR)/usr/lib/hotplug/firmware/.dahdi-fw*; \
151         fi
152         if [ -d $(DESTDIR)/lib/firmware ]; then \
153                 rm -f $(DESTDIR)/lib/firmware/dahdi-fw-*.bin; \
154                 rm -f $(DESTDIR)/lib/firmware/.dahdi-fw*; \
155         fi
156
157 make_firmware_object: make_firmware_object.in ../dahdi-base.o
158         @export BFDNAME=`LANG=C objdump -f ../dahdi-base.o | grep -e "dahdi-base.o:" | sed "s/.*file format \(.*\)/\1/"`; \
159          export BFDARCH=`LANG=C objdump -f ../dahdi-base.o | grep -e "architecture:" | sed "s/.*ture: \(.*\),.*/\1/"`; \
160          sed -e s/BFDNAME/$${BFDNAME}/ -e s/BFDARCH/$${BFDARCH}/ $< > $@
161         @chmod +x $@
162
163 # Build object file of an oct6114 032 firmware image for linking
164 dahdi-fw-oct6114-032.o: dahdi-fw-oct6114-032-$(OCT6114_032_VERSION).tar.gz dahdi-fw-oct6114-032.bin make_firmware_object
165         @echo Making firmware object file for dahdi-fw-oct6114-032.bin
166         ./make_firmware_object dahdi-fw-oct6114-032.bin $@
167
168 # Build object file of an oct6114 064 firmware image for linking
169 dahdi-fw-oct6114-064.o: dahdi-fw-oct6114-064-$(OCT6114_064_VERSION).tar.gz dahdi-fw-oct6114-064.bin make_firmware_object
170         @echo Making firmware object file for dahdi-fw-oct6114-064.bin
171         ./make_firmware_object dahdi-fw-oct6114-064.bin $@
172
173 # Build object file of an oct6114 128 firmware image for linking
174 dahdi-fw-oct6114-128.o: dahdi-fw-oct6114-128-$(OCT6114_128_VERSION).tar.gz dahdi-fw-oct6114-128.bin make_firmware_object
175         @echo Making firmware object file for dahdi-fw-oct6114-128.bin
176         ./make_firmware_object dahdi-fw-oct6114-128.bin $@
177
178 # Build object file of an oct6114 256 firmware image for linking
179 dahdi-fw-oct6114-256.o: dahdi-fw-oct6114-256-$(OCT6114_256_VERSION).tar.gz dahdi-fw-oct6114-256.bin make_firmware_object
180         @echo Making firmware object file for dahdi-fw-oct6114-256.bin
181         ./make_firmware_object dahdi-fw-oct6114-256.bin $@
182
183 # Build object file of a TC400M firmware image for linking
184 dahdi-fw-tc400m.o: dahdi-fw-tc400m-$(TC400M_VERSION).tar.gz dahdi-fw-tc400m.bin make_firmware_object
185         @echo Making firmware object file for dahdi-fw-tc400m.bin
186         ./make_firmware_object dahdi-fw-tc400m.bin $@
187
188 # Build object file of a VPMOCT032 firmware image for linking
189 dahdi-fw-vpmoct032.o: dahdi-fw-vpmoct032-$(VPMOCT032_VERSION).tar.gz dahdi-fw-vpmoct032.bin make_firmware_object
190         @echo Making firmware object file for dahdi-fw-vpmoct032.bin
191         ./make_firmware_object dahdi-fw-vpmoct032.bin $@