[88] | 1 | # |
---|
| 2 | # $Id: Makefile.Software 117 2009-05-16 14:42:39Z rosiere $ |
---|
| 3 | # |
---|
| 4 | # [ Description ] |
---|
| 5 | # |
---|
| 6 | # Makefile |
---|
| 7 | # |
---|
[78] | 8 | |
---|
[88] | 9 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
| 10 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
| 11 | else |
---|
| 12 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
| 13 | endif |
---|
| 14 | |
---|
[78] | 15 | #-----[ Directory ]--------------------------------------------------------------- |
---|
[88] | 16 | DIR_OBJ = obj |
---|
| 17 | DIR_BIN = bin |
---|
[78] | 18 | |
---|
| 19 | EXE = soft |
---|
| 20 | |
---|
[100] | 21 | DIR_COMMON = $(MORPHEO_TOPLEVEL)/Softwares/Common |
---|
[101] | 22 | DIR_COMMON_C = $(DIR_COMMON)/src/c |
---|
| 23 | DIR_COMMON_ASM = $(DIR_COMMON)/src/asm |
---|
| 24 | DIR_COMMON_SYS = $(DIR_COMMON)/src/sys |
---|
| 25 | DIR_COMMON_INC = $(DIR_COMMON)/include |
---|
[100] | 26 | |
---|
[101] | 27 | OBJECTS_COMMON = $(patsubst $(DIR_COMMON_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_SYS)/*.s)) \ |
---|
| 28 | $(patsubst $(DIR_COMMON_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_ASM)/*.s)) \ |
---|
[100] | 29 | $(patsubst $(DIR_COMMON_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_C)/*.c)) |
---|
| 30 | |
---|
| 31 | |
---|
[78] | 32 | #-----[ To the compilation ]------------------------------------------------------ |
---|
[111] | 33 | OPTIMIZE = -O2 -std=c99 -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
[112] | 34 | |
---|
[78] | 35 | #Option : |
---|
| 36 | # -fomit-frame-pointer : n'utilise pas le pointeur de frame |
---|
| 37 | # -fdelayed-branch : utilise les delayed slot |
---|
| 38 | # ON OFF |
---|
| 39 | # -mror -mno-ror : utilisation de l'instruction l.ror |
---|
| 40 | # -mcmov -mno-cmov : utilisation de l'instruction l.cmov |
---|
| 41 | # -msext -mno-sext : utilisation des instructions l.extXX |
---|
| 42 | # -mhard-mul -msoft-mul : utilisation du multiplieur materiel |
---|
| 43 | # -mhard-div -msoft-div : utilisation du diviseur materiel |
---|
| 44 | # -mhard-float -msoft-float : utilisation du flottant materiel |
---|
| 45 | # -msibcall -mno-sibcall : Enable sibcall optimization |
---|
| 46 | # -mlogue -mno-logue : Schedule pro/epi-logue. |
---|
| 47 | # -maj -mno-aj : Use aligned jumps. |
---|
| 48 | |
---|
| 49 | # Tools |
---|
[81] | 50 | OR32_CC = $(OR1K_BIN)/or32-elf-gcc |
---|
| 51 | OR32_AS = $(OR1K_BIN)/or32-elf-as |
---|
| 52 | OR32_LD = $(OR1K_BIN)/or32-elf-ld |
---|
| 53 | OR32_OBJDUMP = $(OR1K_BIN)/or32-elf-objdump |
---|
| 54 | OR32_NM = $(OR1K_BIN)/or32-elf-nm |
---|
[78] | 55 | |
---|
| 56 | # Tools's option |
---|
[117] | 57 | OR32_CC_OPT = -Wall $(INCDIR) $(OPTIMIZE) -Wlong-long -DMorpheo $(FLAGS) |
---|
[78] | 58 | # -DHAVE_LIBC |
---|
[81] | 59 | OR32_AS_OPT = |
---|
[112] | 60 | OR32_LD_OPT = -T$(DIR_LDSCRIPT)/or32.ld $(LIBDIR) $(LIBNAME) $(OR1K_LIBDIR) $(OR1K_LIBNAME) |
---|
[81] | 61 | OR32_OBJDUMP_OPT = -D |
---|
| 62 | OR32_NM_OPT = -n |
---|
[78] | 63 | |
---|
| 64 | #-----[ Rules ]------------------------------------------------------------------- |
---|
[88] | 65 | .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o |
---|
[78] | 66 | |
---|
[101] | 67 | vpath %.h $(DIR_INC):$(DIR_COMMON_INC) |
---|
| 68 | vpath %.c $(DIR_C):$(DIR_COMMON_C) |
---|
| 69 | vpath %.s $(DIR_ASM):$(DIR_SYS):$(DIR_COMMON_ASM):$(DIR_COMMON_SYS) |
---|
[88] | 70 | vpath %.o $(DIR_OBJ) |
---|
| 71 | vpath %.x $(DIR_BIN) |
---|
[78] | 72 | |
---|
[88] | 73 | all : |
---|
[78] | 74 | @\ |
---|
[88] | 75 | $(MKDIR) $(DIR_BIN) $(DIR_OBJ); \ |
---|
| 76 | $(MAKE) $(DIR_BIN)/$(EXE).x; |
---|
[78] | 77 | |
---|
[88] | 78 | $(DIR_BIN)/%.x : $(OBJECTS) |
---|
| 79 | @\ |
---|
| 80 | $(ECHO) "Linkage : $*.x"; \ |
---|
| 81 | $(OR32_LD) -o $@ $^ $(OR32_LD_OPT); \ |
---|
| 82 | $(ECHO) "List symbols : $*.x.nm"; \ |
---|
[114] | 83 | $(OR32_NM) $(OR32_NM_OPT) $@ > $@.nm; \ |
---|
[112] | 84 | $(ECHO) "Display info : $*.x.txt"; \ |
---|
| 85 | $(OR32_OBJDUMP) $(OR32_OBJDUMP_OPT) $@ > $@.txt;\ |
---|
| 86 | echo $($(GREP) "l.jal 0" $@.txt); |
---|
[78] | 87 | |
---|
[88] | 88 | $(DIR_OBJ)/%.o : %.s |
---|
| 89 | @\ |
---|
| 90 | $(ECHO) "Compilation : $*.s"; \ |
---|
[117] | 91 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; |
---|
| 92 | # $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
[78] | 93 | |
---|
[88] | 94 | $(DIR_OBJ)/%.o : %.c |
---|
| 95 | @\ |
---|
| 96 | $(ECHO) "Compilation : $*.c"; \ |
---|
[117] | 97 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; |
---|
| 98 | # $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
[78] | 99 | |
---|
| 100 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
| 101 | clean : |
---|
| 102 | @\ |
---|
[88] | 103 | $(ECHO) "Delete temporary files"; \ |
---|
| 104 | $(RM) $(DIR_OBJ) $(DIR_BIN) \ |
---|
| 105 | *~ \ |
---|
| 106 | $(DIR_SRC)/*~ \ |
---|
| 107 | $(DIR_C)/*~ \ |
---|
| 108 | $(DIR_ASM)/*~ \ |
---|
| 109 | $(DIR_SYS)/*~ \ |
---|
| 110 | $(DIR_INC)/*~ \ |
---|
| 111 | $(DIR_LDSCRIPT)/*~ \ |
---|
[78] | 112 | |
---|
[88] | 113 | clean_all : clean |
---|
[78] | 114 | |
---|
| 115 | #-----[ Help ]-------------------------------------------------------------------- |
---|
| 116 | help : |
---|
| 117 | @\ |
---|
| 118 | $(ECHO) "";\ |
---|
| 119 | $(ECHO) "List of directive : ";\ |
---|
[88] | 120 | $(ECHO) " * all : Compile the software";\ |
---|
| 121 | $(ECHO) " * clean : Erase all files generates";\ |
---|
| 122 | $(ECHO) " * clean_all : Erase all files generates";\ |
---|
[78] | 123 | $(ECHO) ""; |
---|