source: soft/giet_vm/Makefile @ 163

Last change on this file since 163 was 163, checked in by karaoui, 13 years ago

changing mover to memo
changing soft.bin to soft.elf
...

File size: 3.5 KB
RevLine 
[162]1export # export all variable to sub-Makefile
[158]2CC=mipsel-unknown-elf-gcc
3AS=mipsel-unknown-elf-as
4LD=mipsel-unknown-elf-ld
5DU=mipsel-unknown-elf-objdump
6
[162]7
8#current directory absolute path
9SOFT_PATH       = $(shell pwd)/
10
11SYS_NAME    = sys
12BOOT_NAME   = boot
13LIB_NAME    = libs
14
15SYS_PATH    = $(SOFT_PATH)$(SYS_NAME)
16BOOT_PATH   = $(SOFT_PATH)$(BOOT_NAME)
17LIB_PATH    = $(SOFT_PATH)$(LIB_NAME)
18MAP_PATH    = $(SOFT_PATH)xml/
19BUILD_PATH      = $(SOFT_PATH)build/
20ELF_PATH        = $(SOFT_PATH)build/
21
22#list of all applications directory
23APP_DIRS        = $(shell ls -d apps/*/ ) 
24
25SYS_OBJS_LIST = \
26                sys_handler.o \
27                init.o          \
28                giet.o \
[160]29                switch.o \
30                common.o \
31                ctx_handler.o \
32                drivers.o \
33                exc_handler.o \
34                irq_handler.o \
35                task_init.o
[158]36
[162]37BOOT_OBJS_LIST = reset.o \
38                                boot_handler.o
[158]39
[162]40#LIB_SRCS = $(wildcard $(LIB_NAME)/*.c)
41LIB_OBJS_LIST = stdio.o\
42                                mwmr.o\
43                                common.o
[158]44
[162]45LIB_OBJS = $(patsubst %,$(LIB_NAME)/%,$(LIB_OBJS_LIST))
46SYS_OBJS   = $(patsubst %,$(SYS_NAME)/%,$(SYS_OBJS_LIST))
47BOOT_OBJS   = $(patsubst %,$(BOOT_NAME)/%,$(BOOT_OBJS_LIST))
48
49
[160]50CFLAGS=-Wall -ffreestanding -mno-gpopt -mips32 -g
[158]51
[162]52SYS_INCLUDE = -I$(SYS_PATH) -I$(MAP_PATH) -I$(LIB_PATH) -I.
[158]53
[162]54BOOT_INCLUDE = -I$(BOOT_PATH) -I$(MAP_PATH) -I$(LIB_PATH) -I.
[158]55
[162]56INCLUDE         = -I$(LIB_PATH) -I$(SOFT_PATH) -I$(SYS_PATH) -I$(MAP_PATH)
[160]57
58TRASH= /dev/null||true
59
60.PHONY: apps prepare
61
[161]62all: prepare soft.elf
[160]63       
[161]64## merge all *.elf to soft.elf
65soft.elf: boot.elf sys.elf map.bin apps
[163]66        $(MAKE) -C memo
67        memo/memo.x  map.bin
[162]68        $(DU) -D $@ > $(BUILD_PATH)$@.txt
[160]69
70## prepare the environement
71prepare:
[162]72        @mkdir $(BUILD_PATH) 2>$(TRASH)
73        @mkdir $(ELF_PATH) 2>$(TRASH)
[160]74
[162]75## compile the parser
[158]76## mapping compilation
77map.bin: map.xml
[162]78        $(MAKE) -C xml                         
[158]79        xml/xml2bin map.xml map.bin
80
81## system compilation
[161]82sys.elf: $(SYS_OBJS) $(SYS_PATH)/sys.ld
[162]83        (cd $(BUILD_PATH); $(LD) -o $@ -T $(SYS_PATH)/sys.ld $(SYS_OBJS) )
84        (cd $(BUILD_PATH); $(DU) -D $@ > $@.txt)
[158]85
[162]86$(SYS_NAME)/%.o: $(SYS_NAME)/%.c
87        @mkdir $(BUILD_PATH)/$(SYS_NAME) 2>$(TRASH)
88        $(CC) $(SYS_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]89
[162]90$(SYS_NAME)/%.o: $(SYS_NAME)/%.s
91        @mkdir $(BUILD_PATH)/$(SYS_NAME) 2>$(TRASH)
92        $(CC) $(SYS_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]93
[162]94$(SYS_NAME)/%.o: $(SYS_NAME)/%.S
95        @mkdir $(BUILD_PATH)/$(SYS_NAME) 2>$(TRASH)
96        $(CC) $(SYS_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]97
[162]98## boot compilation
99boot.elf: $(BOOT_OBJS) $(BOOT_PATH)/boot.ld
100        (cd $(BUILD_PATH); $(LD) -o $@ -T $(BOOT_PATH)/boot.ld $(BOOT_OBJS) )
101        (cd $(BUILD_PATH); $(DU) -D $@ > $@.txt)
[158]102
[162]103$(BOOT_NAME)/%.o: $(BOOT_NAME)/%.c
104        @mkdir $(BUILD_PATH)/$(BOOT_NAME) 2>$(TRASH)
105        $(CC) $(BOOT_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]106
[162]107$(BOOT_NAME)/%.o: $(BOOT_NAME)/%.s
108        @mkdir $(BUILD_PATH)/$(BOOT_NAME) 2>$(TRASH)
109        $(CC) $(BOOT_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]110
[162]111$(BOOT_NAME)/%.o: $(BOOT_NAME)/%.S
112        @mkdir $(BUILD_PATH)/$(BOOT_NAME) 2>$(TRASH)
113        $(CC) $(BOOT_INCLUDE) $(CFLAGS)  -c -o $(BUILD_PATH)/$@ $<
[158]114
[162]115##libs compilation
116$(LIB_NAME)/%.o: $(LIB_NAME)/%.c
117        @mkdir $(BUILD_PATH)/$(LIB_NAME) 2>$(TRASH)
118        $(CC) $(CFLAGS) $(INCLUDE) -c -o $(BUILD_PATH)/$@ $<
[158]119
[162]120## applications
121apps: $(LIB_OBJS)
[160]122        @echo "---------------------------------------------BUILDING APPS------------------------------------------------------"
[162]123        set -e; for d in $(APP_DIRS); do $(MAKE)  -C $$d ; echo "Compiling $$d";  done
[158]124
125### special rules
126clean:
[161]127        rm -f *.o *.elf *.bin *.txt core *~  2>$(TRASH)
[162]128        $(MAKE) clean -C xml/ 2>$(TRASH)
[163]129        $(MAKE) clean -C memo/ 2>$(TRASH)
[162]130        rm -r $(BUILD_PATH) 2>$(TRASH)
131        set -e; for d in $(APP_DIRS); do $(MAKE) clean -C $$d ; done
Note: See TracBrowser for help on using the repository browser.