forked from rodan/openchronos-rfsw
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
119 lines (92 loc) · 2.59 KB
/
Makefile
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
SUBDIRS = drivers modules
include Common.mk
PYTHON := $(shell which python2 || which python)
BASH := $(shell which bash || which bash)
.PHONY: all
.PHONY: clean
.PHONY: install
.PHONY: config
.PHONY: new_timestamps
.PHONY: depend
.PHONY: doc
.PHONY: httpdoc
.PHONY: force
.PHONY: tags
.PHONY: diff
all: new_timestamps depend config.h openchronos.txt tags
#
# Build list of sources and objects to build
SRCS := $(wildcard *.c)
$(foreach subdir,$(SUBDIRS), \
$(eval SRCS := $(SRCS) $(wildcard $(subdir)/*.c)) \
)
OBJS := $(patsubst %.c,%.o,$(SRCS))
#
# Dependencies rules
depend: openchronos.dep
openchronos.dep: $(SRCS)
@echo "Generating dependencies.."
@touch $@
@makedepend $(INCLUDES) -Y -f $@ $^ &> /dev/null
@rm -f $@.bak
#
# Append specific CFLAGS/LDFLAGS
DEBUG := $(shell grep "^\#define CONFIG_DEBUG" config.h)
ifeq ($(DEBUG),)
TARGET := RELEASE
CFLAGS += $(CFLAGS_REL)
LDFLAGS += $(LDFLAGS_REL)
else
TARGET := DEBUG
CFLAGS += $(CFLAGS_DBG)
LDFLAGS += $(LDFLAGS_DBG)
endif
# rebuild if CFLAGS changed, as suggested in:
# http://stackoverflow.com/questions/3236145/force-gnu-make-to-rebuild-objects-affected-by-compiler-definition/3237349#3237349
openchronos.cflags: force
@echo "$(CFLAGS)" | cmp -s - $@ || echo "$(CFLAGS)" > $@
$(OBJS): openchronos.cflags
#
# Top rules
openchronos.elf: even_in_range.o $(OBJS)
@echo -e "\n>> Building $@ as target $(TARGET)"
@$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) -o $@ $+
openchronos.txt: openchronos.elf
$(PYTHON) tools/memory.py -i $< -o $@
even_in_range.o: even_in_range.s
$(AS) $< -o $@
modinit.o: modinit.c
@echo "CC $<"
@$(CC) $(CFLAGS) -Wno-implicit-function-declaration \
$(INCLUDES) -c $< -o $@
%.o: %.c
@echo "CC $<"
@$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
modinit.c:
@echo "Please do a 'make config' first!" && false
config.h:
@echo "Please do a 'make config' first!" && false
new_timestamps:
@$(BASH) ./tools/update_rtca_now.sh
diff: $(SRCS)
@echo "Generating diff to upstream code"
@diff -urpEbBN --exclude=.git --exclude-from=.diffexclude --exclude-from=.gitignore ../openchronos-ng-code ./ > diff_to_upstream.patch; /bin/true
tags: $(SRCS)
@echo "Generating tags .."
@exuberant-ctags -R
config:
$(PYTHON) tools/config.py
$(PYTHON) tools/make_modinit.py
install: openchronos.txt
contrib/ChronosTool.py rfbsl $<
clean: $(SUBDIRS)
@for subdir in $(SUBDIRS); do \
echo "Cleaning $$subdir .."; rm -f $$subdir/*.o; \
done
@rm -f *.o openchronos.{elf,txt,cflags,dep} output.map
doc:
rm -rf doc/*
doxygen Doxyfile
httpdoc: doc
rsync -vr doc/ $(USER)@web.sourceforge.net:/home/project-web/openchronos-ng/htdocs/api/
-include openchronos.dep