# # Asterisk -- A telephony toolkit for Linux. # # Makefile for firmware downloading/installation # # Copyright (C) 2007, Digium, Inc. # # Joshua Colp # # This program is free software, distributed under the terms of # the GNU General Public License # .PHONY: dist-clean all uninstall have_download install -include $(ASTTOPDIR)/menuselect.makeopts $(ASTTOPDIR)/makeopts PWD:=$(shell pwd) OCT6114_064_VERSION:=1.05.01 OCT6114_128_VERSION:=1.05.01 TC400M_VERSION:=MR5.6 FIRMWARE_URL:=http://ftp.digium.com/pub/telephony/firmware/releases # Firmware files should use the naming convention: zaptel-fw--- or zaptel-fw-- # First example: zaptel-fw-oct6114-064-1.05.01 # This means this is version 1.05.01 of the oct6114 64 firmware # Second example: zaptel-fw-tc400m-MR5.6 # This means this is version MR5.6 of the tc400m firmware # Build a list of firmware package filenames we need FIRMWARE:=$(MENUSELECT_FIRMWARE:FIRMWARE-OCT6114-064=zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).tar.gz) FIRMWARE:=$(FIRMWARE:FIRMWARE-OCT6114-128=zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).tar.gz) FIRMWARE:=$(FIRMWARE:FIRMWARE-TC400M=zaptel-fw-tc400m-$(TC400M_VERSION).tar.gz) # Build a list of object files if hotplug will not be used OBJECT_FILES:=$(MENUSELECT_FIRMWARE:FIRMWARE-OCT6114-064=zaptel-fw-oct6114-064.o) OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-OCT6114-128=zaptel-fw-oct6114-128.o) OBJECT_FILES:=$(OBJECT_FILES:FIRMWARE-TC400M=zaptel-fw-tc400m.o) # Build a list of firmware header files to include that give the current version of firmware HEADER_FILES:=$(MENUSELECT_FIRMWARE:FIRMWARE-OCT6114-064=zaptel-fw-oct6114-064.h) HEADER_FILES:=$(HEADER_FILES:FIRMWARE-OCT6114-128=zaptel-fw-oct6114-128.h) HEADER_FILES:=$(HEADER_FILES:FIRMWARE-TC400M=zaptel-fw-tc400m.h) # If "fetch" is used, --continue is not a valid option. ifeq ($(WGET),wget) WGET_ARGS:=--continue endif all: $(FIRMWARE) have_download: @if test "$(DOWNLOAD)" = ":" ; then \ echo "**************************************************"; \ echo "*** ***"; \ echo "*** You must have either wget or fetch to be ***"; \ echo "*** able to automatically download and install ***"; \ echo "*** the requested firmware packages. ***"; \ echo "*** ***"; \ echo "**************************************************"; \ exit 1; \ fi # Download and extract firmware tarball zaptel-fw-%.tar.gz: have_download @if test ! -f $@; then $(DOWNLOAD) $(WGET_ARGS) $(FIRMWARE_URL)/$@; fi; if test ! -f $@; then exit 1; fi; \ (cat $@ | gzip -d | tar -xf -) # Clean up any downloaded/extracted firmware packages dist-clean: clean rm -f zaptel-fw-*.bin rm -f zaptel-fw-*.tar.gz # Clean up anything we built clean: rm -f zaptel-fw-*.o rm -f zaptel-fw-*.h # Create object files suitable for linking against object-build: $(FIRMWARE) $(OBJECT_FILES) # Create header files suitable for including header-build: $(FIRMWARE) $(HEADER_FILES) # Install all downloaded firmware images for hotplug usage and build headers for inclusion hotplug-install: $(FIRMWARE) if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \ $(INSTALL) -m 644 zaptel-fw-*.bin $(INSTALL_PREFIX)/usr/lib/hotplug/firmware; \ fi if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \ $(INSTALL) -m 644 zaptel-fw-*.bin $(INSTALL_PREFIX)/lib/firmware; \ fi # Uninstall any installed zaptel firmware images from hotplug firmware directories hotplug-uninstall: if [ -d $(INSTALL_PREFIX)/usr/lib/hotplug/firmware ]; then \ rm -f $(INSTALL_PREFIX)/usr/lib/hotplug/firmware/zaptel-fw-*.bin; \ fi if [ -d $(INSTALL_PREFIX)/lib/firmware ]; then \ rm -f $(INSTALL_PREFIX)/lib/firmware/zaptel-fw-*.bin; \ fi # Build object file of an oct6114 064 firmware image for linking zaptel-fw-oct6114-064.o: ../wct4xxp/base.o zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin @echo Making firmware object file for zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin @echo Temporarily copying to zaptel-fw-oct6114-064.bin @cp zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin zaptel-fw-oct6114-064.bin ../build_tools/make_firmware_object zaptel-fw-oct6114-064.bin $@ ../wct4xxp/base.o @rm -f zaptel-fw-oct6114-064.bin # Build header file of an oct6114 064 firmware image for inclusion zaptel-fw-oct6114-064.h: zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin @echo Making firmware header file for zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin @echo "static const char *zaptel_fw_oct6114_064 = \"zaptel-fw-oct6114-064-$(OCT6114_064_VERSION).bin\";" > $@ # Build object file of an oct6114 128 firmware image for linking zaptel-fw-oct6114-128.o: ../wct4xxp/base.o zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin @echo Making firmware object file for zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin @echo Temporarily copying to zaptel-fw-oct6114-128.bin @cp zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin zaptel-fw-oct6114-128.bin ../build_tools/make_firmware_object zaptel-fw-oct6114-128.bin $@ ../wct4xxp/base.o @rm -f zaptel-fw-oct6114-128.bin # Build header file of an oct6114 128 firmware image for inclusion zaptel-fw-oct6114-128.h: zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin @echo Making firmware header file for zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin @echo "static const char *zaptel_fw_oct6114_128 = \"zaptel-fw-oct6114-128-$(OCT6114_128_VERSION).bin\";" > $@ # Build object file of a TC400M firmware image for linking zaptel-fw-tc400m.o: # Build header file of a TC400M firmware image for inclusion zaptel-fw-tc400m.h: