1 | # |
---|
2 | # $Id: Makefile.Software 112 2009-03-18 22:36:26Z 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 |
---|
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 | # @$(OR32_AS) $(OR32_AS_OPT) $^ -o $@ |
---|
94 | |
---|
95 | $(DIR_OBJ)/%.o : %.c |
---|
96 | @\ |
---|
97 | $(ECHO) "Compilation : $*.c"; \ |
---|
98 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; \ |
---|
99 | $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
100 | |
---|
101 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
102 | clean : |
---|
103 | @\ |
---|
104 | $(ECHO) "Delete temporary files"; \ |
---|
105 | $(RM) $(DIR_OBJ) $(DIR_BIN) \ |
---|
106 | *~ \ |
---|
107 | $(DIR_SRC)/*~ \ |
---|
108 | $(DIR_C)/*~ \ |
---|
109 | $(DIR_ASM)/*~ \ |
---|
110 | $(DIR_SYS)/*~ \ |
---|
111 | $(DIR_INC)/*~ \ |
---|
112 | $(DIR_LDSCRIPT)/*~ \ |
---|
113 | |
---|
114 | clean_all : clean |
---|
115 | |
---|
116 | #-----[ Help ]-------------------------------------------------------------------- |
---|
117 | help : |
---|
118 | @\ |
---|
119 | $(ECHO) "";\ |
---|
120 | $(ECHO) "List of directive : ";\ |
---|
121 | $(ECHO) " * all : Compile the software";\ |
---|
122 | $(ECHO) " * clean : Erase all files generates";\ |
---|
123 | $(ECHO) " * clean_all : Erase all files generates";\ |
---|
124 | $(ECHO) ""; |
---|