source: trunk/Softwares/Min.or32/Makefile @ 2

Last change on this file since 2 was 2, checked in by kane, 17 years ago

Import Morpheo

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