Subversion Repositories Projects

Rev

Rev 316 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
316 dhylands 1
###########################################################################
2
#
3
#	free-rtos.mk
4
#
5
#	Contains definitions common to all Free-RTOS builds.
6
#
7
###########################################################################
8
 
9
#--------------------------------------------------------------------------
10
#
11
# 	Run make with v=1 or verbose=1 to get verbose output
12
#
13
 
14
ifeq ($(v),)
15
export verbose = 0
16
else
17
export verbose = 1
18
endif
19
 
20
ifeq ($(verbose),)
21
export verbose = 0
22
endif
23
 
24
ifeq ($(verbose),0)
25
	Q = @
26
	MAKEFLAGS += -s
27
else
28
	Q =
29
endif
30
export Q
31
 
32
#--------------------------------------------------------------------------
33
 
34
FREE_RTOS	= /home/dhylands/software/FreeRTOSV7.1.0
35
FREE_RTOS_SRC	= $(FREE_RTOS)/Source
36
 
319 dhylands 37
#
38
# Do some sanity checks on the FREE_RTOS directory structure
39
#
40
 
41
ifeq (,$(wildcard $(FREE_RTOS)))
42
$(error FREE_RTOS '$(FREE_RTOS)' doesn't exist)
43
endif
44
ifeq (,$(wildcard $(FREE_RTOS_SRC)))
45
$(error FREE_RTOS_SRC '$(FREE_RTOS_SRC)' doesn't exist)
46
endif
47
ifeq (,$(wildcard $(FREE_RTOS_SRC)/include/FreeRTOS.h))
48
$(error Unable to find '$(FREE_RTOS_SRC)/include/FreeRTOS.h')
49
endif
50
 
316 dhylands 51
CC 	= $(CROSS_COMPILE)gcc
52
LD 	= $(CROSS_COMPILE)ld
53
OBJCOPY	= $(CROSS_COMPILE)objcopy
54
 
55
LIBGCC	= $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
56
LIBC	= $(shell $(CC) $(CFLAGS) -print-file-name=libc.a)
57
 
58
OBJS = $(addprefix obj/,$(SRCS:%.c=%.o))
59
DEPS = $(addprefix obj/,$(SRCS:%.c=%.d))
60
 
61
all : obj/$(TARGET).bin
62
 
63
obj/%.o : %.c
64
	echo "Compiling $< ..."
65
	$(Q)mkdir -p $(@D)
66
	$(Q)$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
67
 
68
obj/$(TARGET).elf : $(OBJS)
69
	echo "Linking $@ ..."
70
	$(Q)$(LD) -T $(LD_SCRIPT) -Map ${@:%.elf=%.map} -o $@ $^ $(LIBC) $(LIBGCC)
71
 
72
obj/%.bin : obj/%.elf
73
	echo "Creating $@ from $<"
74
	$(Q)$(OBJCOPY) -O binary $< $@
75
 
76
clean:
77
	echo "Removing obj directory ..."
78
	$(Q)rm -rf obj
79
 
80
ifeq ($(strip $(filter clean% exec print-%, $(MAKECMDGOALS))),)
81
-include $(DEPS)
82
endif
83