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