-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild_rules.mk
65 lines (54 loc) · 1.36 KB
/
build_rules.mk
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
ARCH?=$(shell uname -m)
ifeq "$(ARCH)" "arm"
BUILDROOT?=$(shell readlink -f ../buildroot)
PKG_CONFIG?=$(BUILDROOT)/output/host/usr/bin/pkg-config
CROSS_COMPILE?=$(BUILDROOT)/output/host/bin/arm-unknown-linux-gnueabi-
UBOOT_DIR?=$(shell readlink -f ../u-boot)
LINUX_DIR?=$(shell readlink -f ../linux)
CFLAGS += -march=armv5t
endif
ifeq "$(ARCH)" "x86_64"
PKG_CONFIG=pkg-config
endif
CC = $(CROSS_COMPILE)gcc
CPP = $(CROSS_COMPILE)g++
CXX = $(CROSS_COMPILE)g++
AR = $(CROSS_COMPILE)ar
LD = $(CROSS_COMPILE)ld
STRIP = $(CROSS_COMPILE)strip
CFLAGS+=-Werror -Wall -pipe
ifeq "$(DEBUG)" ""
CFLAGS += -O2
else
CFLAGS += -O -g
endif
ifeq "$(PROFILE)" "1"
CFLAGS+=-pg --coverage
LFLAGS+=-pg --coverage -lgcov
endif
# Turn on static analysis by default
C?=1
ifeq "$(C)" "0"
check_source =
else
CFLAGS+=-D_FORTIFY_SOURCE=2
check_source = echo " CPPCHECK $1..." ; \
cppcheck --quiet --std=c99 $1
endif
build/$(ARCH)/%.o : %.c
echo " CC $@..."
mkdir -p $(dir $@)
$(call check_source,$<)
$(CC) $(CFLAGS) -c -o $@ $<
build/$(ARCH)/%.dep: %.c
# Don't build dependencies if this is a clean build
ifneq ($(MAKECMDGOALS),clean)
echo " DEP $<..."
mkdir -p $(dir $@)
$(CC) $< $(CFLAGS) -MM -MG -MT $(basename $@).o -o $@
endif
# Turn off verbose output by default
V?=0
ifeq "$(V)" "0"
MAKEFLAGS = --no-print-directory --quiet
endif