1# hcs12mem - HC12/S12 memory reader & writer
2# Makefile.hcs12: rules for processing HCS12 files
3#
4# Copyright (C) 2005 Michal Konieczny <mk@cml.mfk.net.pl>
5#
6# This program is free software; you can redistribute it and/or modify
7# it under the terms of the GNU General Public License as published by
8# the Free Software Foundation; either version 2 of the License, or
9# (at your option) any later version.
10#
11# This program is distributed in the hope that it will be useful,
12# but WITHOUT ANY WARRANTY; without even the implied warranty of
13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14# GNU General Public License for more details.
15#
16# You should have received a copy of the GNU General Public License
17# along with this program; if not, write to the Free Software
18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
20# target architecture
21
22ARCH = -m68hcs12 -mshort
23
24# executable names
25
26LD = m6811-elf-ld
27CC = m6811-elf-gcc
28AS = m6811-elf-as
29AR = m6811-elf-ar
30SIZE = m6811-elf-size
31OBJCOPY = m6811-elf-objcopy
32
33# flags
34
35ASFLAGS = $(ARCH) --short-branchs --strict-direct-mode
36CCFLAGS = $(ARCH) -ansi -Wall -pedantic -fsigned-char -g
37LDFLAGS = $(ARCH) -Wl,-m,m68hc12elfb -nostartfiles  -nodefaultlibs -g
38
39# objcopy section selection
40
41OBJCOPY_SECTIONS = \
42	--only-section=.text \
43	--only-section=.rodata \
44	--only-section=.vectors \
45	--only-section=.data
46
47# rules
48
49SUFFIXES = .o .elf .s19 .b
50
51%.o: $(srcdir)/%.s
52	$(AS) $(ASFLAGS) -o $@ $<
53%.o: $(srcdir)/%.S
54	$(CC) $(CCASFLAGS) -c -o $@ $<
55%.o: $(srcdir)/%.c
56	$(CC) $(CCFLAGS) -c -o $@ $<
57%.s: $(srcdir)/%.c
58	$(CC) $(CCFLAGS) -S -o $@ $<
59%.elf: %.o
60	$(CC) $(LDFLAGS) -o $@ $<
61%.elf: $(srcdir)/%.S
62	$(CC) $(CCFLAGS) $(LDFLAGS) -o $@ $<
63%.s19: %.elf
64	$(OBJCOPY) --output-target=srec $(OBJCOPY_SECTIONS) $< $@
65%.b: %.elf
66	$(OBJCOPY) --output-target=binary --gap-fill 0xff $(OBJCOPY_SECTIONS) $< $@
67