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