Subversion Repositories DevTools

Rev

Rev 241 | Go to most recent revision | Details | 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
 
22
USE_FILTER  = 1
23
LEAVETMP    =
24
SHOWENV     =
25
 
26
ifdef OPTIONS
27
 
28
ifneq "$(findstring args,$(OPTIONS))" ""        # Show arguments (default)
29
CC_PRE =
30
XX_PRE =
31
endif
32
 
33
ifneq "$(findstring noargs,$(OPTIONS))" ""      # Show no arguments
34
CC_PRE = @
35
XX_PRE = @
36
endif
37
 
38
ifneq "$(findstring allargs,$(OPTIONS))" ""     #  Show ALL arguments
39
AA_PRE :=
40
endif
41
 
42
ifneq "$(findstring filter,$(OPTIONS))" ""      # Use filter (Default)
43
USE_FILTER = 1
44
endif
45
 
46
ifneq "$(findstring nofilter,$(OPTIONS))" ""    # Don't use filter
47
USE_FILTER  = 
48
endif
49
 
50
ifneq "$(findstring leavetmp,$(OPTIONS))" ""    # Leave temp files
51
LEAVETMP = 1
52
endif
53
 
54
ifneq "$(findstring noleavetmp,$(OPTIONS))" ""  # Don't leave temp files (Default)
55
LEAVETMP =
56
endif
57
 
58
ifneq "$(findstring showenv,$(OPTIONS))" ""     # Display env before commands
59
SHOWENV = 1
60
endif
61
 
62
ifneq "$(findstring noshowenv,$(OPTIONS))" ""   # Don't display env before commands
63
SHOWENV =
64
endif
65
 
66
endif
67
 
68
#
69
###############################################################################
70
# Brain hurts stuff... $(space) becomes a macro containing 1 space
71
# other aren't so bad.  These are used to make argument lists is a few 
72
# places where we have to translate from a space seperated list to a 
73
# something else seperated list (or vicky verka).
74
###############################################################################
75
#
76
comma		:= ,
77
plus		:= +
78
semicolon	:= ;
79
empty		:= 
80
space		:= $(empty) $(empty)
81
spacealt	:= %20
82
 
83
#
84
###############################################################################
85
# A little macro used within each of the rules for translating a file from 
86
# one type to another to print the environment if the variable SHOWENV has 
87
# been defined.
88
###############################################################################
89
#
90
ifdef SHOWENV
91
define show_environment
92
		$(GBE_BIN)/printenv
93
endef
94
else
95
define show_environment
96
endef
97
endif
98
 
99
#
100
###############################################################################
101
# Verbose versions of specific commands
102
###############################################################################
103
#
104
 
105
ifdef VERBOSE
106
GBE_RM		=$(rm)
107
GBE_RMDIR	=$(rmdir)
108
else
109
GBE_RM		=@$(rm)
110
GBE_RMDIR	=@$(rmdir)
111
endif
112
 
113
#
114
###############################################################################
115
# Support macros
116
###############################################################################
117
#
118
 
119
#.. Remove files contained within the specified list
120
#
121
#   Usage:      $(call RmFiles,VARIABLE_NAME)
122
#
123
define RmFiles
124
	@(if [ "$(GBE_VERBOSE)" -gt 0 ]; then \
125
		echo Removing $($(1)); fi; \
126
	CHOWNS=; \
127
	RMS=; \
128
	for file in $($(1)); do \
129
		if [ -f $$file -o -h $$file ]; then \
130
			if [ ! -w $$file ]; then \
131
				CHOWNS="$$CHOWNS $$file"; \
132
			fi; \
133
			RMS="$$RMS $$file"; \
134
		fi; \
135
	done; \
136
	if [ -n "$$RMS" ]; then \
137
		if [ -n "$$CHOWNS" ]; then \
138
			$(chmod) -f +w $$CHOWNS; \
139
		fi; \
140
		$(rm) -f $$RMS; \
141
	fi);
142
endef
143
 
144
#.. Install/uninstall the specified file
145
#
146
#   Usage:      $(call InstallFile,dest,file,path,fmode)
147
#               $(call UninstallFile,file)
148
#
149
define InstallFile
150
    $(call CopyFile,installing,$1,$2,$3,$4)
151
endef
152
 
153
define UninstallFile
154
    $(call UncopyFile,uninstalling,$1)
155
endef
156
 
157
#.. Package/Unpackage the specified file
158
#
159
#   Usage:      $(call PackageFile,dest,file,path,fmode)
160
#               $(call UnpackageFile,file)
161
#
162
define PackageFile
163
    $(call CopyFile,packaging,$1,$2,$3,$4)
164
endef
165
 
166
define UnpackageFile
167
    $(call UncopyFile,unpackaging,$1)
168
endef
169
 
170
#.. Generic Copy/Remove the specified file
171
#
172
#   Usage:      $(call CopyFile,Text,dest,file,path,fmode)
173
#               $(call UncopyFile,Text,file)
174
#
175
define CopyFile
176
	@(echo ------ $1 "$2"; \
177
        dest=$(subst $$,\$$,$(2)); file=$(subst $$,\$$,$(3)); path=$(4); fmode=$(5); \
178
        if [ ! -f "$$file" ] ; then echo "$1 source file not found: $$file" ; exit 1; fi;\
179
	if [ ! -d "$$path" ] ; then $(mkdir) -p "$$path"; fi; \
180
	if [ -f "$$dest" -a ! -w "$$dest" ]; then $(chmod) -f +w "$$dest"; fi; \
181
	$(rm) -f "$$dest"; \
182
        $(cp) "$$file" "$$dest" ;\
183
        if [ $$? -gt 0 ] ; then echo "$1 copy error" ; exit 1; fi ;\
184
        $(if $(5),$(chmod) -f $$fmode "$$dest") ; \
185
        if [ ! -f "$$dest" ] ; then echo "$1 file not found after copy: $$dest" ; exit 1; fi; \
186
        );
187
endef
188
 
189
define UncopyFile
190
	@(echo ------ $1 "$2"; \
191
        file=$(subst $$,\$$,$2); \
192
	if [ -f "$$file" ]; then \
193
		if [ ! -w "$$file" ]; then $(chmod) -f +w "$$file"; fi; \
194
		$(rm) -f "$$file"; \
195
	fi);
196
endef
197
 
198
 
199
##