File: Makefile

package info (click to toggle)
mtd 20050122-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 6,244 kB
  • ctags: 9,869
  • sloc: ansic: 97,013; asm: 1,055; sh: 558; makefile: 356; cpp: 68
file content (58 lines) | stat: -rw-r--r-- 1,732 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# -*- make -*-
CC = gcc
AS86 = as86
LOADADDRESS=0x98000
CFLAGS = -O2 -fstrength-reduce -fomit-frame-pointer -m386 -Wall
CPPFLAGS = -DRELOC=$(LOADADDRESS) -DMOVEROM -DSTACKADDR=0xA0000-0x98000 -I ../fs/ffs2

# Enable this if your flash window is 4k
# CPPFLAGS += -DSMALLER

all: flashloader.rom sbc_gxx.rom

# To create the loader we first 
flashloader.rom: makerom rloader.bin start32.o components.a
	$(LD) -N -Ttext $(LOADADDRESS) -e _start -nostdlib -o $@.t start32.o components.a
	objcopy -O binary -R .note -R .comment $@.t $@.bin
	@-rm $@.t
	cat rloader.bin $@.bin > $@
	./makerom -i'Flash Loader Rom' $@
	
# We create a library to help the linker
components.a: misc.o main.o io.o
	@-rm $@ > /dev/null 2>&1
	$(AR) cq $@ $(filter %.o,$^)

sbc_gxx.rom: makerom rloader.bin start32.o sbc_gxx.a
	$(LD) -N -Ttext $(LOADADDRESS) -e _start -nostdlib -o $@.t start32.o \
	sbc_gxx.a
	objcopy -O binary -R .note -R .comment $@.t $@.bin
	@-rm $@.t
	cat rloader.bin $@.bin > $@
	./makerom -i'Flash Loader Rom' $@
	
# We create a library to help the linker
sbc_gxx.a: misc.o sbc_gxx_boot.o
	@-rm $@ > /dev/null 2>&1
	$(AR) cq $@ $(filter %.o,$^)
	
# The 16 bit boot code is written using the as86 assembler which is not syntax
# compatible with the AT&T like 'as' assembler. Throwback from when gnu as 
# could not output 16 bit code at all.
rloader.bin: loader.asm loader.inc
	$(CC) $(CFLAGS) $(CPPFLAGS) -x assembler-with-cpp -E $< | $(AS86) -0 -b rloader.bin.t -
	mv -f rloader.bin.t rloader.bin

io.o: ../fs/ffs2/io.c
	ln -sf ../fs/ffs2/io.c .
	$(CC) $(CFLAGS) $(CPPFLAGS) -c io.c -o $@

clean: 
	-rm -f *.a *.o *.bin *.rom makerom

%.o: %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@

%.o: %.S
	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@