1 | # |
---|
2 | # $Id: Makefile.Software 117 2009-05-16 14:42:39Z 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 | #-----[ Directory ]--------------------------------------------------------------- |
---|
16 | DIR_OBJ = obj |
---|
17 | DIR_BIN = bin |
---|
18 | |
---|
19 | EXE = soft |
---|
20 | |
---|
21 | DIR_COMMON = $(MORPHEO_TOPLEVEL)/Softwares/Common |
---|
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 |
---|
26 | |
---|
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)) \ |
---|
29 | $(patsubst $(DIR_COMMON_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_COMMON_C)/*.c)) |
---|
30 | |
---|
31 | |
---|
32 | #-----[ To the compilation ]------------------------------------------------------ |
---|
33 | OPTIMIZE = -O2 -std=c99 -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
34 | |
---|
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 |
---|
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 |
---|
55 | |
---|
56 | # Tools's option |
---|
57 | OR32_CC_OPT = -Wall $(INCDIR) $(OPTIMIZE) -Wlong-long -DMorpheo $(FLAGS) |
---|
58 | # -DHAVE_LIBC |
---|
59 | OR32_AS_OPT = |
---|
60 | OR32_LD_OPT = -T$(DIR_LDSCRIPT)/or32.ld $(LIBDIR) $(LIBNAME) $(OR1K_LIBDIR) $(OR1K_LIBNAME) |
---|
61 | OR32_OBJDUMP_OPT = -D |
---|
62 | OR32_NM_OPT = -n |
---|
63 | |
---|
64 | #-----[ Rules ]------------------------------------------------------------------- |
---|
65 | .PRECIOUS : $(DIR_BIN)/%.x.txt $(DIR_BIN)/%.x $(DIR_OBJ)/%.o |
---|
66 | |
---|
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) |
---|
70 | vpath %.o $(DIR_OBJ) |
---|
71 | vpath %.x $(DIR_BIN) |
---|
72 | |
---|
73 | all : |
---|
74 | @\ |
---|
75 | $(MKDIR) $(DIR_BIN) $(DIR_OBJ); \ |
---|
76 | $(MAKE) $(DIR_BIN)/$(EXE).x; |
---|
77 | |
---|
78 | $(DIR_BIN)/%.x : $(OBJECTS) |
---|
79 | @\ |
---|
80 | $(ECHO) "Linkage : $*.x"; \ |
---|
81 | $(OR32_LD) -o $@ $^ $(OR32_LD_OPT); \ |
---|
82 | $(ECHO) "List symbols : $*.x.nm"; \ |
---|
83 | $(OR32_NM) $(OR32_NM_OPT) $@ > $@.nm; \ |
---|
84 | $(ECHO) "Display info : $*.x.txt"; \ |
---|
85 | $(OR32_OBJDUMP) $(OR32_OBJDUMP_OPT) $@ > $@.txt;\ |
---|
86 | echo $($(GREP) "l.jal 0" $@.txt); |
---|
87 | |
---|
88 | $(DIR_OBJ)/%.o : %.s |
---|
89 | @\ |
---|
90 | $(ECHO) "Compilation : $*.s"; \ |
---|
91 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; |
---|
92 | # $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
93 | |
---|
94 | $(DIR_OBJ)/%.o : %.c |
---|
95 | @\ |
---|
96 | $(ECHO) "Compilation : $*.c"; \ |
---|
97 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; |
---|
98 | # $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
99 | |
---|
100 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
101 | clean : |
---|
102 | @\ |
---|
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)/*~ \ |
---|
112 | |
---|
113 | clean_all : clean |
---|
114 | |
---|
115 | #-----[ Help ]-------------------------------------------------------------------- |
---|
116 | help : |
---|
117 | @\ |
---|
118 | $(ECHO) "";\ |
---|
119 | $(ECHO) "List of directive : ";\ |
---|
120 | $(ECHO) " * all : Compile the software";\ |
---|
121 | $(ECHO) " * clean : Erase all files generates";\ |
---|
122 | $(ECHO) " * clean_all : Erase all files generates";\ |
---|
123 | $(ECHO) ""; |
---|