1 | # |
---|
2 | # $Id: Makefile.Software 137 2010-02-16 12:35:48Z 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 |
---|
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 | OBJECTS_COMMON = $(patsubst $(DIR_COMMON_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_SYS)/*.s))\ |
---|
31 | $(patsubst $(DIR_COMMON_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_ASM)/*.s))\ |
---|
32 | $(patsubst $(DIR_COMMON_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_C)/*.c)) |
---|
33 | |
---|
34 | |
---|
35 | #-----[ To the compilation ]------------------------------------------------------ |
---|
36 | |
---|
37 | #~~~~~[ OS : Newlib ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
38 | NEWLIB_DIR_LDSCRIPT = $(NEWLIB)/lib/ |
---|
39 | #NEWLIB_INCDIR |
---|
40 | #NEWLIB_LIBDIR |
---|
41 | #NEWLIB_LIBNAME |
---|
42 | NEWLIB_OBJECTS = $(NEWLIB)/lib/*.o |
---|
43 | |
---|
44 | #~~~~~[ OS : UNIX ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
45 | UNIX_DIR_LDSCRIPT = |
---|
46 | UNIX_INCDIR = |
---|
47 | UNIX_LIBDIR = |
---|
48 | UNIX_LIBNAME = -lm |
---|
49 | UNIX_OBJECTS = |
---|
50 | |
---|
51 | |
---|
52 | #~~~~~[ TARGET : MORPHEO ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
53 | |
---|
54 | MORPHEO_OPTIMIZE = -O3 -std=c99 -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
55 | |
---|
56 | #Option : |
---|
57 | # -fomit-frame-pointer : n'utilise pas le pointeur de frame |
---|
58 | # -fdelayed-branch : utilise les delayed slot |
---|
59 | # ON OFF |
---|
60 | # -mror -mno-ror : utilisation de l'instruction l.ror |
---|
61 | # -mcmov -mno-cmov : utilisation de l'instruction l.cmov |
---|
62 | # -msext -mno-sext : utilisation des instructions l.extXX |
---|
63 | # -mhard-mul -msoft-mul : utilisation du multiplieur materiel |
---|
64 | # -mhard-div -msoft-div : utilisation du diviseur materiel |
---|
65 | # -mhard-float -msoft-float : utilisation du flottant materiel |
---|
66 | # -msibcall -mno-sibcall : Enable sibcall optimization |
---|
67 | # -mlogue -mno-logue : Schedule pro/epi-logue. |
---|
68 | # -maj -mno-aj : Use aligned jumps. |
---|
69 | |
---|
70 | # Tools |
---|
71 | MORPHEO_CC = $(OR1K_BIN)/or32-elf-gcc |
---|
72 | MORPHEO_AS = $(OR1K_BIN)/or32-elf-as |
---|
73 | MORPHEO_LD = $(OR1K_BIN)/or32-elf-ld |
---|
74 | MORPHEO_OBJDUMP = $(OR1K_BIN)/or32-elf-objdump |
---|
75 | MORPHEO_NM = $(OR1K_BIN)/or32-elf-nm |
---|
76 | |
---|
77 | # Tools's option |
---|
78 | MORPHEO_CC_OPT = -Wall $(INCDIR) $(MORPHEO_OPTIMIZE) -Wlong-long -DMorpheo $(FLAGS) |
---|
79 | # -DHAVE_LIBC |
---|
80 | MORPHEO_AS_OPT = |
---|
81 | MORPHEO_LD_OPT = -T$(DIR_LDSCRIPT)/or32.ld $(LIBDIR) $(LIBNAME) $(OR1K_LIBDIR) $(OR1K_LIBNAME) |
---|
82 | MORPHEO_OBJDUMP_OPT = -D |
---|
83 | MORPHEO_NM_OPT = -n |
---|
84 | |
---|
85 | #~~~~~[ TARGET : x86 ]~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
---|
86 | |
---|
87 | x86_OPTIMIZE = -O3 -std=c99 |
---|
88 | |
---|
89 | x86_CC = gcc |
---|
90 | x86_AS = as |
---|
91 | x86_LD = gcc |
---|
92 | x86_OBJDUMP = objdump |
---|
93 | x86_NM = nm |
---|
94 | |
---|
95 | x86_CC_OPT = -Wall $(INCDIR) $(x86_OPTIMIZE) -Wlong-long -DUNIX $(FLAGS) -g3 |
---|
96 | x86_AS_OPT = |
---|
97 | x86_LD_OPT = $(LIBDIR) $(LIBNAME) -g3 |
---|
98 | x86_OBJDUMP_OPT = -D |
---|
99 | x86_NM_OPT = -n |
---|
100 | |
---|
101 | #-----[ Rules ]------------------------------------------------------------------- |
---|
102 | .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o |
---|
103 | |
---|
104 | vpath %.h $(DIR_INC):$(DIR_COMMON_INC) |
---|
105 | vpath %.c $(DIR_C):$(DIR_COMMON_C) |
---|
106 | vpath %.s $(DIR_ASM):$(DIR_SYS):$(DIR_COMMON_ASM):$(DIR_COMMON_SYS) |
---|
107 | vpath %.o $(DIR_OBJ) |
---|
108 | vpath %.x $(DIR_BIN) |
---|
109 | |
---|
110 | all : $(DIR_BIN)/$(EXE).x |
---|
111 | |
---|
112 | $(DIR_BIN)/%.x : $(DIR_BIN) $(DIR_OBJ) |
---|
113 | @\ |
---|
114 | $(MAKE) $(OBJECTS); \ |
---|
115 | $(ECHO) "Linkage : $*.x"; \ |
---|
116 | $($(TARGET)_LD) -o $@ $(OBJECTS) $($(TARGET)_LD_OPT); \ |
---|
117 | $(ECHO) "List symbols : $*.x.nm"; \ |
---|
118 | $($(TARGET)_NM) $($(TARGET)_NM_OPT) $@ > $@.nm; \ |
---|
119 | $(ECHO) "Display info : $*.x.txt"; \ |
---|
120 | $($(TARGET)_OBJDUMP) $($(TARGET)_OBJDUMP_OPT) $@ > $@.txt;\ |
---|
121 | echo $($(GREP) "l.jal 0" $@.txt); |
---|
122 | |
---|
123 | $(DIR_OBJ)/%.o : %.s |
---|
124 | @\ |
---|
125 | $(ECHO) "Compilation : $*.s"; \ |
---|
126 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
127 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
128 | |
---|
129 | $(DIR_OBJ)/%.o : %.c |
---|
130 | @\ |
---|
131 | $(ECHO) "Compilation : $*.c"; \ |
---|
132 | $($(TARGET)_CC) $($(TARGET)_CC_OPT) -o $@ -c $^ ; |
---|
133 | # $($(TARGET)_CC) $($(TARGET)_CC_OPT) -S -o $@.s -c $^ ; |
---|
134 | |
---|
135 | $(DIR_BIN) $(DIR_OBJ) : |
---|
136 | @\ |
---|
137 | $(MKDIR) $@; |
---|
138 | |
---|
139 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
140 | clean : |
---|
141 | @\ |
---|
142 | $(ECHO) "Delete temporary files"; \ |
---|
143 | $(RM) $(DIR_OBJ) \ |
---|
144 | *~ \ |
---|
145 | $(DIR_SRC)/*~ \ |
---|
146 | $(DIR_C)/*~ \ |
---|
147 | $(DIR_ASM)/*~ \ |
---|
148 | $(DIR_SYS)/*~ \ |
---|
149 | $(DIR_INC)/*~ \ |
---|
150 | $(DIR_LDSCRIPT)/*~ \ |
---|
151 | |
---|
152 | clean_all : clean |
---|
153 | $(RM) $(DIR_BIN) |
---|
154 | |
---|
155 | #-----[ Help ]-------------------------------------------------------------------- |
---|
156 | help : |
---|
157 | @\ |
---|
158 | $(ECHO) "";\ |
---|
159 | $(ECHO) "List of directive : ";\ |
---|
160 | $(ECHO) " * all : Compile the software";\ |
---|
161 | $(ECHO) " * clean : Erase all files generates";\ |
---|
162 | $(ECHO) " * clean_all : Erase all files generates";\ |
---|
163 | $(ECHO) ""; |
---|