1 | # Makefile for compiling the Getting Started project
|
2 |
|
3 | #-------------------------------------------------------------------------------
|
4 | # User-modifiable options
|
5 | #-------------------------------------------------------------------------------
|
6 |
|
7 | # Trace level used for compilation
|
8 | # (can be overriden by adding TRACE_LEVEL=#number to the command-line)
|
9 | # TRACE_LEVEL_DEBUG 5
|
10 | # TRACE_LEVEL_INFO 4
|
11 | # TRACE_LEVEL_WARNING 3
|
12 | # TRACE_LEVEL_ERROR 2
|
13 | # TRACE_LEVEL_FATAL 1
|
14 | # TRACE_LEVEL_NO_TRACE 0
|
15 | TRACE_LEVEL = 4
|
16 |
|
17 | # Optimization level
|
18 | OPTIMIZATION = -O0
|
19 |
|
20 | # Output file basename
|
21 | OUTPUT = main
|
22 |
|
23 | # Output directories
|
24 | BIN = .
|
25 | OBJ = obj
|
26 |
|
27 | # library dirs
|
28 | LIBRARYSRC = ./lib/src
|
29 |
|
30 | STARTUPFILE = ./lib/startup_stm32f4xx.s
|
31 |
|
32 | #-------------------------------------------------------------------------------
|
33 | # Tools
|
34 | #-------------------------------------------------------------------------------
|
35 |
|
36 | # Tool suffix when cross-compiling
|
37 | CROSS_COMPILE = arm-none-eabi-
|
38 |
|
39 | CC = $(CROSS_COMPILE)gcc
|
40 | SIZE = $(CROSS_COMPILE)size
|
41 | STRIP = $(CROSS_COMPILE)strip
|
42 | OBJCOPY = $(CROSS_COMPILE)objcopy
|
43 | OBJDUMP = $(CROSS_COMPILE)objdump
|
44 | LD = $(CROSS_COMPILE)gcc
|
45 | AS = $(CROSS_COMPILE)gcc
|
46 |
|
47 | #-------------------------------------------------------------------------------
|
48 | # Files
|
49 | #-------------------------------------------------------------------------------
|
50 |
|
51 | # include folders
|
52 | INCLUDES = -I./
|
53 | INCLUDES += -I./lib/
|
54 | INCLUDES += -I./lib/inc/
|
55 | INCLUDES += -I./lib/inc/../../
|
56 |
|
57 | # Objects built from C source files
|
58 | C_OBJECTS = $(OBJ)/main.o
|
59 | C_OBJECTS += $(OBJ)/system_stm32f4xx.o
|
60 | C_OBJECTS += $(OBJ)/stm32f4xx_gpio.o
|
61 | C_OBJECTS += $(OBJ)/stm32f4xx_rcc.o
|
62 | C_OBJECTS += $(OBJ)/stm32f4xx_tim.o
|
63 | C_OBJECTS += $(OBJ)/stm32f4xx_it.o
|
64 | C_OBJECTS += $(OBJ)/stm32f4xx_syscfg.o
|
65 | C_OBJECTS += $(OBJ)/stm32_eth.o
|
66 | C_OBJECTS += $(OBJ)/ethernet.o
|
67 | C_OBJECTS += $(OBJ)/clock-arch.o
|
68 | C_OBJECTS += $(OBJ)/timer.o
|
69 | C_OBJECTS += $(OBJ)/misc.o
|
70 | C_OBJECTS += $(OBJ)/uip.o
|
71 | C_OBJECTS += $(OBJ)/httpd.o
|
72 | C_OBJECTS += $(OBJ)/uip_arp.o
|
73 | C_OBJECTS += $(OBJ)/psock.o
|
74 | C_OBJECTS += $(OBJ)/httpd-fs.o
|
75 | C_OBJECTS += $(OBJ)/httpd-cgi.o
|
76 | C_OBJECTS += $(OBJ)/http-strings.o
|
77 | C_OBJECTS += $(OBJ)/syscall.o
|
78 |
|
79 | # Objects built from Assembly source files
|
80 | ASM_OBJECTS = $(OBJ)/startup_stm32f4xx.o
|
81 |
|
82 | LINKER_SCRIPT = ./lib/stm32f4xx_flash.ld
|
83 |
|
84 | # Append OBJ and BIN directories to output filename
|
85 | OUTPUT := $(BIN)/$(OUTPUT)
|
86 |
|
87 | #-------------------------------------------------------------------------------
|
88 | # Rules
|
89 | #-------------------------------------------------------------------------------
|
90 |
|
91 | # Flags
|
92 | CFLAGS = -Wall -fno-common -c -g -mcpu=cortex-m3 -mthumb
|
93 | CFLAGS += -g $(OPTIMIZATION) $(INCLUDES) -DTRACE_LEVEL=$(TRACE_LEVEL)
|
94 | ASFLAGS = -g -mapcs-32
|
95 | LDFLAGS = -g -v -nostartfiles -LC:/OlimexODS/yagarto/lib/gcc/arm-none-eabi/4.5.1
|
96 | OBJCOPYFLAGS = -O binary
|
97 | OBJDUMPFLAGS = -x --syms -S
|
98 |
|
99 | all: $(BIN) $(OBJ) $(OUTPUT).out
|
100 |
|
101 | $(BIN) $(OBJ):
|
102 | mkdir $@
|
103 |
|
104 | $(OUTPUT).out: $(C_OBJECTS) $(ASM_OBJECTS) $(LINKER_SCRIPT)
|
105 | @ echo "..linking"
|
106 | $(LD) $(LDFLAGS) -T$(LINKER_SCRIPT) -o $(OUTPUT).out $(C_OBJECTS) $(ASM_OBJECTS) libgcc.a
|
107 | $(OBJCOPY) $(OBJCOPYFLAGS) $(OUTPUT).out $(OUTPUT).bin
|
108 | @ echo "...completed."
|
109 |
|
110 | $(C_OBJECTS): main.c system_stm32f4xx.c
|
111 | @ echo ".compiling"
|
112 | $(CC) $(CFLAGS) -o $(OBJ)/main.o main.c
|
113 | $(CC) $(CFLAGS) -o $(OBJ)/system_stm32f4xx.o system_stm32f4xx.c
|
114 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_it.o stm32f4xx_it.c
|
115 | $(CC) $(CFLAGS) -o $(OBJ)/stm32_eth.o stm32_eth.c
|
116 | $(CC) $(CFLAGS) -o $(OBJ)/ethernet.o ethernet.c
|
117 | $(CC) $(CFLAGS) -o $(OBJ)/clock-arch.o clock-arch.c
|
118 | $(CC) $(CFLAGS) -o $(OBJ)/timer.o timer.c
|
119 | $(CC) $(CFLAGS) -o $(OBJ)/uip.o uip.c
|
120 | $(CC) $(CFLAGS) -o $(OBJ)/httpd.o httpd.c
|
121 | $(CC) $(CFLAGS) -o $(OBJ)/uip_arp.o uip_arp.c
|
122 | $(CC) $(CFLAGS) -o $(OBJ)/psock.o psock.c
|
123 | $(CC) $(CFLAGS) -o $(OBJ)/httpd-fs.o httpd-fs.c
|
124 | $(CC) $(CFLAGS) -o $(OBJ)/httpd-cgi.o httpd-cgi.c
|
125 | $(CC) $(CFLAGS) -o $(OBJ)/http-strings.o http-strings.c
|
126 | $(CC) $(CFLAGS) -o $(OBJ)/syscall.o syscall.c
|
127 | @ echo ".compiling libraries"
|
128 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_tim.o $(LIBRARYSRC)/stm32f4xx_tim.c
|
129 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_gpio.o $(LIBRARYSRC)/stm32f4xx_gpio.c
|
130 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.c
|
131 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_rcc.o $(LIBRARYSRC)/stm32f4xx_rcc.c
|
132 | $(CC) $(CFLAGS) -o $(OBJ)/stm32f4xx_syscfg.o $(LIBRARYSRC)/stm32f4xx_syscfg.c
|
133 | $(CC) $(CFLAGS) -o $(OBJ)/misc.o $(LIBRARYSRC)/misc.c
|
134 |
|
135 | $(ASM_OBJECTS): $(STARTUPFILE)
|
136 | @ echo ".assembling"
|
137 | $(AS) $(ASFLAGS) -o $(OBJ)/startup_stm32f4xx.o $(STARTUPFILE)
|
138 |
|
139 | clean:
|
140 | -rm -f $(OBJ)/*.o $(BIN)/*.out $(BIN)/*.bin $(BIN)/*.dmp $(BIN)/*.map $(BIN)/*.lss
|