OpenULINK firmware: change .lnk file extension to .lk in "make clean"
[openocd.git] / src / jtag / drivers / OpenULINK / Makefile
blob8ef2d03f9395c02b6593a62d798db3645edeea4b
1 ############################################################################
2 # Copyright (C) 2011 by Martin Schmoelzer #
3 # <martin.schmoelzer@student.tuwien.ac.at> #
4 # #
5 # This program is free software; you can redistribute it and/or modify #
6 # it under the terms of the GNU General Public License as published by #
7 # the Free Software Foundation; either version 2 of the License, or #
8 # (at your option) any later version. #
9 # #
10 # This program is distributed in the hope that it will be useful, #
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of #
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
13 # GNU General Public License for more details. #
14 # #
15 # You should have received a copy of the GNU General Public License #
16 # along with this program; if not, write to the #
17 # Free Software Foundation, Inc., #
18 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. #
19 ############################################################################
21 # Define the name of our tools. Some distributions (e. g. Fedora) prefix
22 # the SDCC executables, change this accordingly!
23 PREFIX =
25 # Small Device C Compiler: http://sdcc.sourceforge.net/
26 CC = $(PREFIX)-sdcc
28 # 8051 assembler, part of the SDCC software package.
29 AS = $(PREFIX)-sdas8051
31 # SDCC produces quite messy Intel HEX files. This tool is be used to re-format
32 # those files. It is not required for the firmware download functionality in
33 # the OpenOCD driver, but the resulting file is smaller.
34 PACKIHX = $(PREFIX)-packihx
36 # GNU binutils size. Used to print the size of the IHX file generated by SDCC.
37 SIZE = size
39 # Source and header directories.
40 SRC_DIR = src
41 INCLUDE_DIR = include
43 CODE_SIZE = 0x1B00
45 # Starting address of __xdata variables. Since the OpenULINK firmware does not
46 # use any of the isochronous interrupts, we can use the isochronous buffer space
47 # as XDATA memory.
48 XRAM_LOC = 0x2000
49 XRAM_SIZE = 0x0800
51 CFLAGS = --std-sdcc99 --opt-code-size --model-small
52 LDFLAGS = --code-loc 0x0000 --code-size $(CODE_SIZE) --xram-loc $(XRAM_LOC) \
53 --xram-size $(XRAM_SIZE) --iram-size 256 --model-small
55 # list of base object files
56 OBJECTS = main.rel usb.rel protocol.rel jtag.rel delay.rel USBJmpTb.rel
57 HEADERS = $(INCLUDE_DIR)/main.h \
58 $(INCLUDE_DIR)/usb.h \
59 $(INCLUDE_DIR)/protocol.h \
60 $(INCLUDE_DIR)/jtag.h \
61 $(INCLUDE_DIR)/delay.h \
62 $(INCLUDE_DIR)/reg_ezusb.h \
63 $(INCLUDE_DIR)/io.h \
64 $(INCLUDE_DIR)/msgtypes.h
66 # Disable all built-in rules.
67 .SUFFIXES:
69 # Targets which are executed even when identically named file is present.
70 .PHONY: all, clean
72 all: ulink_firmware.ihx
73 $(SIZE) ulink_firmware.ihx
75 ulink_firmware.ihx: $(OBJECTS)
76 $(CC) -mmcs51 $(LDFLAGS) -o $@ $^
78 # Rebuild every C module (there are only 5 of them) if any header changes.
79 %.rel: $(SRC_DIR)/%.c $(HEADERS)
80 $(CC) -c $(CFLAGS) -mmcs51 -I$(INCLUDE_DIR) -o $@ $<
82 %.rel: $(SRC_DIR)/%.a51
83 $(AS) -lsgo $@ $<
85 clean:
86 rm -f *.asm *.lst *.rel *.rst *.sym *.ihx *.lk *.map *.mem
88 hex: ulink_firmware.ihx
89 $(PACKIHX) ulink_firmware.ihx > ulink_firmware.hex