Subversion Repositories Projects

Rev

Rev 95 | Rev 146 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 dhylands 1
###########################################################################
2
#
3
# 	mkEnv.mk
4
#
5
# 	This file contains common variable definitions used during the build.
6
#
7
#	This Makefile requires make version 3.81
8
#
9
###########################################################################
10
 
11
MK_ENV_INCLUDED = 1
12
 
13
ifneq ($(lastword a b),b)
14
$(error These Makefiles require make 3.81 or newer)
15
endif
16
 
17
#--------------------------------------------------------------------------
18
#
19
# 	Run make with v=1 or verbose=1 to get verbose output
20
#
21
 
22
ifeq ($(v),)
23
export verbose = 0
24
else
25
export verbose = 1
26
endif
27
 
28
ifeq ($(verbose),)
29
export verbose = 0
30
endif
31
 
32
ifeq ($(verbose),0)
33
	Q = @
34
	MAKEFLAGS += -s
35
else
36
	Q =
37
endif
38
export Q
39
 
40
#--------------------------------------------------------------------------
41
# 	MK_ROOT describes the path to get from the directory containing the
42
# 	Makefile which included this file,
43
 
38 dhylands 44
MK_ROOT := $(patsubst %/,%,$(dir $(patsubst %/,%,$(dir $(lastword $(MAKEFILE_LIST))))))
2 dhylands 45
export MK_ROOT
46
 
47
ifeq ($(verbose),1)
48
$(info MK_ROOT = $(MK_ROOT))
49
endif
50
 
51
#--------------------------------------------------------------------------
52
#
53
# Define space to be a single space character. Using " " gets the quotes
54
# as well, which we don't want.
55
#
56
 
57
empty :=
58
space := $(empty) $(empty)
59
 
60
#--------------------------------------------------------------------------
61
#
9 dhylands 62
#	MK_HOST_OS describes the OS that the make system is running on.
63
#
64
 
65
MK_SUPPORTED_HOST_OS = cygwin linux
66
 
67
ifeq ($(MK_HOST_OS),)
68
MK_HOST_UNAME = $(shell uname -s)
69
ifeq ($(findstring CYGWIN_NT,$(MK_HOST_UNAME)),CYGWIN_NT)
70
export MK_HOST_OS = cygwin
71
endif
72
ifeq ($(MK_HOST_UNAME),Linux)
73
export MK_HOST_OS = linux
74
endif
75
endif
76
 
77
ifeq ($(filter $(MK_HOST_OS),$(MK_SUPPORTED_HOST_OS)),)
78
$(warning Unsupported value for MK_HOST_OS: '$(MK_HOST_OS)')
79
$(warning MK_OS must be one of the following:)
80
$(warning $(space))
81
$(foreach os,$(MK_SUPPORTED_HOST_OS),$(warning $(space)  $(os)))
82
endif
83
 
84
ifeq ($(MK_OS),host)
85
MK_OS = $(MK_HOST_OS)
86
endif
87
 
88
#--------------------------------------------------------------------------
89
#
2 dhylands 90
# 	MK_OS describes the "Operating system" which is the source code is
91
# 	currently being compiled for. For each supported OS, there is another
92
# 	rules file in the $(MK_ROOT)/rules directory which is named using
93
# 	mkRules_$(MK_OS).mk
94
#
95
 
9 dhylands 96
MK_SUPPORTED_OS = avr cortex-m3 cygwin gumstix linux none win32
2 dhylands 97
 
98
ifeq ($(filter $(MK_OS),$(MK_SUPPORTED_OS)),)
99
$(warning Unsupported value for MK_OS: '$(MK_OS)')
100
$(warning MK_OS must be one of the following:)
101
$(warning $(space))
102
$(foreach os,$(MK_SUPPORTED_OS),$(warning $(space)  $(os)))
103
$(warning $(space))
104
$(warning Please note that these are case sensitive)
105
$(warning $(space))
106
$(error Run 'make MK_OS=DesiredOS' to correct)
107
endif
9 dhylands 108
 
2 dhylands 109
#--------------------------------------------------------------------------
110
#
111
# 	Run make with debug=1 to have non-optimized code generated.
112
#
113
 
114
ifeq ($(debug),)
115
export debug = 0
116
endif
117
 
118
ifeq ($(debug),1)
119
MK_OPTIMIZE    	= 1
120
MK_REL_EXT		= -dbg
121
else
122
MK_OPTIMIZE    	= 0
123
MK_REL_EXT		=
124
endif
125
 
126
MK_ADD_SYMBOLS 	= 1
127
 
128
#--------------------------------------------------------------------------
129
#
130
# 	MK_OS_DIR is used for uniquely identifying directories that ojects are
131
#	are placed in. The mkEnx-$(MK_OS).mk script can override this default
132
#
133
#	The AVR uses something like: obj/avr-m64-16MHz
134
#
135
 
136
MK_OS_DIR	= $(MK_OS)
137
 
138
#--------------------------------------------------------------------------
139
#
140
# 	MK_GEN_DIRS desribes the list of generated directories which can be
141
#	rm -rf'd to remove all generated files.
142
#
143
 
144
MK_GEN_DIRS = obj lib bin
145
 
146
#--------------------------------------------------------------------------
147
#
148
# 	MK_OBJ_DIR describes the location where the generated object and
149
# 	dependancy files will be placed.
150
#
151
 
123 dhylands 152
ifeq ($(MK_OBJ_DIR),)
2 dhylands 153
MK_OBJ_DIR = ./obj/$(MK_OS_DIR)$(MK_REL_EXT)
123 dhylands 154
endif
2 dhylands 155
 
156
#--------------------------------------------------------------------------
157
#
158
# 	MK_LIB_DIR describes the location where generated libraries files will
159
# 	be placed.
160
#
161
 
123 dhylands 162
ifeq ($(MK_LIB_DIR),)
2 dhylands 163
MK_LIB_DIR = ./lib/$(MK_OS_DIR)$(MK_REL_EXT)
123 dhylands 164
endif
2 dhylands 165
 
166
#--------------------------------------------------------------------------
167
#
168
# 	MK_BIN_DIR describes the location where generated binary (aka executable)
169
#	files will be placed.
170
#
171
 
123 dhylands 172
ifeq ($(MK_BIN_DIR),)
2 dhylands 173
MK_BIN_DIR = ./bin/$(MK_OS_DIR)$(MK_REL_EXT)
123 dhylands 174
endif
2 dhylands 175
 
176
#--------------------------------------------------------------------------
177
#
178
# 	MK_RULES_DIR describes the location where all of the support makefiles
179
#	live.
180
#
181
 
182
MK_RULES_DIR = $(MK_ROOT)/rules
183
 
184
#--------------------------------------------------------------------------
185
#
186
# 	MK_UTILS_DIR describes the location where all of the host utilities
187
#	are installed.
188
#
189
 
95 dhylands 190
MK_UTILS_DIR = $(shell echo ~)/bin
2 dhylands 191
 
192
#--------------------------------------------------------------------------
193
#
194
# 	The MK_xxx_NAME macro can be used to construct the name of a library,
195
#	executable, or object file, by providing the basename.
196
#
197
# 	For example:
198
#
199
#  		STR_LIB_NAME = $(call MK_LIB_NAME,str)
200
#
201
# 	will assign STR_LIB_NAME with the full version of the 'str' library.
202
#
203
 
204
MK_LIB_NAME = $(foreach libBase,$(1),$(MK_LIB_DIR)/$(MK_LIB_PREFIX)$(libBase)$(MK_LIB_EXT))
205
MK_BIN_NAME = $(foreach binBase,$(1),$(MK_BIN_DIR)/$(binBase)$(MK_BIN_EXT))
9 dhylands 206
MK_ELF_NAME = $(foreach binBase,$(1),$(MK_BIN_DIR)/$(binBase)$(MK_ELF_EXT))
207
MK_HEX_NAME = $(foreach hexBase,$(1),$(MK_BIN_DIR)/$(hexBase)$(MK_HEX_EXT))
2 dhylands 208
MK_OBJ_NAME = $(foreach objBase,$(1),$(MK_OBJ_DIR)/$(objBase)$(MK_OBJ_EXT))
209
 
210
#--------------------------------------------------------------------------
211
#
212
# Setup variables for the various utilities that are required.
213
#
214
 
215
ECHO	= @echo
216
MKDIR	= mkdir
217
RM		= rm
95 dhylands 218
INSTALL	= install
2 dhylands 219
 
220
#--------------------------------------------------------------------------
221
#
222
# Setup stuff for the Common directory
223
#
224
 
225
MK_COMMON_DIR = $(MK_ROOT)/common
226
 
227
CPPFLAGS += -I . -I $(MK_COMMON_DIR)
228
 
229
vpath %.c   $(MK_COMMON_DIR)
230
vpath %.cpp $(MK_COMMON_DIR)
231
 
232
#--------------------------------------------------------------------------
233
#
234
# Get OS specific environment makefile.
235
#
236
 
237
MK_OS_ENV_FILE = $(MK_RULES_DIR)/mkEnv-$(MK_OS).mk
238
include $(MK_OS_ENV_FILE)
239