| 227 |
dpurdie |
1 |
# -*- mode: mak; tabs: 8; -*-
|
|
|
2 |
#
|
|
|
3 |
##############################################################################
|
|
|
4 |
# Compat for older (embedded) makefiles
|
|
|
5 |
##############################################################################
|
|
|
6 |
#
|
|
|
7 |
|
|
|
8 |
SCM_ROOT = $(GBE_ROOT)
|
|
|
9 |
SCM_TYPE = $(GBE_TYPE)
|
|
|
10 |
SCM_BIN = $(GBE_BIN)
|
|
|
11 |
SCM_PLATFORM = $(GBE_PLATFORM)
|
|
|
12 |
|
|
|
13 |
#
|
|
|
14 |
###############################################################################
|
|
|
15 |
# Common definitions extracted from OPTIONS
|
|
|
16 |
##############################################################################
|
|
|
17 |
#
|
|
|
18 |
CC_PRE := @
|
|
|
19 |
XX_PRE := @
|
|
|
20 |
AA_PRE := @
|
|
|
21 |
|
| 241 |
dpurdie |
22 |
SHOWARGS := NONE
|
| 227 |
dpurdie |
23 |
|
| 241 |
dpurdie |
24 |
USE_FILTER := 1
|
|
|
25 |
LEAVETMP :=
|
|
|
26 |
SHOWENV :=
|
|
|
27 |
|
| 227 |
dpurdie |
28 |
ifdef OPTIONS
|
|
|
29 |
|
|
|
30 |
ifneq "$(findstring args,$(OPTIONS))" "" # Show arguments (default)
|
| 241 |
dpurdie |
31 |
CC_PRE :=
|
|
|
32 |
XX_PRE :=
|
|
|
33 |
SHOWARGS := ARGS
|
| 227 |
dpurdie |
34 |
endif
|
|
|
35 |
|
|
|
36 |
ifneq "$(findstring noargs,$(OPTIONS))" "" # Show no arguments
|
| 241 |
dpurdie |
37 |
CC_PRE := @
|
|
|
38 |
XX_PRE := @
|
|
|
39 |
SHOWARGS := NONE
|
| 227 |
dpurdie |
40 |
endif
|
|
|
41 |
|
|
|
42 |
ifneq "$(findstring allargs,$(OPTIONS))" "" # Show ALL arguments
|
|
|
43 |
AA_PRE :=
|
| 241 |
dpurdie |
44 |
SHOWARGS := ALL
|
| 227 |
dpurdie |
45 |
endif
|
|
|
46 |
|
|
|
47 |
ifneq "$(findstring filter,$(OPTIONS))" "" # Use filter (Default)
|
| 241 |
dpurdie |
48 |
USE_FILTER := 1
|
| 227 |
dpurdie |
49 |
endif
|
|
|
50 |
|
|
|
51 |
ifneq "$(findstring nofilter,$(OPTIONS))" "" # Don't use filter
|
| 241 |
dpurdie |
52 |
USE_FILTER :=
|
| 227 |
dpurdie |
53 |
endif
|
|
|
54 |
|
|
|
55 |
ifneq "$(findstring leavetmp,$(OPTIONS))" "" # Leave temp files
|
| 241 |
dpurdie |
56 |
LEAVETMP := 1
|
| 227 |
dpurdie |
57 |
endif
|
|
|
58 |
|
|
|
59 |
ifneq "$(findstring noleavetmp,$(OPTIONS))" "" # Don't leave temp files (Default)
|
| 241 |
dpurdie |
60 |
LEAVETMP :=
|
| 227 |
dpurdie |
61 |
endif
|
|
|
62 |
|
|
|
63 |
ifneq "$(findstring showenv,$(OPTIONS))" "" # Display env before commands
|
| 241 |
dpurdie |
64 |
SHOWENV := 1
|
| 227 |
dpurdie |
65 |
endif
|
|
|
66 |
|
|
|
67 |
ifneq "$(findstring noshowenv,$(OPTIONS))" "" # Don't display env before commands
|
| 241 |
dpurdie |
68 |
SHOWENV :=
|
| 227 |
dpurdie |
69 |
endif
|
|
|
70 |
|
|
|
71 |
endif
|
|
|
72 |
|
|
|
73 |
#
|
|
|
74 |
###############################################################################
|
|
|
75 |
# Brain hurts stuff... $(space) becomes a macro containing 1 space
|
|
|
76 |
# other aren't so bad. These are used to make argument lists is a few
|
|
|
77 |
# places where we have to translate from a space seperated list to a
|
|
|
78 |
# something else seperated list (or vicky verka).
|
|
|
79 |
###############################################################################
|
|
|
80 |
#
|
|
|
81 |
comma := ,
|
|
|
82 |
plus := +
|
|
|
83 |
semicolon := ;
|
|
|
84 |
empty :=
|
|
|
85 |
space := $(empty) $(empty)
|
|
|
86 |
spacealt := %20
|
|
|
87 |
|
|
|
88 |
#
|
|
|
89 |
###############################################################################
|
| 303 |
dpurdie |
90 |
# Macros to assist in the handling of paths with spaces
|
|
|
91 |
# encodepath - Uses spacealt, uses /, space-sep-list
|
|
|
92 |
# Used to conatins lists of paths that may contain
|
|
|
93 |
# spaces. Used for INCLUDE and LIB paths
|
|
|
94 |
#
|
|
|
95 |
# decodepath - Decodes an encoded path-list.
|
|
|
96 |
# User specifies the item prefix and suffix.
|
|
|
97 |
# Return list uses \ and may have spaces in pathnames
|
|
|
98 |
# Prefix items with 1st-arg
|
|
|
99 |
# Join items with 2nd arg
|
|
|
100 |
#
|
|
|
101 |
# Usage:
|
|
|
102 |
# aa = $(call encodepath,c:\Program Files)
|
|
|
103 |
# $(call decodepath,-I,;,$(aa))
|
|
|
104 |
#
|
|
|
105 |
###############################################################################
|
|
|
106 |
#
|
|
|
107 |
encodepath = $(subst //,/,$(subst \,/,$(subst $(space),$(spacealt),$(strip $(1)))))
|
|
|
108 |
decodepath = $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,$(1)%$(2),$(subst /,\,$(3)))))
|
|
|
109 |
|
|
|
110 |
#
|
|
|
111 |
###############################################################################
|
|
|
112 |
#
|
|
|
113 |
# Macros to convert relative to absolute paths
|
|
|
114 |
#
|
|
|
115 |
# Work around for a bug in make 3.81 where abspath assumes that the input
|
|
|
116 |
# is a relative path. The work around checks for paths that have a : or start
|
|
|
117 |
# with a '/ - and assumes these are absolute.
|
|
|
118 |
# It will only call makes 'abspath' for relative paths.
|
|
|
119 |
#
|
|
|
120 |
###############################################################################
|
|
|
121 |
#
|
|
|
122 |
myabspath = $(foreach dir,$1,$(call myabs1path,$(dir)))
|
|
|
123 |
myabs1path = $(if $(or $(findstring :,$1),$(filter /%,$1)),$1,$(abspath $1))
|
|
|
124 |
|
|
|
125 |
#
|
|
|
126 |
###############################################################################
|
| 227 |
dpurdie |
127 |
# A little macro used within each of the rules for translating a file from
|
|
|
128 |
# one type to another to print the environment if the variable SHOWENV has
|
|
|
129 |
# been defined.
|
|
|
130 |
###############################################################################
|
|
|
131 |
#
|
|
|
132 |
ifdef SHOWENV
|
|
|
133 |
define show_environment
|
| 245 |
dpurdie |
134 |
$(printenv)
|
| 227 |
dpurdie |
135 |
endef
|
|
|
136 |
else
|
|
|
137 |
define show_environment
|
|
|
138 |
endef
|
|
|
139 |
endif
|
|
|
140 |
|
|
|
141 |
#
|
| 303 |
dpurdie |
142 |
################################################################################
|
|
|
143 |
# A macro to dump out command files if the ARGS or ALLARGS option is set
|
|
|
144 |
# Usage: $(call show_cmdfile,<PathOfCommandFile>)
|
|
|
145 |
################################################################################
|
|
|
146 |
#
|
|
|
147 |
ifeq ($(SHOWARGS),NONE)
|
|
|
148 |
show_cmdfile =
|
|
|
149 |
else
|
|
|
150 |
show_cmdfile = echo "Using command file: $(1)";cat $(1);echo "End of Command file"
|
|
|
151 |
endif
|
|
|
152 |
|
|
|
153 |
#
|
| 227 |
dpurdie |
154 |
###############################################################################
|
|
|
155 |
# Support macros
|
|
|
156 |
###############################################################################
|
|
|
157 |
#
|
|
|
158 |
|
| 321 |
dpurdie |
159 |
#.. Invoke RunTime support operations
|
|
|
160 |
#
|
|
|
161 |
# Usage:
|
|
|
162 |
# $(JatsRunTime) function_name -- args
|
|
|
163 |
# Notes:
|
|
|
164 |
# Don't use " to quote arguments as it will invoke a shell
|
|
|
165 |
# under windows (and others). This can only slow it down.
|
|
|
166 |
# Using ' is OK
|
|
|
167 |
#
|
|
|
168 |
define JatsRunTime
|
|
|
169 |
$(GBE_PERL) -Mjats_runtime -e
|
|
|
170 |
endef
|
|
|
171 |
|
| 227 |
dpurdie |
172 |
#.. Remove files contained within the specified list
|
|
|
173 |
#
|
|
|
174 |
# Usage: $(call RmFiles,VARIABLE_NAME)
|
|
|
175 |
#
|
|
|
176 |
define RmFiles
|
| 261 |
dpurdie |
177 |
$(AA_PRE)(if [ "$(GBE_VERBOSE)" -gt 0 ]; then \
|
| 227 |
dpurdie |
178 |
echo Removing $($(1)); fi; \
|
|
|
179 |
CHOWNS=; \
|
|
|
180 |
RMS=; \
|
|
|
181 |
for file in $($(1)); do \
|
|
|
182 |
if [ -f $$file -o -h $$file ]; then \
|
|
|
183 |
if [ ! -w $$file ]; then \
|
|
|
184 |
CHOWNS="$$CHOWNS $$file"; \
|
|
|
185 |
fi; \
|
|
|
186 |
RMS="$$RMS $$file"; \
|
|
|
187 |
fi; \
|
|
|
188 |
done; \
|
|
|
189 |
if [ -n "$$RMS" ]; then \
|
|
|
190 |
if [ -n "$$CHOWNS" ]; then \
|
|
|
191 |
$(chmod) -f +w $$CHOWNS; \
|
|
|
192 |
fi; \
|
|
|
193 |
$(rm) -f $$RMS; \
|
|
|
194 |
fi);
|
|
|
195 |
endef
|
|
|
196 |
|
|
|
197 |
#.. Install/uninstall the specified file
|
|
|
198 |
#
|
|
|
199 |
# Usage: $(call InstallFile,dest,file,path,fmode)
|
|
|
200 |
# $(call UninstallFile,file)
|
|
|
201 |
#
|
|
|
202 |
define InstallFile
|
|
|
203 |
$(call CopyFile,installing,$1,$2,$3,$4)
|
|
|
204 |
endef
|
|
|
205 |
|
|
|
206 |
define UninstallFile
|
|
|
207 |
$(call UncopyFile,uninstalling,$1)
|
|
|
208 |
endef
|
|
|
209 |
|
|
|
210 |
#.. Package/Unpackage the specified file
|
|
|
211 |
#
|
|
|
212 |
# Usage: $(call PackageFile,dest,file,path,fmode)
|
|
|
213 |
# $(call UnpackageFile,file)
|
|
|
214 |
#
|
|
|
215 |
define PackageFile
|
|
|
216 |
$(call CopyFile,packaging,$1,$2,$3,$4)
|
|
|
217 |
endef
|
|
|
218 |
|
|
|
219 |
define UnpackageFile
|
|
|
220 |
$(call UncopyFile,unpackaging,$1)
|
|
|
221 |
endef
|
|
|
222 |
|
|
|
223 |
#.. Generic Copy/Remove the specified file
|
|
|
224 |
#
|
|
|
225 |
# Usage: $(call CopyFile,Text,dest,file,path,fmode)
|
|
|
226 |
# $(call UncopyFile,Text,file)
|
|
|
227 |
#
|
| 257 |
dpurdie |
228 |
# Notes:
|
|
|
229 |
# dest, file and path
|
|
|
230 |
# May have spaces in them
|
|
|
231 |
# These will have been escaped with a '\' which will
|
|
|
232 |
# need to be removed. The '\ ' is required to keep make
|
|
|
233 |
# happy elsewhere.
|
| 249 |
dpurdie |
234 |
#
|
| 257 |
dpurdie |
235 |
# May have '$' in them which we will need to escape
|
| 249 |
dpurdie |
236 |
#
|
| 257 |
dpurdie |
237 |
# Windows copy has limitations.
|
|
|
238 |
# Abs path length must < 260
|
|
|
239 |
# Passing a relative path does not solve the problem
|
|
|
240 |
# Moreover, if the relative path contains one or more ../
|
|
|
241 |
# sequences, then the 'cp' command creates a complete path
|
|
|
242 |
# before removing the zzz/.. sequences - and this must not exceed
|
|
|
243 |
# 259 characters.
|
|
|
244 |
#
|
|
|
245 |
# At the moment we get the most out of the windows 'cp' by
|
|
|
246 |
# passing it a clean absolute pathname, but there is still
|
|
|
247 |
# a limit of ~259 characters. This affects many programs, not just
|
|
|
248 |
# cp but make, rm, chmod ...
|
|
|
249 |
#
|
|
|
250 |
#
|
|
|
251 |
# Nice Macros
|
|
|
252 |
# AbsName - convert a '\ ' pathname into an absolute path with plain spaces
|
|
|
253 |
# and $ escaped with a \.
|
|
|
254 |
# In the process 'spaces' need to be replaced with something to
|
|
|
255 |
# keep abspath from splitting on space.
|
|
|
256 |
# NiceName - convert a '\ ' pathname into an string with plain spaces
|
|
|
257 |
# and $ escaped with a \.
|
|
|
258 |
#
|
|
|
259 |
AbsName = $(subst $$,\$$,$(subst $(spacealt),$(space),$(abspath $(subst \$(space),$(spacealt),$1))))
|
|
|
260 |
NiceName = $(subst $$,\$$,$(subst \$(space),$(space),$1))
|
|
|
261 |
|
| 227 |
dpurdie |
262 |
define CopyFile
|
| 261 |
dpurdie |
263 |
$(AA_PRE)(\
|
| 257 |
dpurdie |
264 |
udest="$(call NiceName,$2)"; \
|
|
|
265 |
dest="$(call AbsName,$2)"; \
|
|
|
266 |
file="$(call NiceName,$3)"; \
|
|
|
267 |
path="$(call AbsName,$4)"; \
|
| 249 |
dpurdie |
268 |
fmode="$(5)"; \
|
| 257 |
dpurdie |
269 |
echo "------ $1 $$udest"; \
|
| 227 |
dpurdie |
270 |
if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
|
|
|
271 |
if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
|
|
|
272 |
if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
|
|
|
273 |
$(rm) -f "$$dest"; \
|
|
|
274 |
$(cp) "$$file" "$$dest" ;\
|
|
|
275 |
if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
|
|
|
276 |
$(if $(5),$(chmod) -f $$fmode "$$dest") ; \
|
|
|
277 |
if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
|
|
|
278 |
);
|
|
|
279 |
endef
|
|
|
280 |
|
|
|
281 |
define UncopyFile
|
| 257 |
dpurdie |
282 |
$(AA_PRE)(\
|
|
|
283 |
udest="$(call NiceName,$2)"; \
|
|
|
284 |
file="$(call AbsName,$2)"; \
|
|
|
285 |
echo "------ $1 $$udest"; \
|
| 227 |
dpurdie |
286 |
if [ -f "$$file" ]; then \
|
|
|
287 |
if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
|
|
|
288 |
$(rm) -f "$$file"; \
|
|
|
289 |
fi);
|
|
|
290 |
endef
|
|
|
291 |
|
|
|
292 |
##
|