summaryrefslogtreecommitdiffhomepage
path: root/digital/ucoolib/build/top.mk
blob: d4f53fe4885eeba02ad500a2046a9d693760fa8d (plain)
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
65
66
67
68
69
70
71
72
73
# ucoolib - Microcontroller object oriented library.
#
# Build system top file. To be included with $(BASE) pointing to the ucoolib
# root.

ifeq ($(BASE),)
$(error BASE is not defined)
endif

include $(BASE)/build/macros.mk

# General parameters.

OBJDIR := obj

INCLUDES := $(INCLUDES) -I$(BASE) -I$(OBJDIR)
CPPFLAGS := $(DEFS) $(INCLUDES) -MP -MMD
OPTIMIZE ?= -Os
CFLAGS := -g -Wall -W -Wundef -Wno-unused-parameter \
	-fno-exceptions $(OPTIMIZE)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-threadsafe-statics
LDFLAGS :=
LDLIBS := $(LIBS)

# Quiet, unset to see executed lines.
Q = @

# Main rules.

all:
lst:
size:
hex:
srec:
bin:

clean:
	rmdir $(OBJDIR) 2> /dev/null || true

.PHONY: all lst size hex srec bin clean

# Modules and sources setup.

include $(BASE)/build/setup.mk

vpath %.cc $(ALL_MODULES:%=$(BASE)/ucoolib/%)
vpath %.c $(ALL_MODULES:%=$(BASE)/ucoolib/%)
vpath %.S $(ALL_MODULES:%=$(BASE)/ucoolib/%)

# Configuration.

include $(BASE)/build/config.mk

# Objects directory.

$(OBJDIR):
	$Qmkdir -p $(OBJDIR)

# Arch specific.

include $(BASE)/build/arch.mk
define TARGETS_template
include $$(BASE)/build/$1.mk
endef
$(foreach target,$(TARGETS),$(eval $(call TARGETS_template,$(target))))

TARGETS_SUBTARGETS := $(foreach target,$(TARGETS),$(target):$(target) \
	$(foreach subtarget,$($(target)_SUBTARGETS),$(target):$(subtarget)))

.PHONY: program
ifeq ($(words $(filter-out host,$(TARGETS))),1)
program: $(patsubst %,program.%,$(filter-out host,$(TARGETS)))
endif