[2] | 1 | # common definition |
---|
| 2 | include Makefile.morpheo |
---|
| 3 | |
---|
| 4 | #-----[ Directory ]--------------------------------------------------------------- |
---|
| 5 | |
---|
| 6 | DIR_LOCAL = . |
---|
| 7 | DIR_LOCAL_C = $(DIR_LOCAL)/src/c |
---|
| 8 | DIR_LOCAL_ASM = $(DIR_LOCAL)/src/asm |
---|
| 9 | DIR_LOCAL_SYS = $(DIR_LOCAL)/src/sys |
---|
| 10 | DIR_LOCAL_INC = $(DIR_LOCAL)/src/c/include |
---|
| 11 | |
---|
| 12 | DIR_GLOBAL = $(SOFT)/Global.or32 |
---|
| 13 | DIR_GLOBAL_C = $(DIR_GLOBAL)/src/c |
---|
| 14 | DIR_GLOBAL_ASM = $(DIR_GLOBAL)/src/asm |
---|
| 15 | DIR_GLOBAL_SYS = $(DIR_GLOBAL)/src/sys |
---|
| 16 | DIR_GLOBAL_INC = $(DIR_GLOBAL)/include |
---|
| 17 | |
---|
| 18 | DIR_INC = -I$(DIR_LOCAL_INC) -I$(DIR_GLOBAL_INC) |
---|
| 19 | DIR_OBJ = obj |
---|
| 20 | DIR_BIN = bin |
---|
| 21 | |
---|
| 22 | EXE = soft |
---|
| 23 | |
---|
| 24 | #-----[ Files ]------------------------------------------------------------------- |
---|
| 25 | OBJ_ASM = $(patsubst $(DIR_LOCAL_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_ASM)/*.s)) \ |
---|
| 26 | $(patsubst $(DIR_GLOBAL_ASM)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_ASM)/*.s)) |
---|
| 27 | OBJ_SYS = $(patsubst $(DIR_LOCAL_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_SYS)/*.s)) \ |
---|
| 28 | $(patsubst $(DIR_GLOBAL_SYS)/%.s,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_SYS)/*.s)) |
---|
| 29 | OBJ_C = $(patsubst $(DIR_LOCAL_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_LOCAL_C)/*.c)) \ |
---|
| 30 | $(patsubst $(DIR_GLOBAL_C)/%.c,$(DIR_OBJ)/%.o,$(wildcard $(DIR_GLOBAL_C)/*.c)) |
---|
| 31 | |
---|
| 32 | OBJ = $(OBJ_SYS) $(OBJ_ASM) $(OBJ_C) |
---|
| 33 | |
---|
| 34 | #-----[ Rules ]------------------------------------------------------------------- |
---|
| 35 | .PRECIOUS : $(DIR_BIN)/%.x $(DIR_OBJ)/%.o $(DIR_OBJ)/%.a |
---|
| 36 | |
---|
| 37 | all : test_env $(DIR_BIN)/$(EXE).x.txt |
---|
| 38 | |
---|
| 39 | $(DIR_BIN)/%.x.txt : $(DIR_BIN)/%.x |
---|
| 40 | @$(ECHO) "List symbols of $*" |
---|
| 41 | @$(NM) $(NM_OPT) $^ > $@.nm |
---|
| 42 | @$(ECHO) "Display information of $*" |
---|
| 43 | @$(OBJDUMP) $(OBJDUMP_OPT) $^ > $@ |
---|
| 44 | |
---|
| 45 | $(DIR_BIN)/%.x : $(OBJ_SYS) $(OBJ) |
---|
| 46 | @$(ECHO) "Linkage of $*" |
---|
| 47 | @$(LD) -o $@ $^ $(LD_OPT) |
---|
| 48 | |
---|
| 49 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_ASM)/%.s |
---|
| 50 | @$(ECHO) "Compile of $*" |
---|
| 51 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 52 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 53 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
| 54 | |
---|
| 55 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_SYS)/%.s |
---|
| 56 | @$(ECHO) "Compile of $*" |
---|
| 57 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 58 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 59 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
| 60 | |
---|
| 61 | $(DIR_OBJ)/%.o : $(DIR_LOCAL_C)/%.c |
---|
| 62 | @$(ECHO) "Compile of $*" |
---|
| 63 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 64 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 65 | |
---|
| 66 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_ASM)/%.s |
---|
| 67 | @$(ECHO) "Compile of $*" |
---|
| 68 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 69 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 70 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
| 71 | |
---|
| 72 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_SYS)/%.s |
---|
| 73 | @$(ECHO) "Compile of $*" |
---|
| 74 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 75 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 76 | # @$(AS) $(AS_OPT) $^ -o $@ |
---|
| 77 | |
---|
| 78 | $(DIR_OBJ)/%.o : $(DIR_GLOBAL_C)/%.c |
---|
| 79 | @$(ECHO) "Compile of $*" |
---|
| 80 | @$(CC) $(CC_OPT) $(DIR_INC) -o $@ -c $^ |
---|
| 81 | @$(CC) $(CC_OPT) $(DIR_INC) -S -o $@.s -c $^ |
---|
| 82 | |
---|
| 83 | #-----[ Environement ]------------------------------------------------------------ |
---|
| 84 | test_env : |
---|
| 85 | # ifeq ($(origin TOOLS), undefined) |
---|
| 86 | # $(error "variable TOOLS is undefined"); |
---|
| 87 | # endif |
---|
| 88 | # ifeq ($(origin SOFT), undefined) |
---|
| 89 | # $(error "variable SOFT is undefined"); |
---|
| 90 | # endif |
---|
| 91 | @$(MKDIR) $(DIR_OBJ) $(DIR_BIN) |
---|
| 92 | |
---|
| 93 | #-----[ Maintenance ]------------------------------------------------------------- |
---|
| 94 | clean : |
---|
| 95 | @$(ECHO) "Delete temporary files "`$(PWD)` |
---|
| 96 | @$(RM) $(DIR_OBJ) $(DIR_BIN) |
---|
| 97 | @$(MAKE) clean_rec DIR_CLEAN=. |
---|
| 98 | |
---|
| 99 | #Clean recursive |
---|
| 100 | clean_rec : |
---|
| 101 | @$(ECHO) "Delete temporary files in directory $(DIR_CLEAN)" |
---|
| 102 | @$(RM) -f $(DIR_CLEAN)/*~ |
---|
| 103 | @for files in `$(LS) $(DIR_CLEAN)`; do \ |
---|
| 104 | if $(TEST) -d $(DIR_CLEAN)/$$files; \ |
---|
| 105 | then \ |
---|
| 106 | $(MAKE) clean_rec DIR_CLEAN=$(DIR_CLEAN)/$$files; \ |
---|
| 107 | fi; \ |
---|
| 108 | done; |
---|
| 109 | |
---|
| 110 | #-----[ Help ]-------------------------------------------------------------------- |
---|
| 111 | help : |
---|
| 112 | @$(ECHO) "" |
---|
| 113 | @$(ECHO) "List of directive : " |
---|
| 114 | @$(ECHO) " * make : Compile the software" |
---|
| 115 | @$(ECHO) " * make clean : Erase all files generates" |
---|
| 116 | @$(ECHO) " * make bench_list : View all benchmark" |
---|
| 117 | @$(ECHO) " * make bench_exec : Print the file \"$(FILE_BENCH)\" - it's the Workload" |
---|
| 118 | @$(ECHO) " * make bench : Compile the Benchmark Suite" |
---|
| 119 | @$(ECHO) "" |
---|