Subversion Repositories DevTools

Rev

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

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