-
Notifications
You must be signed in to change notification settings - Fork 6
/
Rules.mk
56 lines (45 loc) · 1.28 KB
/
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
# General Make rules for building TBM
#
# Copyright (C) 2009 - 2014 Edgar E. Iglesias <edgar.iglesias@gmail.com>
#
# BUILDDIR = Directory where built products end up.
# SRCDIR = Directory where source code lives.
# BUILD_SUBDIRS = List of subdires to create on inclusion.
# Provide sane default values.
DEFAULT_RULE ?= all
DTC ?= dtc
CC ?= cc
LD ?= cc
ifeq ($V,)
QUIET=@
quietprint=@echo " $(1)"
.SILENT:
else
QUIET=
quietprint=
endif
# Create BUILD_SUBDIRS
CREATE_BUILDDIRS = $(foreach d, $(BUILD_SUBDIRS), \
$(shell mkdir -p $(BUILDDIR)$(d)))
# Dereference the variable to create the libs.
$(DEFAULT_RULE): $(CREATE_BUILDDIRS)
# Lining function.
#
#
# Use by $(call $(LINK), objs, output)
LINK = $(QUIET)$(LD) $(1) $(LDFLAGS) $(LDLIBS) -o $(2)
-include $(OBJS:.o=.d)
CPPFLAGS += -MMD
# Compile a DTS into a DTB
$(BUILDDIR)%.dtb: $(SRCDIR)%.dts
$(call quietprint, $@)
$(QUIET)$(DTC) $(DTCFLAGS) -I dts -O dtb -o $@ $<
$(BUILDDIR)%.dtb.o: $(BUILDDIR)%.dtb
$(call quietprint, $@)
$(QUIET)$(REALLD) -r -b binary -o $@ $<
$(BUILDDIR)%.o: $(SRCDIR)%.c
$(call quietprint, $@)
$(QUIET)$(CC) $(CFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@
$(BUILDDIR)%.o: $(SRCDIR)%.S
$(call quietprint, $@)
$(QUIET)$(CC) $(ASFLAGS) $(CPPFLAGS) $(TARGET_ARCH) -c $< -o $@