1 | # |
---|
2 | # $Id: Makefile.Software 139 2010-07-30 14:47:27Z rosiere $ |
---|
3 | # |
---|
4 | # [ Description ] |
---|
5 | # |
---|
6 | # Makefile |
---|
7 | # |
---|
8 | |
---|
9 | ifeq ($(origin MORPHEO_TOPLEVEL), undefined) |
---|
10 | $(error "variable MORPHEO_TOPLEVEL is undefined") |
---|
11 | else |
---|
12 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
13 | endif |
---|
14 | |
---|
15 | include $(MORPHEO_TOPLEVEL)/Softwares/Makefile.defs |
---|
16 | |
---|
17 | #-----[ Directory ]--------------------------------------------------------------- |
---|
18 | |
---|
19 | DIR_OBJ = obj |
---|
20 | DIR_BIN = bin |
---|
21 | |
---|
22 | EXE = soft_$(OS)_$(TARGET) |
---|
23 | |
---|
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 |
---|
29 | |
---|
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))))) |
---|
37 | |
---|
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)) |
---|
41 | |
---|
42 | #-----[ To the compilation ]------------------------------------------------------ |
---|
43 | |
---|
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 | |
---|
58 | #~~~~~[ TARGET : COMMON ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
59 | COMMON_OPTIMIZE = -O2 -std=c99 -Wall -Wlong-long |
---|
60 | |
---|
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 | |
---|
67 | #~~~~~[ TARGET : MORPHEO ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
68 | MORPHEO_OPTIMIZE = $(COMMON_OPTIMIZE) -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
69 | |
---|
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 |
---|
85 | PREFIX_MORPHEO = or32-elf- |
---|
86 | |
---|
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 | |
---|
93 | # Tools's option |
---|
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) |
---|
99 | |
---|
100 | #~~~~~[ TARGET : x86 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
101 | x86_OPTIMIZE = $(COMMON_OPTIMIZE) |
---|
102 | |
---|
103 | x86_CC = gcc |
---|
104 | x86_AS = as |
---|
105 | x86_LD = gcc |
---|
106 | x86_OBJDUMP = objdump |
---|
107 | x86_NM = nm |
---|
108 | |
---|
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) |
---|
114 | |
---|
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 |
---|
125 | EV67_NM = $(EV67_BIN)/$(PREFIX_EV67)nm |
---|
126 | |
---|
127 | EV67_CC_OPT = $(COMMON_CC_OPT) |
---|
128 | EV67_AS_OPT = $(COMMON_AS_OPT) |
---|
129 | EV67_LD_OPT = $(COMMON_LD_OPT) |
---|
130 | EV67_OBJDUMP_OPT = $(COMMON_OBJDUMP_OPT) |
---|
131 | EV67_NM_OPT = $(COMMON_NM_OPT) |
---|
132 | |
---|
133 | #-----[ Rules ]------------------------------------------------------------------- |
---|
134 | .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o |
---|
135 | |
---|
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) |
---|
139 | vpath %.o $(DIR_OBJ) |
---|
140 | vpath %.x $(DIR_BIN) |
---|
141 | |
---|
142 | all : $(DIR_BIN)/$(EXE).x |
---|
143 | |
---|
144 | $(DIR_BIN)/%.x : $(DIR_BIN) $(DIR_OBJ) |
---|
145 | @\ |
---|
146 | $(MAKE) $(OBJECTS); \ |
---|
147 | $(ECHO) "Linkage : $*.x"; \ |
---|
148 | $($(TARGET)_LD) -o $@ $(OBJECTS) $($(TARGET)_LD_OPT); \ |
---|
149 | $(ECHO) "List symbols : $*.x.nm"; \ |
---|
150 | $($(TARGET)_NM) $($(TARGET)_NM_OPT) $@ > $@.nm; \ |
---|
151 | $(ECHO) "Display info : $*.x.txt"; \ |
---|
152 | $($(TARGET)_OBJDUMP) $($(TARGET)_OBJDUMP_OPT) $@ > $@.txt; \ |
---|
153 | echo $($(GREP) "l.jal 0" $@.txt); |
---|
154 | |
---|
155 | $(DIR_OBJ)/%.o : %.s |
---|
156 | @\ |
---|
157 | $(ECHO) "Compilation : $*.s"; \ |
---|
158 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
159 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
160 | |
---|
161 | $(DIR_OBJ)/%.o : %.c |
---|
162 | @\ |
---|
163 | $(ECHO) "Compilation : $*.c"; \ |
---|
164 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
165 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
166 | |
---|
167 | $(DIR_BIN) $(DIR_OBJ) : |
---|
168 | @\ |
---|
169 | $(MKDIR) $@; |
---|
170 | |
---|
171 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
172 | clean : |
---|
173 | @\ |
---|
174 | $(ECHO) "Delete temporary files"; \ |
---|
175 | $(RM) $(DIR_OBJ) \ |
---|
176 | *~ \ |
---|
177 | $(DIR_SRC)/*~ \ |
---|
178 | $(DIR_C)/*~ \ |
---|
179 | $(DIR_ASM)/*~ \ |
---|
180 | $(DIR_SYS)/*~ \ |
---|
181 | $(DIR_INC)/*~ \ |
---|
182 | $(DIR_LDSCRIPT)/*~ |
---|
183 | |
---|
184 | clean_all : clean |
---|
185 | $(RM) $(DIR_BIN) |
---|
186 | |
---|
187 | #-----[ Help ]-------------------------------------------------------------------- |
---|
188 | help : |
---|
189 | @\ |
---|
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"; \ |
---|
195 | $(ECHO) ""; |
---|