summaryrefslogtreecommitdiff
path: root/n/avr/make/Makefile.host
blob: f0b47d8aee5fff7acb2824e1d719c8378169f4ac (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
# Makefile.host - Host Makefile.
#
# Flags. {{{1

HOST_CFLAGS = $(CFLAGS)
HOST_CPPFLAGS = $(CPPFLAGS) $(HOST_DEFS) -DHOST=1
HOST_LDFLAGS = $(LDFLAGS)
HOST_LDLIBS = $(LDLIBS) $(HOST_LIBS)

HOST_COMPILE.c = $(CC) $(HOST_CFLAGS) $(HOST_CPPFLAGS) -c
HOST_LINK.o = $(CC) $(HOST_CFLAGS) $(HOST_LDFLAGS)

# Main rules. {{{1

host: exe

.PHONY: host clean.host exe

# General rules. {{{1

HOST_EXES = $(PROGS:%=%.host)
HOST_SOURCES = $(filter-out %.avr.c,$(SOURCES))
HOST_OBJECTS = $(HOST_SOURCES:%.c=%.host.o)

exe: $(HOST_EXES)

define AVR_PROG_template
$(1).host: $$(patsubst %.c,%.host.o,$$(filter-out %.avr.c,$$($(1)_SOURCES)))
endef

$(foreach prog,$(PROGS),$(eval $(call AVR_PROG_template,$(prog))))

$(HOST_EXES):
	$(HOST_LINK.o) $^ $(HOST_LDLIBS) -o $@

%.host.o: %.c
	$(HOST_COMPILE.c) -o $@ $<

# Dependency checking.
-include $(HOST_OBJECTS:%.host.o=%.host.d)

# Cleaning. {{{1

clean.host:
	rm -f *.host.o *.host.d $(HOST_EXES)