Subversion Repositories DevTools

Rev

Rev 2054 | Rev 2478 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2054 Rev 2429
Line 168... Line 168...
168
define	JatsRunTime
168
define	JatsRunTime
169
    $(GBE_PERL) -Mjats_runtime -e
169
    $(GBE_PERL) -Mjats_runtime -e
170
endef
170
endef
171
 
171
 
172
#.. Remove files contained within the specified list
172
#.. Remove files contained within the specified list
-
 
173
#   Used internally to delete generated files
173
#
174
#
174
#   Usage:      $(call RmFiles,VARIABLE_NAME)
175
#   Usage:      $(call RmFiles,VARIABLE_NAME)
175
#
176
#
176
define RmFiles
177
define RmFiles
177
	$(AA_PRE)(if [ "$(GBE_VERBOSE)" -gt 0 ]; then \
178
	$(AA_PRE)JatsFileUtil 'r0' '' $($1)
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
179
endef
196
 
180
 
197
#.. Install/uninstall the specified file
181
#.. Install/uninstall the specified file
198
#
182
#
199
#   Usage:      $(call InstallFile,dest,file,path,fmode)
183
#   Usage:      $(call InstallFile,dest,file,fmode)
200
#               $(call UninstallFile,file)
184
#               $(call UninstallFile,file)
201
#
185
#
202
define InstallFile
186
define InstallFile
203
    $(call CopyFile,installing,$1,$2,$3,$4)
187
    $(call CopyFile,installing,$1,$2,$3,)
204
endef
188
endef
205
 
189
 
206
define UninstallFile
190
define UninstallFile
207
    $(call UncopyFile,uninstalling,$1)
191
    $(call UncopyFile,uninstalling,$1)
208
endef
192
endef
209
 
193
 
210
#.. Package/Unpackage the specified file
194
#.. Package/Unpackage the specified file
211
#
195
#
212
#   Usage:      $(call PackageFile,dest,file,path,fmode)
196
#   Usage:      $(call PackageFile,dest,file,fmode)
213
#               $(call UnpackageFile,file)
197
#               $(call UnpackageFile,file)
214
#
198
#
215
define PackageFile
199
define PackageFile
216
    $(call CopyFile,packaging,$1,$2,$3,$4)
200
    $(call CopyFile,packaging,$1,$2,$3,)
217
endef
201
endef
218
 
202
 
219
define UnpackageFile
203
define UnpackageFile
220
    $(call UncopyFile,unpackaging,$1)
204
    $(call UncopyFile,unpackaging,$1)
221
endef
205
endef
222
 
206
 
223
#.. Generic Copy/Remove the specified file
207
#.. Generic Copy/Remove the specified file
224
#
208
#
225
#   Usage:      $(call CopyFile,Text,dest,file,path,fmode)
209
#   Usage:      $(call CopyFile,Text,dest,file,fmode)
226
#               $(call UncopyFile,Text,file)
210
#               $(call UncopyFile,Text,file)
227
#
211
#
228
#   Notes:
212
#   Notes:
229
#       dest, file and path
213
#       dest, file and path
230
#	May have spaces in them
214
#	May have spaces in them
231
#		These will have been escaped with a '\' which will
215
#		These will have been escaped with a '\' which will
232
#		need to be removed. The '\ ' is required to keep make
216
#		need to be removed. The '\ ' is required to keep make
233
#		happy elsewhere.
217
#		happy elsewhere.
234
#
218
#
-
 
219
#	Current implementation uses a dedicated JATS-internal program to perform
-
 
220
#	the operations. This is much better than the previous implementation
-
 
221
#	which was shell-based. Its problems included:
-
 
222
#		1) Very slow under Windows
-
 
223
#		2) Special handling on $
-
 
224
#		3) Windows Path length limitation of < ~260 characters
-
 
225
#
-
 
226
#	Implementation note:
-
 
227
#		1) Do not get the shell involved in invoking the command
235
#	May have '$' in them which we will need to escape
228
#	           Quote args in '' not "" as "" will trigger shell usage
-
 
229
#		   This is good as we don't need/want shell expansion either
-
 
230
#		2) Paths use '/'. This is passed though to the utility
236
#
231
#
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
232
#	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
233
#	NiceName - convert a '\ ' pathname into an string with plain spaces
257
#                 and $ escaped with a \.
-
 
258
#
234
#
259
AbsName = $(subst $$,\$$,$(subst $(spacealt),$(space),$(abspath $(subst \$(space),$(spacealt),$1))))
-
 
260
NiceName = $(subst $$,\$$,$(subst \$(space),$(space),$1))
235
NiceName = $(subst \$(space),$(space),$1)
261
 
-
 
262
define CopyFileNotWorking
-
 
263
	$(AA_PRE)(\
-
 
264
        set -vx;udest="$(call NiceName,$2)"; \
-
 
265
        dest="$(call AbsName,$2)"; \
-
 
266
        file="$(call NiceName,$3)"; \
-
 
267
        path="$(call AbsName,$4)"; \
-
 
268
        fmode="$(5)"; \
-
 
269
	echo "------ $1 $$udest"; \
-
 
270
        install -D --verbose "$$file" "$$dest"; \
-
 
271
        if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
-
 
272
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
-
 
273
        );
-
 
274
endef
-
 
275
 
236
 
276
define CopyFile
237
define CopyFile
277
	$(AA_PRE)(\
-
 
278
        udest="$(call NiceName,$2)"; \
-
 
279
        dest="$(call AbsName,$2)"; \
-
 
280
        file="$(call NiceName,$3)"; \
-
 
281
        path="$(call AbsName,$4)"; \
-
 
282
        fmode="$(5)"; \
-
 
283
	echo "------ $1 $$udest"; \
-
 
284
        if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
238
	$(AA_PRE)JatsFileUtil 'c0' '$1' '$(call NiceName,$2)' '$(call NiceName,$3)' '$4'
285
	if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
-
 
286
	if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
-
 
287
	$(rm) -f "$$dest"; \
-
 
288
        $(cp) "$$file" "$$dest" ;\
-
 
289
        if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
-
 
290
        $(if $(5),$(chmod) -f $$fmode "$$dest") ; \
-
 
291
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
-
 
292
        );
-
 
293
endef
239
endef
294
 
240
 
295
define UncopyFile
241
define UncopyFile
296
	$(AA_PRE)(\
-
 
297
        udest="$(call NiceName,$2)"; \
242
	$(AA_PRE)JatsFileUtil 'd0' '$1' '$(call NiceName,$2)'
298
        file="$(call AbsName,$2)"; \
-
 
299
	echo "------ $1 $$udest"; \
-
 
300
	if [ -f "$$file" ]; then \
-
 
301
		if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
-
 
302
		$(rm) -f "$$file"; \
-
 
303
	fi);
-
 
304
endef
243
endef
305
 
244
 
306
##
245
##