[88] | 1 | # |
---|
| 2 | # $Id: Makefile.Software 139 2010-07-30 14:47: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 | |
---|
[137] | 15 | include $(MORPHEO_TOPLEVEL)/Softwares/Makefile.defs |
---|
| 16 | |
---|
[78] | 17 | #-----[ Directory ]--------------------------------------------------------------- |
---|
[137] | 18 | |
---|
[88] | 19 | DIR_OBJ = obj |
---|
| 20 | DIR_BIN = bin |
---|
[78] | 21 | |
---|
[138] | 22 | EXE = soft_$(OS)_$(TARGET) |
---|
[78] | 23 | |
---|
[137] | 24 | DIR_COMMON = $(MORPHEO_TOPLEVEL)/Softwares/Common |
---|
| 25 | DIR_COMMON_C = $(DIR_COMMON)/src/c |
---|
| 26 | DIR_COMMON_ASM = $(DIR_COMMON)/src/asm |
---|
| 27 | DIR_COMMON_SYS = $(DIR_COMMON)/src/sys |
---|
| 28 | DIR_COMMON_INC = $(DIR_COMMON)/include |
---|
[100] | 29 | |
---|
[138] | 30 | #PREFIX_OBJ = $(OS)_$(TARGET)_ |
---|
| 31 | # |
---|
| 32 | #SOURCES_COMMON = $(wildcard $(DIR_COMMON_SYS)/*.s)\ |
---|
| 33 | # $(wildcard $(DIR_COMMON_ASM)/*.s)\ |
---|
| 34 | # $(wildcard $(DIR_COMMON_C)/*.c) |
---|
| 35 | # |
---|
| 36 | #TEST = $(addprefix $(DIR_OBJ)/$(PREFIX_OBJ), $(addsuffix .o, $(basename $(notdir $(SOURCES_COMMON))))) |
---|
[100] | 37 | |
---|
[138] | 38 | OBJECTS_COMMON = $(patsubst $(DIR_COMMON_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_SYS)/*.s))\ |
---|
| 39 | $(patsubst $(DIR_COMMON_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_ASM)/*.s))\ |
---|
| 40 | $(patsubst $(DIR_COMMON_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_C)/*.c)) |
---|
[100] | 41 | |
---|
[78] | 42 | #-----[ To the compilation ]------------------------------------------------------ |
---|
[112] | 43 | |
---|
[137] | 44 | #~~~~~[ OS : Newlib ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 45 | NEWLIB_DIR_LDSCRIPT = $(NEWLIB)/lib/ |
---|
| 46 | #NEWLIB_INCDIR |
---|
| 47 | #NEWLIB_LIBDIR |
---|
| 48 | #NEWLIB_LIBNAME |
---|
| 49 | NEWLIB_OBJECTS = $(NEWLIB)/lib/*.o |
---|
| 50 | |
---|
| 51 | #~~~~~[ OS : UNIX ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 52 | UNIX_DIR_LDSCRIPT = |
---|
| 53 | UNIX_INCDIR = |
---|
| 54 | UNIX_LIBDIR = |
---|
| 55 | UNIX_LIBNAME = -lm |
---|
| 56 | UNIX_OBJECTS = |
---|
| 57 | |
---|
[138] | 58 | #~~~~~[ TARGET : COMMON ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[139] | 59 | COMMON_OPTIMIZE = -O2 -std=c99 -Wall -Wlong-long |
---|
[137] | 60 | |
---|
[138] | 61 | COMMON_CC_OPT = $(INCDIR) -D$(OS) -D$(TARGET) $($(TARGET)_OPTIMIZE) $(FLAGS) |
---|
| 62 | COMMON_AS_OPT = |
---|
| 63 | COMMON_LD_OPT = $(LIBDIR) $(LIBNAME) -static |
---|
| 64 | COMMON_OBJDUMP_OPT = -D |
---|
| 65 | COMMON_NM_OPT = -n |
---|
| 66 | |
---|
[137] | 67 | #~~~~~[ TARGET : MORPHEO ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[138] | 68 | MORPHEO_OPTIMIZE = $(COMMON_OPTIMIZE) -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
[137] | 69 | |
---|
[78] | 70 | #Option : |
---|
| 71 | # -fomit-frame-pointer : n'utilise pas le pointeur de frame |
---|
| 72 | # -fdelayed-branch : utilise les delayed slot |
---|
| 73 | # ON OFF |
---|
| 74 | # -mror -mno-ror : utilisation de l'instruction l.ror |
---|
| 75 | # -mcmov -mno-cmov : utilisation de l'instruction l.cmov |
---|
| 76 | # -msext -mno-sext : utilisation des instructions l.extXX |
---|
| 77 | # -mhard-mul -msoft-mul : utilisation du multiplieur materiel |
---|
| 78 | # -mhard-div -msoft-div : utilisation du diviseur materiel |
---|
| 79 | # -mhard-float -msoft-float : utilisation du flottant materiel |
---|
| 80 | # -msibcall -mno-sibcall : Enable sibcall optimization |
---|
| 81 | # -mlogue -mno-logue : Schedule pro/epi-logue. |
---|
| 82 | # -maj -mno-aj : Use aligned jumps. |
---|
| 83 | |
---|
| 84 | # Tools |
---|
[138] | 85 | PREFIX_MORPHEO = or32-elf- |
---|
[78] | 86 | |
---|
[138] | 87 | MORPHEO_CC = $(OR1K_BIN)/$(PREFIX_MORPHEO)gcc |
---|
| 88 | MORPHEO_AS = $(OR1K_BIN)/$(PREFIX_MORPHEO)as |
---|
| 89 | MORPHEO_LD = $(OR1K_BIN)/$(PREFIX_MORPHEO)ld |
---|
| 90 | MORPHEO_OBJDUMP = $(OR1K_BIN)/$(PREFIX_MORPHEO)objdump |
---|
| 91 | MORPHEO_NM = $(OR1K_BIN)/$(PREFIX_MORPHEO)nm |
---|
| 92 | |
---|
[78] | 93 | # Tools's option |
---|
[138] | 94 | MORPHEO_CC_OPT = $(COMMON_CC_OPT) |
---|
| 95 | MORPHEO_AS_OPT = $(COMMON_AS_OPT) |
---|
| 96 | MORPHEO_LD_OPT = $(COMMON_LD_OPT) -T$(DIR_LDSCRIPT)/or32.ld $(OR1K_LIBDIR) $(OR1K_LIBNAME) |
---|
| 97 | MORPHEO_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) |
---|
| 98 | MORPHEO_NM_OPT = $(COMMON_NM_OPT) |
---|
[78] | 99 | |
---|
[137] | 100 | #~~~~~[ TARGET : x86 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
[138] | 101 | x86_OPTIMIZE = $(COMMON_OPTIMIZE) |
---|
[137] | 102 | |
---|
| 103 | x86_CC = gcc |
---|
| 104 | x86_AS = as |
---|
| 105 | x86_LD = gcc |
---|
| 106 | x86_OBJDUMP = objdump |
---|
| 107 | x86_NM = nm |
---|
| 108 | |
---|
[138] | 109 | x86_CC_OPT = $(COMMON_CC_OPT) |
---|
| 110 | x86_AS_OPT = $(COMMON_AS_OPT) |
---|
| 111 | x86_LD_OPT = $(COMMON_LD_OPT) |
---|
| 112 | x86_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) |
---|
| 113 | x86_NM_OPT = $(COMMON_NM_OPT) |
---|
[137] | 114 | |
---|
[138] | 115 | #~~~~~[ TARGET : EV67 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
| 116 | EV67_OPTIMIZE = $(COMMON_OPTIMIZE) -mtune="ev4" |
---|
| 117 | |
---|
| 118 | PREFIX_EV67 = alphaev67-unknown-linux-gnu- |
---|
| 119 | #PREFIX_EV67 = alpha-unknown-linux-gnu- |
---|
| 120 | |
---|
| 121 | EV67_CC = $(EV67_BIN)/$(PREFIX_EV67)gcc |
---|
| 122 | EV67_AS = $(EV67_BIN)/$(PREFIX_EV67)as |
---|
| 123 | EV67_LD = $(EV67_BIN)/$(PREFIX_EV67)gcc |
---|
| 124 | EV67_OBJDUMP = $(EV67_BIN)/$(PREFIX_EV67)objdump |
---|
[139] | 125 | EV67_NM = $(EV67_BIN)/$(PREFIX_EV67)nm |
---|
[138] | 126 | |
---|
[139] | 127 | EV67_CC_OPT = $(COMMON_CC_OPT) |
---|
| 128 | EV67_AS_OPT = $(COMMON_AS_OPT) |
---|
| 129 | EV67_LD_OPT = $(COMMON_LD_OPT) |
---|
[138] | 130 | EV67_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) |
---|
| 131 | EV67_NM_OPT = $(COMMON_NM_OPT) |
---|
| 132 | |
---|
[78] | 133 | #-----[ Rules ]------------------------------------------------------------------- |
---|
[88] | 134 | .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o |
---|
[78] | 135 | |
---|
[101] | 136 | vpath %.h $(DIR_INC):$(DIR_COMMON_INC) |
---|
| 137 | vpath %.c $(DIR_C):$(DIR_COMMON_C) |
---|
| 138 | vpath %.s $(DIR_ASM):$(DIR_SYS):$(DIR_COMMON_ASM):$(DIR_COMMON_SYS) |
---|
[88] | 139 | vpath %.o $(DIR_OBJ) |
---|
| 140 | vpath %.x $(DIR_BIN) |
---|
[78] | 141 | |
---|
[124] | 142 | all : $(DIR_BIN)/$(EXE).x |
---|
[78] | 143 | |
---|
[124] | 144 | $(DIR_BIN)/%.x : $(DIR_BIN) $(DIR_OBJ) |
---|
[88] | 145 | @\ |
---|
[139] | 146 | $(MAKE) $(OBJECTS); \ |
---|
| 147 | $(ECHO) "Linkage : $*.x"; \ |
---|
| 148 | $($(TARGET)_LD) -o $@ $(OBJECTS) $($(TARGET)_LD_OPT); \ |
---|
| 149 | $(ECHO) "List symbols : $*.x.nm"; \ |
---|
[137] | 150 | $($(TARGET)_NM) $($(TARGET)_NM_OPT) $@ > $@.nm; \ |
---|
[139] | 151 | $(ECHO) "Display info : $*.x.txt"; \ |
---|
| 152 | $($(TARGET)_OBJDUMP) $($(TARGET)_OBJDUMP_OPT) $@ > $@.txt; \ |
---|
[112] | 153 | echo $($(GREP) "l.jal 0" $@.txt); |
---|
[78] | 154 | |
---|
[88] | 155 | $(DIR_OBJ)/%.o : %.s |
---|
| 156 | @\ |
---|
[139] | 157 | $(ECHO) "Compilation : $*.s"; \ |
---|
[137] | 158 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
| 159 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
[78] | 160 | |
---|
[88] | 161 | $(DIR_OBJ)/%.o : %.c |
---|
| 162 | @\ |
---|
[139] | 163 | $(ECHO) "Compilation : $*.c"; \ |
---|
[137] | 164 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
| 165 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
[78] | 166 | |
---|
[124] | 167 | $(DIR_BIN) $(DIR_OBJ) : |
---|
| 168 | @\ |
---|
| 169 | $(MKDIR) $@; |
---|
| 170 | |
---|
[78] | 171 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
| 172 | clean : |
---|
| 173 | @\ |
---|
[88] | 174 | $(ECHO) "Delete temporary files"; \ |
---|
[139] | 175 | $(RM) $(DIR_OBJ) \ |
---|
| 176 | *~ \ |
---|
| 177 | $(DIR_SRC)/*~ \ |
---|
| 178 | $(DIR_C)/*~ \ |
---|
| 179 | $(DIR_ASM)/*~ \ |
---|
| 180 | $(DIR_SYS)/*~ \ |
---|
| 181 | $(DIR_INC)/*~ \ |
---|
| 182 | $(DIR_LDSCRIPT)/*~ |
---|
[78] | 183 | |
---|
[139] | 184 | clean_all : clean |
---|
[124] | 185 | $(RM) $(DIR_BIN) |
---|
[78] | 186 | |
---|
| 187 | #-----[ Help ]-------------------------------------------------------------------- |
---|
| 188 | help : |
---|
| 189 | @\ |
---|
[139] | 190 | $(ECHO) ""; \ |
---|
| 191 | $(ECHO) "List of directive : "; \ |
---|
| 192 | $(ECHO) " * all : Compile the software"; \ |
---|
| 193 | $(ECHO) " * clean : Erase all files generates"; \ |
---|
| 194 | $(ECHO) " * clean_all : Erase all files generates"; \ |
---|
[78] | 195 | $(ECHO) ""; |
---|