work-in-progress on DDR3 firmware. sigh
[ls2.git] / coldboot / Makefile
1 ARCH = $(shell uname -m)
2 ifneq ("$(ARCH)", "ppc64")
3 ifneq ("$(ARCH)", "ppc64le")
4 CROSS_COMPILE ?= powerpc64le-linux-gnu-
5 endif
6 endif
7
8 # a multiplier factor on sleep loops. this allows simulations to run
9 # at much shorter intervals
10 LONG_TIMER_MULT = 10000
11 SHORT_TIMER_MULT = 100
12 #LONG_TIMER_MULT = 1
13 #SHORT_TIMER_MULT = 1
14
15 LIBGRAMDIR = ../libgram
16 LIBGRAMINC = ../libgram/include
17
18 GRAMOBJS := $(LIBGRAMDIR)/src/init.o \
19 $(LIBGRAMDIR)/src/dfii.o \
20 $(LIBGRAMDIR)/src/calibration.o
21
22 CC = $(CROSS_COMPILE)gcc
23 LD = $(CROSS_COMPILE)ld
24 OBJCOPY = $(CROSS_COMPILE)objcopy
25
26 CFLAGS = -Os -g -Wall -std=c99 -msoft-float -mno-string \
27 -mno-multiple -mno-vsx -mno-altivec -mlittle-endian \
28 -fno-stack-protector -mstrict-align -ffreestanding \
29 -fdata-sections -ffunction-sections -I../include \
30 -I $(LIBGRAMINC) \
31 -DLONG_TIMER_MULT=$(LONG_TIMER_MULT) \
32 -DSHORT_TIMER_MULT=$(SHORT_TIMER_MULT)
33 ASFLAGS = $(CFLAGS)
34 LDFLAGS = -T powerpc.lds
35
36 all: coldboot.hex
37
38 console.o: ../lib/console.c
39 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
40
41 init.o: ../libgram/src/init.c
42 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
43
44 dfii.o: ../libgram/src/dfii.c
45 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
46
47 calibration.o: ../libgram/src/calibration.c
48 $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
49
50 coldboot.elf: coldboot.o head.o ../lib/console.o $(GRAMOBJS)
51 $(LD) $(LDFLAGS) -o $@ $^
52
53 coldboot.bin: coldboot.elf
54 $(OBJCOPY) -O binary $^ $@
55
56 coldboot.hex: coldboot.bin
57 ../scripts/bin2hex.py $^ > $@
58 powerpc64le-linux-gnu-objdump -D coldboot.elf > coldboot.as
59
60
61 clean:
62 @rm -f *.o coldboot.elf coldboot.bin coldboot.hex coldboot.as
63 distclean: clean
64 rm -f *~
65