| 227 |
dpurdie |
1 |
##############################################################################
|
| 3965 |
dpurdie |
2 |
# File: rules.std
|
| 227 |
dpurdie |
3 |
# Compat for older (embedded) makefiles
|
|
|
4 |
##############################################################################
|
|
|
5 |
#
|
|
|
6 |
|
|
|
7 |
SCM_ROOT = $(GBE_ROOT)
|
|
|
8 |
SCM_TYPE = $(GBE_TYPE)
|
|
|
9 |
SCM_BIN = $(GBE_BIN)
|
|
|
10 |
SCM_PLATFORM = $(GBE_PLATFORM)
|
|
|
11 |
|
|
|
12 |
#
|
|
|
13 |
###############################################################################
|
|
|
14 |
# Common definitions extracted from OPTIONS
|
|
|
15 |
##############################################################################
|
|
|
16 |
#
|
|
|
17 |
CC_PRE := @
|
|
|
18 |
XX_PRE := @
|
|
|
19 |
AA_PRE := @
|
|
|
20 |
|
| 241 |
dpurdie |
21 |
SHOWARGS := NONE
|
| 227 |
dpurdie |
22 |
|
| 241 |
dpurdie |
23 |
USE_FILTER := 1
|
|
|
24 |
LEAVETMP :=
|
|
|
25 |
SHOWENV :=
|
|
|
26 |
|
| 227 |
dpurdie |
27 |
ifdef OPTIONS
|
|
|
28 |
|
|
|
29 |
ifneq "$(findstring args,$(OPTIONS))" "" # Show arguments (default)
|
| 241 |
dpurdie |
30 |
CC_PRE :=
|
|
|
31 |
XX_PRE :=
|
|
|
32 |
SHOWARGS := ARGS
|
| 227 |
dpurdie |
33 |
endif
|
|
|
34 |
|
|
|
35 |
ifneq "$(findstring noargs,$(OPTIONS))" "" # Show no arguments
|
| 241 |
dpurdie |
36 |
CC_PRE := @
|
|
|
37 |
XX_PRE := @
|
|
|
38 |
SHOWARGS := NONE
|
| 227 |
dpurdie |
39 |
endif
|
|
|
40 |
|
|
|
41 |
ifneq "$(findstring allargs,$(OPTIONS))" "" # Show ALL arguments
|
|
|
42 |
AA_PRE :=
|
| 241 |
dpurdie |
43 |
SHOWARGS := ALL
|
| 227 |
dpurdie |
44 |
endif
|
|
|
45 |
|
|
|
46 |
ifneq "$(findstring filter,$(OPTIONS))" "" # Use filter (Default)
|
| 241 |
dpurdie |
47 |
USE_FILTER := 1
|
| 227 |
dpurdie |
48 |
endif
|
|
|
49 |
|
|
|
50 |
ifneq "$(findstring nofilter,$(OPTIONS))" "" # Don't use filter
|
| 241 |
dpurdie |
51 |
USE_FILTER :=
|
| 227 |
dpurdie |
52 |
endif
|
|
|
53 |
|
|
|
54 |
ifneq "$(findstring leavetmp,$(OPTIONS))" "" # Leave temp files
|
| 241 |
dpurdie |
55 |
LEAVETMP := 1
|
| 227 |
dpurdie |
56 |
endif
|
|
|
57 |
|
|
|
58 |
ifneq "$(findstring noleavetmp,$(OPTIONS))" "" # Don't leave temp files (Default)
|
| 241 |
dpurdie |
59 |
LEAVETMP :=
|
| 227 |
dpurdie |
60 |
endif
|
|
|
61 |
|
|
|
62 |
ifneq "$(findstring showenv,$(OPTIONS))" "" # Display env before commands
|
| 241 |
dpurdie |
63 |
SHOWENV := 1
|
| 227 |
dpurdie |
64 |
endif
|
|
|
65 |
|
|
|
66 |
ifneq "$(findstring noshowenv,$(OPTIONS))" "" # Don't display env before commands
|
| 241 |
dpurdie |
67 |
SHOWENV :=
|
| 227 |
dpurdie |
68 |
endif
|
|
|
69 |
|
|
|
70 |
endif
|
|
|
71 |
|
| 2930 |
dpurdie |
72 |
###############################################################################
|
|
|
73 |
# Some old VIX uses have the following EnvVars set. These can confuse the
|
|
|
74 |
# gnu autoconfigure process. Ensure that they are not set
|
|
|
75 |
|
|
|
76 |
unexport CC CXX CPP CPP_LINK CPPFLAGS
|
|
|
77 |
#unexport LD_LIBRARY_PATH
|
|
|
78 |
|
| 227 |
dpurdie |
79 |
#
|
|
|
80 |
###############################################################################
|
|
|
81 |
# Brain hurts stuff... $(space) becomes a macro containing 1 space
|
|
|
82 |
# other aren't so bad. These are used to make argument lists is a few
|
|
|
83 |
# places where we have to translate from a space seperated list to a
|
|
|
84 |
# something else seperated list (or vicky verka).
|
|
|
85 |
###############################################################################
|
|
|
86 |
#
|
|
|
87 |
comma := ,
|
|
|
88 |
plus := +
|
|
|
89 |
semicolon := ;
|
|
|
90 |
empty :=
|
|
|
91 |
space := $(empty) $(empty)
|
|
|
92 |
spacealt := %20
|
|
|
93 |
|
|
|
94 |
#
|
|
|
95 |
###############################################################################
|
| 303 |
dpurdie |
96 |
# Macros to assist in the handling of paths with spaces
|
|
|
97 |
# encodepath - Uses spacealt, uses /, space-sep-list
|
|
|
98 |
# Used to conatins lists of paths that may contain
|
|
|
99 |
# spaces. Used for INCLUDE and LIB paths
|
|
|
100 |
#
|
|
|
101 |
# decodepath - Decodes an encoded path-list.
|
|
|
102 |
# User specifies the item prefix and suffix.
|
|
|
103 |
# Return list uses \ and may have spaces in pathnames
|
|
|
104 |
# Prefix items with 1st-arg
|
|
|
105 |
# Join items with 2nd arg
|
|
|
106 |
#
|
|
|
107 |
# Usage:
|
|
|
108 |
# aa = $(call encodepath,c:\Program Files)
|
|
|
109 |
# $(call decodepath,-I,;,$(aa))
|
|
|
110 |
#
|
|
|
111 |
###############################################################################
|
|
|
112 |
#
|
|
|
113 |
encodepath = $(subst //,/,$(subst \,/,$(subst $(space),$(spacealt),$(strip $(1)))))
|
|
|
114 |
decodepath = $(subst $(spacealt),$(space),$(subst $(space),$(empty),$(patsubst %,$(1)%$(2),$(subst /,\,$(3)))))
|
|
|
115 |
|
|
|
116 |
#
|
|
|
117 |
###############################################################################
|
|
|
118 |
#
|
|
|
119 |
# Macros to convert relative to absolute paths
|
|
|
120 |
#
|
|
|
121 |
# Work around for a bug in make 3.81 where abspath assumes that the input
|
|
|
122 |
# is a relative path. The work around checks for paths that have a : or start
|
|
|
123 |
# with a '/ - and assumes these are absolute.
|
|
|
124 |
# It will only call makes 'abspath' for relative paths.
|
|
|
125 |
#
|
|
|
126 |
###############################################################################
|
|
|
127 |
#
|
|
|
128 |
myabspath = $(foreach dir,$1,$(call myabs1path,$(dir)))
|
|
|
129 |
myabs1path = $(if $(or $(findstring :,$1),$(filter /%,$1)),$1,$(abspath $1))
|
|
|
130 |
|
|
|
131 |
#
|
|
|
132 |
###############################################################################
|
| 227 |
dpurdie |
133 |
# A little macro used within each of the rules for translating a file from
|
|
|
134 |
# one type to another to print the environment if the variable SHOWENV has
|
|
|
135 |
# been defined.
|
|
|
136 |
###############################################################################
|
|
|
137 |
#
|
|
|
138 |
ifdef SHOWENV
|
|
|
139 |
define show_environment
|
| 245 |
dpurdie |
140 |
$(printenv)
|
| 227 |
dpurdie |
141 |
endef
|
|
|
142 |
else
|
|
|
143 |
define show_environment
|
|
|
144 |
endef
|
|
|
145 |
endif
|
|
|
146 |
|
|
|
147 |
#
|
| 303 |
dpurdie |
148 |
################################################################################
|
|
|
149 |
# A macro to dump out command files if the ARGS or ALLARGS option is set
|
|
|
150 |
# Usage: $(call show_cmdfile,<PathOfCommandFile>)
|
|
|
151 |
################################################################################
|
|
|
152 |
#
|
|
|
153 |
ifeq ($(SHOWARGS),NONE)
|
|
|
154 |
show_cmdfile =
|
|
|
155 |
else
|
|
|
156 |
show_cmdfile = echo "Using command file: $(1)";cat $(1);echo "End of Command file"
|
|
|
157 |
endif
|
|
|
158 |
|
|
|
159 |
#
|
| 227 |
dpurdie |
160 |
###############################################################################
|
|
|
161 |
# Support macros
|
|
|
162 |
###############################################################################
|
|
|
163 |
#
|
|
|
164 |
|
| 321 |
dpurdie |
165 |
#.. Invoke RunTime support operations
|
|
|
166 |
#
|
|
|
167 |
# Usage:
|
|
|
168 |
# $(JatsRunTime) function_name -- args
|
|
|
169 |
# Notes:
|
|
|
170 |
# Don't use " to quote arguments as it will invoke a shell
|
|
|
171 |
# under windows (and others). This can only slow it down.
|
|
|
172 |
# Using ' is OK
|
|
|
173 |
#
|
|
|
174 |
define JatsRunTime
|
|
|
175 |
$(GBE_PERL) -Mjats_runtime -e
|
|
|
176 |
endef
|
|
|
177 |
|
| 227 |
dpurdie |
178 |
#.. Remove files contained within the specified list
|
| 2076 |
dpurdie |
179 |
# Used internally to delete generated files
|
| 227 |
dpurdie |
180 |
#
|
|
|
181 |
# Usage: $(call RmFiles,VARIABLE_NAME)
|
|
|
182 |
#
|
|
|
183 |
define RmFiles
|
| 2312 |
dpurdie |
184 |
$(AA_PRE)JatsFileUtil 'r0' '' $($1)
|
| 227 |
dpurdie |
185 |
endef
|
|
|
186 |
|
|
|
187 |
#.. Install/uninstall the specified file
|
|
|
188 |
#
|
| 2074 |
dpurdie |
189 |
# Usage: $(call InstallFile,dest,file,fmode)
|
| 227 |
dpurdie |
190 |
# $(call UninstallFile,file)
|
|
|
191 |
#
|
|
|
192 |
define InstallFile
|
| 2074 |
dpurdie |
193 |
$(call CopyFile,installing,$1,$2,$3,)
|
| 227 |
dpurdie |
194 |
endef
|
|
|
195 |
|
|
|
196 |
define UninstallFile
|
|
|
197 |
$(call UncopyFile,uninstalling,$1)
|
|
|
198 |
endef
|
|
|
199 |
|
|
|
200 |
#.. Package/Unpackage the specified file
|
|
|
201 |
#
|
| 2074 |
dpurdie |
202 |
# Usage: $(call PackageFile,dest,file,fmode)
|
| 227 |
dpurdie |
203 |
# $(call UnpackageFile,file)
|
|
|
204 |
#
|
|
|
205 |
define PackageFile
|
| 2074 |
dpurdie |
206 |
$(call CopyFile,packaging,$1,$2,$3,)
|
| 227 |
dpurdie |
207 |
endef
|
|
|
208 |
|
|
|
209 |
define UnpackageFile
|
|
|
210 |
$(call UncopyFile,unpackaging,$1)
|
|
|
211 |
endef
|
|
|
212 |
|
|
|
213 |
#.. Generic Copy/Remove the specified file
|
|
|
214 |
#
|
| 2074 |
dpurdie |
215 |
# Usage: $(call CopyFile,Text,dest,file,fmode)
|
| 227 |
dpurdie |
216 |
# $(call UncopyFile,Text,file)
|
|
|
217 |
#
|
| 257 |
dpurdie |
218 |
# Notes:
|
|
|
219 |
# dest, file and path
|
|
|
220 |
# May have spaces in them
|
|
|
221 |
# These will have been escaped with a '\' which will
|
|
|
222 |
# need to be removed. The '\ ' is required to keep make
|
|
|
223 |
# happy elsewhere.
|
| 249 |
dpurdie |
224 |
#
|
| 2074 |
dpurdie |
225 |
# Current implementation uses a dedicated JATS-internal program to perform
|
|
|
226 |
# the operations. This is much better than the previous implementation
|
|
|
227 |
# which was shell-based. Its problems included:
|
|
|
228 |
# 1) Very slow under Windows
|
|
|
229 |
# 2) Special handling on $
|
|
|
230 |
# 3) Windows Path length limitation of < ~260 characters
|
| 249 |
dpurdie |
231 |
#
|
| 2074 |
dpurdie |
232 |
# Implementation note:
|
|
|
233 |
# 1) Do not get the shell involved in invoking the command
|
|
|
234 |
# Quote args in '' not "" as "" will trigger shell usage
|
|
|
235 |
# This is good as we don't need/want shell expansion either
|
| 2476 |
dpurdie |
236 |
# Shell startup is slow under windows.
|
| 2074 |
dpurdie |
237 |
# 2) Paths use '/'. This is passed though to the utility
|
| 257 |
dpurdie |
238 |
#
|
| 2074 |
dpurdie |
239 |
# Macros
|
| 257 |
dpurdie |
240 |
# NiceName - convert a '\ ' pathname into an string with plain spaces
|
| 2650 |
dpurdie |
241 |
# Convert nasty characters into %nn to get past the shell
|
|
|
242 |
# Characters to convert are:
|
|
|
243 |
# Percent(%) - Its our escape lead-in
|
|
|
244 |
# Not sure make handles such file
|
|
|
245 |
# singlequote(') - It quotes our arguments
|
|
|
246 |
# Ampersand(&) - If found make uses shell
|
| 257 |
dpurdie |
247 |
#
|
| 2650 |
dpurdie |
248 |
NiceName = $(subst \$(space), ,$(subst ',%27,$(subst &,%26,$(subst %,%25,$1))))
|
| 257 |
dpurdie |
249 |
|
| 227 |
dpurdie |
250 |
define CopyFile
|
| 2076 |
dpurdie |
251 |
$(AA_PRE)JatsFileUtil 'c0' '$1' '$(call NiceName,$2)' '$(call NiceName,$3)' '$4'
|
| 227 |
dpurdie |
252 |
endef
|
|
|
253 |
|
|
|
254 |
define UncopyFile
|
| 2076 |
dpurdie |
255 |
$(AA_PRE)JatsFileUtil 'd0' '$1' '$(call NiceName,$2)'
|
| 227 |
dpurdie |
256 |
endef
|
|
|
257 |
|
|
|
258 |
##
|