Subversion Repositories DevTools

Rev

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

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