-
Notifications
You must be signed in to change notification settings - Fork 31
/
Makefile
151 lines (112 loc) · 3.79 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#directory i should grab the source from
SRCDIR?=.
#the directory i should dump .o to
OBJDIR?=.
#top level directory, where .config is
TOPDIR?=.
#antares directory where all the scripts are
ANTARES_DIR?=$(TOPDIR)
#temporary dir for autogenerated stuff and other such shit
TMPDIR?=tmp
ARCH?=avr
#The config file we will be using
KCONFIG_CONFIG?=.config
#enforce bash, since other shells may break things
SHELL:=$(shell which bash)
define check_alt
which $(1) 2>/dev/null|| which $(2) 2>/dev/null || echo "fail"
endef
#Nasty OS X compat
STAT:=$(shell $(call check_alt,gstat,stat))
export STAT
ECHO:=$(shell $(call check_alt,gecho,echo))
export ECHO
ANTARES_DIR:=$(abspath $(ANTARES_DIR))
TMPDIR:=$(abspath $(TMPDIR))
TOPDIR:=$(abspath $(TOPDIR))
Kconfig:=$(SRCDIR)/kcnf
KVersion:=$(ANTARES_DIR)/version.kcnf
PHONY+=deftarget deploy build collectinfo clean
MAKEFLAGS:=-r
IMAGENAME=$(call unquote,$(CONFIG_IMAGE_DIR))/$(call unquote,$(CONFIG_IMAGE_FILENAME))
export SRCDIR ARCH TMPDIR IMAGENAME ARCH TOPDIR ANTARES_DIR TOOL_PREFIX
-include $(ANTARES_DIR)/.version
-include $(TOPDIR)/.config
-include $(TOPDIR)/include/config/auto.conf.cmd
include $(ANTARES_DIR)/make/host.mk
-include $(TMPDIR)/arch.mk
include $(ANTARES_DIR)/make/Makefile.lib
ifeq ($(PROJECT_SHIPS_ARCH),y)
-include $(TOPDIR)/src/arch/$(ARCH)/arch.mk
else
-include $(ANTARES_DIR)/src/arch/$(ARCH)/arch.mk
endif
ifeq ($(ANTARES_DIR),$(TOPDIR))
$(info $(tb_red))
$(info Please, do not run make in the antares directory)
$(info Use an out-of-tree project directory instead.)
$(info Have a look at the documentation on how to do that)
$(info $(col_rst))
$(error Cowardly refusing to go further)
endif
ifeq ($(CONFIG_TOOLCHAIN_GCC),y)
include $(ANTARES_DIR)/toolchains/gcc.mk
endif
ifeq ($(CONFIG_TOOLCHAIN_SDCC),y)
include $(ANTARES_DIR)/toolchains/sdcc.mk
endif
include $(ANTARES_DIR)/make/Makefile.collect
include $(ANTARES_DIR)/kconfig/kconfig.mk
# For compiler portability
export O
.SUFFIXES:
clean-y:="$(TMPDIR)" "$(TOPDIR)/build" "$(TOPDIR)/include/generated" "$(CONFIG_IMAGE_DIR)"
clean:
-$(SILENT_CLEAN) rm -Rf $(clean-y)
mrproper: clean
-$(SILENT_MRPROPER) rm -Rf $(TOPDIR)/kconfig
-$(Q)rm -f $(TOPDIR)/antares 2>/dev/null
$(Q)rm -Rf $(TOPDIR)/include/config
$(Q)rm -f $(TOPDIR)/include/arch
-$(Q)rm rm -f $(TOPDIR)/TAGS
$(Q)[ -d $(TOPDIR)/antares ] && \
echo "WARN: $(TOPDIR)/antares was not a symlink. Remove manually if you want to refetch antares"
distclean: mrproper
build: $(BUILDGOALS) .config
@echo > /dev/null
deploy: build
$(Q)$(MAKE) -f $(ANTARES_DIR)/make/Makefile.deploy $(call unquote,$(CONFIG_DEPLOY_DEFTARGET))
@echo "Your Antares firmware is now deployed"
real-deploy-%: build
$(Q)$(MAKE) -f $(ANTARES_DIR)/make/Makefile.deploy $*
@echo "Your Antares firmware is now deployed"
$(Q)$(MAKE) -f $(ANTARES_DIR)/make/Makefile.deploy post
tags:
$(SILENT_TAGS)etags `\
find $(TOPDIR) $(ANTARES_DIR)/ \
-name "*.c" -o -name "*.cpp" -o -name "*.h" \
| grep -v kconfig`
graph-%:
$(Q)$(ANTARES_DIR)/scripts/visualise_make $*
.config:
@echo "Missing configuration file ($(tb_red).config$(col_rst)). Please run configuation tool (menuconfig, etc))"
#Help needs a dedicated rule, so that it won't invoke build as it normally does
deploy-help:
$(Q)$(MAKE) -f $(ANTARES_DIR)/make/Makefile.deploy help
#For deployment autocompletion
define deploy_dummy
deploy-$(1): real-deploy-$(1)
@echo > /dev/null
PHONY+=deploy-$(1)
endef
-include $(TMPDIR)/deploy.mk
-include $(TMPDIR)/edeploy.mk
$(foreach d,$(DEPLOY), $(eval $(call deploy_dummy,$(d))))
.PHONY: $(PHONY)
# On debian wheezy with make 3.8.1-8.2 empty DEFAULT_GOAL crashes make (debian bug #780778)
ifeq ($(strip $(CONFIG_MAKE_DEFTARGET)),)
$(warn Empty default target or missing configuration file)
.DEFAULT_GOAL :=.config
else
.DEFAULT_GOAL := $(subst ",, $(CONFIG_MAKE_DEFTARGET))
endif