1 | CC=mipsel-unknown-elf-gcc |
---|
2 | AS=mipsel-unknown-elf-as |
---|
3 | LD=mipsel-unknown-elf-ld |
---|
4 | DU=mipsel-unknown-elf-objdump |
---|
5 | |
---|
6 | SYS_OBJS = giet.o \ |
---|
7 | switch.o \ |
---|
8 | common.o \ |
---|
9 | ctx_handler.o \ |
---|
10 | drivers.o \ |
---|
11 | exc_handler.o \ |
---|
12 | irq_handler.o \ |
---|
13 | sys_handler.o \ |
---|
14 | init.o \ |
---|
15 | task_init.o |
---|
16 | |
---|
17 | BOOT_OBJS = reset.o \ |
---|
18 | boot_handler.o |
---|
19 | |
---|
20 | SYS_PATH = sys |
---|
21 | BOOT_PATH = boot |
---|
22 | MAP_PATH = xml |
---|
23 | LIBS_PATH = libs |
---|
24 | BUILD_DIR_NAME = build |
---|
25 | |
---|
26 | CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g |
---|
27 | |
---|
28 | SYS_INCLUDE = -I$(SYS_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. |
---|
29 | |
---|
30 | BOOT_INCLUDE = -I$(BOOT_PATH) -I$(MAP_PATH) -I$(LIBS_PATH) -I. |
---|
31 | |
---|
32 | #commons between sys and boot are: common.ld , mips_registers.h... |
---|
33 | |
---|
34 | TRASH= /dev/null||true |
---|
35 | |
---|
36 | .PHONY: apps prepare |
---|
37 | |
---|
38 | all: prepare soft.bin |
---|
39 | |
---|
40 | |
---|
41 | ## merge all *.bin to soft.bin |
---|
42 | soft.bin: boot.bin sys.bin map.bin apps |
---|
43 | make -C mover |
---|
44 | mover/mover.x -sm map.bin |
---|
45 | $(DU) -D $@ > $@.txt |
---|
46 | |
---|
47 | ## prepare the environement |
---|
48 | prepare: |
---|
49 | @mkdir $(BUILD_DIR_NAME) 2>$(TRASH) |
---|
50 | |
---|
51 | ## mapping compilation |
---|
52 | map.bin: map.xml |
---|
53 | make -C xml #compile the parser |
---|
54 | xml/xml2bin map.xml map.bin |
---|
55 | |
---|
56 | ## system compilation |
---|
57 | sys.bin: $(SYS_OBJS) $(SYS_PATH)/sys.ld |
---|
58 | (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(SYS_PATH)/sys.ld $(SYS_OBJS) ) |
---|
59 | (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) |
---|
60 | |
---|
61 | switch.o: $(SYS_PATH)/switch.s giet_config.h |
---|
62 | $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
63 | |
---|
64 | giet.o: $(SYS_PATH)/giet.s giet_config.h |
---|
65 | $(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
66 | |
---|
67 | task_init.o: $(SYS_PATH)/task_init.S giet_config.h |
---|
68 | #$(AS) -g -mips32 -o $(BUILD_DIR_NAME)/$@ $< |
---|
69 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
70 | $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt |
---|
71 | |
---|
72 | ctx_handler.o: $(SYS_PATH)/ctx_handler.c $(SYS_PATH)/ctx_handler.h giet_config.h |
---|
73 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
74 | |
---|
75 | exc_handler.o: $(SYS_PATH)/exc_handler.c $(SYS_PATH)/exc_handler.h giet_config.h |
---|
76 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
77 | |
---|
78 | irq_handler.o: $(SYS_PATH)/irq_handler.c $(SYS_PATH)/irq_handler.h giet_config.h |
---|
79 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
80 | |
---|
81 | sys_handler.o: $(SYS_PATH)/sys_handler.c $(SYS_PATH)/sys_handler.h giet_config.h |
---|
82 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
83 | |
---|
84 | drivers.o: $(SYS_PATH)/drivers.c $(SYS_PATH)/drivers.h giet_config.h |
---|
85 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
86 | |
---|
87 | common.o: $(SYS_PATH)/common.c $(SYS_PATH)/common.h giet_config.h |
---|
88 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
89 | |
---|
90 | init.o: $(SYS_PATH)/init.c giet_config.h |
---|
91 | $(CC) $(CFLAGS) $(SYS_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
92 | |
---|
93 | ## boot compilation |
---|
94 | boot.bin: $(BOOT_OBJS) $(BOOT_PATH)/boot.ld |
---|
95 | (cd $(BUILD_DIR_NAME); $(LD) -o ../$@ -T ../$(BOOT_PATH)/boot.ld $(BOOT_OBJS) ) |
---|
96 | (cd $(BUILD_DIR_NAME); $(DU) -D ../$@ > $@.txt) |
---|
97 | |
---|
98 | reset.o: $(BOOT_PATH)/reset.S giet_config.h |
---|
99 | $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
100 | $(DU) -D $(BUILD_DIR_NAME)/$@ > $(BUILD_DIR_NAME)/$@.txt |
---|
101 | |
---|
102 | boot_handler.o: $(BOOT_PATH)/boot_handler.c $(BOOT_PATH)/boot_handler.h giet_config.h |
---|
103 | $(CC) $(CFLAGS) $(BOOT_INCLUDE) -c -o $(BUILD_DIR_NAME)/$@ $< |
---|
104 | |
---|
105 | ## applications and libs compilation |
---|
106 | apps: |
---|
107 | @echo "---------------------------------------------BUILDING APPS------------------------------------------------------" |
---|
108 | make -C apps |
---|
109 | |
---|
110 | ### special rules |
---|
111 | clean: |
---|
112 | rm -f *.o *.bin *.txt core *~ 2>$(TRASH) |
---|
113 | make clean -C xml/ 2>$(TRASH) |
---|
114 | make clean -C mover/ 2>$(TRASH) |
---|
115 | make clean -C apps 2>$(TRASH) |
---|
116 | rm -r $(BUILD_DIR_NAME) 2>$(TRASH) |
---|