Skip to content
Newer
Older
100644 75 lines (58 sloc) 2.37 KB
cf264b8 @jpbonn Added clang "hello world" sample.
jpbonn authored
1 #
2 # To use this test harness Makefile:
3 # 1) checkout the Milkymist SOC git repository
4 # git clone git://github.com/milkymist/milkymist.git
5 # 2) build the SOC bios software (see the SOC README)
6 # ./build_bios.sh
7 # 3) Set MMDIR to the SOC directory
8 # 4) Add your files to the OBJECTS variable
9 # 5) set the CC variable appropriately
10 # 6) make depend
11 # 7) make
12 #
13 MMDIR=/Users/jpbonn/Documents/soc/milkymist
14 # Set BOARDOBJSDIR to the directory containing the
15 # startup files (crt0.c, init.c, isr.c)
16 BOARDOBJSDIR=/Users/jpbonn/Documents/clang-demos/hello
17
18 BIOSOBJECTS=$(BOARDOBJSDIR)/crt0.o $(BOARDOBJSDIR)/init.o $(BOARDOBJSDIR)/isr.o
19 OBJECTS = $(BIOSOBJECTS) main.o
20
21 # Mico32 toolchain
22 #
23 #CC=lm32-rtems4.11-gcc
24 CC=/Users/jpbonn/Documents/mico32/install2/bin/clang -march=mico32 -ccc-host-triple mico32-elf -ccc-gcc-name /opt/rtems-4.11/bin/lm32-rtems4.11-gcc
25 GCC=lm32-rtems4.11-gcc
26 AS=lm32-rtems4.11-as
27 LD=lm32-rtems4.11-ld
28 OBJCOPY=lm32-rtems4.11-objcopy
29 AR=lm32-rtems4.11-ar
30 RANLIB=lm32-rtems4.11-ranlib
31
32
33 # Toolchain options
34 #
35 INCLUDES=-I$(MMDIR)/software/include -I$(MMDIR)/software/include/base -I$(MMDIR)/tools
36 ASFLAGS=$(INCLUDES)
37 CFLAGS=-O3 -g -nostdinc -Wall -mbarrel-shift-enabled -mmultiply-enabled -mdivide-enabled -msign-extend-enabled -fno-builtin -fsigned-char -fsingle-precision-constant $(INCLUDES)
38 LDFLAGS=-nostdinc -nostdlib -nodefaultlibs
39
40 SEGMENTS=-j .text -j .data -j .rodata
41
42 all: main.elf main-rescue.elf
43
44 %.bin: %.elf
45 $(MAKE) -C $(MMDIR)/tools
46 $(OBJCOPY) $(SEGMENTS) -O binary $< $@
47 chmod -x $@
48 $(MMDIR)/tools/mkmmimg $@ write
49
50 # make sure the linker*.ld at the first of depends
51 main.elf: $(BOARDOBJSDIR)/linker.ld $(OBJECTS)
52 main-rescue.elf: $(BOARDOBJSDIR)/linker-rescue.ld $(OBJECTS)
53
54 # The following files use inline assembly so we need to use GCC:
55 $(BOARDOBJSDIR)/init.o: $(BOARDOBJSDIR)/init.c
56 $(GCC) $(CFLAGS) -c -o $@ $<
57
58 $(BOARDOBJSDIR)/isr.o: $(BOARDOBJSDIR)/isr.c
59 $(GCC) $(CFLAGS) -c -o $@ $<
60
61 %.elf:
62 $(LD) $(LDFLAGS) -T $< -N -o $@ $(OBJECTS) -L$(MMDIR)/software/libhpdmc -L$(MMDIR)/software/libbase -L$(MMDIR)/software/libhal -L$(MMDIR)/software/libnet --start-group -lhpdmc -lbase-light -lhal -lnet --end-group
63 chmod -x $@
64
65 .PHONY: clean depend
66
67 depend:
68 makedepend -Y -- $(CFLAGS) -- *.c $(BOARDOBJSDIR)/*.c
69
70 clean:
71 rm -f *.o main.elf main.bin main-rescue.elf main-rescue.bin .*~ *~ Makefile.bak $(BOARDOBJSDIR)/*.o
72
73
74 # The following lines will get regenerated by "make depend":
Something went wrong with that request. Please try again.