[78] | 1 | include $(MORPHEO_TOPLEVEL)/Makefile.tools |
---|
| 2 | |
---|
| 3 | #-----[ Directory ]--------------------------------------------------------------- |
---|
| 4 | DIRECTORY_OBJ = obj |
---|
| 5 | DIRECTORY_BIN = bin |
---|
| 6 | |
---|
| 7 | EXE = soft |
---|
| 8 | |
---|
| 9 | #-----[ Files ]------------------------------------------------------------------- |
---|
| 10 | OBJECTS = $(OBJECTS_SYS) $(OBJECTS_ASM) $(OBJECTS_C) |
---|
| 11 | |
---|
| 12 | #-----[ To the compilation ]------------------------------------------------------ |
---|
| 13 | OPTIMIZE = -O3 -fomit-frame-pointer -fdelayed-branch -mror -mcmov -msext -mhard-mul -msoft-div -msoft-float |
---|
| 14 | #Option : |
---|
| 15 | # -fomit-frame-pointer : n'utilise pas le pointeur de frame |
---|
| 16 | # -fdelayed-branch : utilise les delayed slot |
---|
| 17 | # ON OFF |
---|
| 18 | # -mror -mno-ror : utilisation de l'instruction l.ror |
---|
| 19 | # -mcmov -mno-cmov : utilisation de l'instruction l.cmov |
---|
| 20 | # -msext -mno-sext : utilisation des instructions l.extXX |
---|
| 21 | # -mhard-mul -msoft-mul : utilisation du multiplieur materiel |
---|
| 22 | # -mhard-div -msoft-div : utilisation du diviseur materiel |
---|
| 23 | # -mhard-float -msoft-float : utilisation du flottant materiel |
---|
| 24 | # -msibcall -mno-sibcall : Enable sibcall optimization |
---|
| 25 | # -mlogue -mno-logue : Schedule pro/epi-logue. |
---|
| 26 | # -maj -mno-aj : Use aligned jumps. |
---|
| 27 | |
---|
| 28 | # Tools |
---|
[81] | 29 | OR32_CC = $(OR1K_BIN)/or32-elf-gcc |
---|
| 30 | OR32_AS = $(OR1K_BIN)/or32-elf-as |
---|
| 31 | OR32_LD = $(OR1K_BIN)/or32-elf-ld |
---|
| 32 | OR32_OBJDUMP = $(OR1K_BIN)/or32-elf-objdump |
---|
| 33 | OR32_NM = $(OR1K_BIN)/or32-elf-nm |
---|
[78] | 34 | |
---|
| 35 | # Tools's option |
---|
[81] | 36 | OR32_CC_OPT = $(INCLUDE) $(OPTIMIZE) -Wlong-long |
---|
[78] | 37 | # -DHAVE_LIBC |
---|
[81] | 38 | OR32_AS_OPT = |
---|
| 39 | OR32_LD_OPT = -T$(DIRECTORY_LDSCRIPT)/or32.ld $(LIBRARY) |
---|
| 40 | OR32_OBJDUMP_OPT = -D |
---|
| 41 | OR32_NM_OPT = -n |
---|
[78] | 42 | |
---|
| 43 | #-----[ Rules ]------------------------------------------------------------------- |
---|
| 44 | .PRECIOUS : $(DIRECTORY_BIN)/%.x.txt $(DIRECTORY_BIN)/%.x $(DIRECTORY_OBJ)/%.o |
---|
| 45 | |
---|
| 46 | all : test_env $(DIRECTORY_BIN)/$(EXE).x.txt |
---|
| 47 | |
---|
| 48 | $(DIRECTORY_BIN)/%.x.txt : $(DIRECTORY_BIN)/%.x |
---|
| 49 | @\ |
---|
| 50 | $(ECHO) "List symbols : $*"; \ |
---|
[81] | 51 | $(OR32_NM) $(OR32_NM_OPT) $^ > $@.nm; \ |
---|
[78] | 52 | $(ECHO) "Display info : $*"; \ |
---|
[81] | 53 | $(OR32_OBJDUMP) $(OR32_OBJDUMP_OPT) $^ > $@; |
---|
[78] | 54 | |
---|
| 55 | $(DIRECTORY_BIN)/%.x : $(OBJECTS) |
---|
| 56 | @ \ |
---|
| 57 | $(ECHO) "Linkage : $*"; \ |
---|
[81] | 58 | $(OR32_LD) -o $@ $^ $(OR32_LD_OPT); |
---|
[78] | 59 | |
---|
| 60 | $(DIRECTORY_OBJ)/%.o : $(DIRECTORY_ASM)/%.s |
---|
| 61 | @ \ |
---|
| 62 | $(ECHO) "Compilation : $*"; \ |
---|
[81] | 63 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; \ |
---|
| 64 | $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
| 65 | # @$(OR32_AS) $(OR32_AS_OPT) $^ -o $@ |
---|
[78] | 66 | |
---|
| 67 | $(DIRECTORY_OBJ)/%.o : $(DIRECTORY_SYS)/%.s |
---|
| 68 | @ \ |
---|
| 69 | $(ECHO) "Compilation : $*"; \ |
---|
[81] | 70 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; \ |
---|
| 71 | $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
| 72 | # @$(OR32_AS) $(OR32_AS_OPT) $^ -o $@ |
---|
[78] | 73 | |
---|
| 74 | $(DIRECTORY_OBJ)/%.o : $(DIRECTORY_C)/%.c |
---|
| 75 | @ \ |
---|
| 76 | $(ECHO) "Compilation : $*"; \ |
---|
[81] | 77 | $(OR32_CC) $(OR32_CC_OPT) -o $@ -c $^ ; \ |
---|
| 78 | $(OR32_CC) $(OR32_CC_OPT) -S -o $@.s -c $^ ; |
---|
[78] | 79 | |
---|
| 80 | #-----[ Environement ]------------------------------------------------------------ |
---|
| 81 | test_env : |
---|
| 82 | # ifeq ($(origin TOOLS), undefined) |
---|
| 83 | # $(error "variable TOOLS is undefined"); |
---|
| 84 | # endif |
---|
| 85 | # ifeq ($(origin SOFT), undefined) |
---|
| 86 | # $(error "variable SOFT is undefined"); |
---|
| 87 | # endif |
---|
| 88 | @$(MKDIR) $(DIRECTORY_OBJ) $(DIRECTORY_BIN) |
---|
| 89 | |
---|
| 90 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
| 91 | clean : |
---|
| 92 | @\ |
---|
| 93 | $(ECHO) "Delete temporary files "`$(PWD)`; \ |
---|
| 94 | $(RM) $(DIRECTORY_OBJ) $(DIRECTORY_BIN); \ |
---|
| 95 | $(MAKE) clean_rec DIRECTORY_CLEAN=.; |
---|
| 96 | |
---|
| 97 | clean_rec : |
---|
| 98 | @\ |
---|
| 99 | $(ECHO) "Delete temporary files in directory $(DIRECTORY_CLEAN)"; \ |
---|
| 100 | $(RM) -f $(DIRECTORY_CLEAN)/*~; \ |
---|
| 101 | for files in `$(LS) $(DIRECTORY_CLEAN)`; do \ |
---|
| 102 | if $(TEST) -d $(DIRECTORY_CLEAN)/$$files; \ |
---|
| 103 | then \ |
---|
| 104 | $(MAKE) clean_rec DIRECTORY_CLEAN=$(DIRECTORY_CLEAN)/$$files; \ |
---|
| 105 | fi; \ |
---|
| 106 | done; |
---|
| 107 | |
---|
| 108 | #-----[ Help ]-------------------------------------------------------------------- |
---|
| 109 | help : |
---|
| 110 | @\ |
---|
| 111 | $(ECHO) "";\ |
---|
| 112 | $(ECHO) "List of directive : ";\ |
---|
| 113 | $(ECHO) " * make : Compile the software";\ |
---|
| 114 | $(ECHO) " * make clean : Erase all files generates";\ |
---|
| 115 | $(ECHO) ""; |
---|