@@ -83,172 +83,3 @@ m4_ifdef([AM_INIT_AUTOMAKE],
83
83
dnl
84
84
m4_define ( [ $0 ] , [ ] ) [ ] dnl
85
85
] )
86
-
87
-
88
- dnl _XC_AMEND_DISTCLEAN_BODY ([LIST-OF-SUBDIRS])
89
- dnl -------------------------------------------------
90
- dnl Private macro.
91
- dnl
92
- dnl This macro performs shell code embedding into
93
- dnl configure script in order to modify distclean
94
- dnl and maintainer-clean targets of makefiles which
95
- dnl are located in given list of subdirs.
96
- dnl
97
- dnl See XC_AMEND_DISTCLEAN comments for details.
98
-
99
- m4_define ( [ _XC_AMEND_DISTCLEAN_BODY] ,
100
- [ dnl
101
- ## ---------------------------------- ##
102
- ## Start of distclean amending code ##
103
- ## ---------------------------------- ##
104
-
105
- for xc_subdir in [ $1 ]
106
- do
107
-
108
- if test ! -f "$xc_subdir/Makefile"; then
109
- echo "$xc_msg_err $xc_subdir/Makefile file not found. $xc_msg_abrt" >&2
110
- exit 1
111
- fi
112
-
113
- # Fetch dependency tracking file list from Makefile include lines.
114
-
115
- xc_inc_lines=`grep '^include .*(DEPDIR)' "$xc_subdir/Makefile" 2>/dev/null`
116
- xc_cnt_words=`echo "$xc_inc_lines" | wc -w | tr -d "$xc_space$xc_tab"`
117
-
118
- # --disable-dependency-tracking might have been used, consequently
119
- # there is nothing to amend without a dependency tracking file list.
120
-
121
- if test $xc_cnt_words -gt 0; then
122
-
123
- AC_MSG_NOTICE ( [ amending $xc_subdir/Makefile] )
124
-
125
- # Build Makefile specific patch hunk.
126
-
127
- xc_p="$xc_subdir/xc_patch.tmp"
128
-
129
- xc_rm_depfiles=`echo "$xc_inc_lines" \
130
- | $SED 's%include% -rm -f%' 2>/dev/null`
131
-
132
- xc_dep_subdirs=`echo "$xc_inc_lines" \
133
- | $SED 's%include[ [ ] ] [ [ ] ] *%%' 2>/dev/null \
134
- | $SED 's%(DEPDIR)/.*%(DEPDIR)%' 2>/dev/null \
135
- | sort | uniq`
136
-
137
- echo "$xc_rm_depfiles" >$xc_p
138
-
139
- for xc_dep_dir in $xc_dep_subdirs; do
140
- echo "${xc_tab}@xm_dep_cnt=\`ls $xc_dep_dir | wc -l 2>/dev/null\`; \\" >>$xc_p
141
- echo "${xc_tab}if test \$\$xm_dep_cnt -eq 0 && test -d $xc_dep_dir; then \\" >>$xc_p
142
- echo "${xc_tab} rm -rf $xc_dep_dir; \\" >>$xc_p
143
- echo "${xc_tab}fi" >>$xc_p
144
- done
145
-
146
- # Build Makefile patching sed scripts.
147
-
148
- xc_s1="$xc_subdir/xc_script_1.tmp"
149
- xc_s2="$xc_subdir/xc_script_2.tmp"
150
- xc_s3="$xc_subdir/xc_script_3.tmp"
151
-
152
- cat >$xc_s1 <<\_EOT
153
- /^distclean[ [ ] ] *:/,/^[ [ ^ ] ] [ [ ^ ] ] *:/{
154
- s/^.*(DEPDIR)/___xc_depdir_line___/
155
- }
156
- /^maintainer-clean[ [ ] ] *:/,/^[ [ ^ ] ] [ [ ^ ] ] *:/{
157
- s/^.*(DEPDIR)/___xc_depdir_line___/
158
- }
159
- _EOT
160
-
161
- cat >$xc_s2 <<\_EOT
162
- /___xc_depdir_line___$/{
163
- N
164
- /___xc_depdir_line___$/D
165
- }
166
- _EOT
167
-
168
- cat >$xc_s3 <<_EOT
169
- /^___xc_depdir_line___/{
170
- r $xc_p
171
- d
172
- }
173
- _EOT
174
-
175
- # Apply patch to Makefile and cleanup.
176
-
177
- $SED -f "$xc_s1" "$xc_subdir/Makefile" >"$xc_subdir/Makefile.tmp1"
178
- $SED -f "$xc_s2" "$xc_subdir/Makefile.tmp1" >"$xc_subdir/Makefile.tmp2"
179
- $SED -f "$xc_s3" "$xc_subdir/Makefile.tmp2" >"$xc_subdir/Makefile.tmp3"
180
-
181
- if test -f "$xc_subdir/Makefile.tmp3"; then
182
- mv -f "$xc_subdir/Makefile.tmp3" "$xc_subdir/Makefile"
183
- fi
184
-
185
- test -f "$xc_subdir/Makefile.tmp1" && rm -f "$xc_subdir/Makefile.tmp1"
186
- test -f "$xc_subdir/Makefile.tmp2" && rm -f "$xc_subdir/Makefile.tmp2"
187
- test -f "$xc_subdir/Makefile.tmp3" && rm -f "$xc_subdir/Makefile.tmp3"
188
-
189
- test -f "$xc_p" && rm -f "$xc_p"
190
- test -f "$xc_s1" && rm -f "$xc_s1"
191
- test -f "$xc_s2" && rm -f "$xc_s2"
192
- test -f "$xc_s3" && rm -f "$xc_s3"
193
-
194
- fi
195
-
196
- done
197
-
198
- ## -------------------------------- ##
199
- ## End of distclean amending code ##
200
- ## -------------------------------- ##
201
- dnl
202
- m4_define ( [ $0 ] , [ ] ) [ ] dnl
203
- ] )
204
-
205
-
206
- dnl XC_AMEND_DISTCLEAN ([LIST-OF-SUBDIRS])
207
- dnl -------------------------------------------------
208
- dnl Public macro.
209
- dnl
210
- dnl This macro embeds shell code into configure script
211
- dnl that amends, at configure runtime, the distclean
212
- dnl and maintainer-clean targets of Makefiles located
213
- dnl in all subdirs given in the mandatory white-space
214
- dnl separated list argument.
215
- dnl
216
- dnl Embedding only takes place when using automake 1.14
217
- dnl or newer, otherwise amending code is not included
218
- dnl in generated configure script.
219
- dnl
220
- dnl distclean and maintainer-clean targets are modified
221
- dnl to avoid unconditional removal of dependency subdirs
222
- dnl which triggers distclean and maintainer-clean errors
223
- dnl when using automake 'subdir-objects' option along
224
- dnl with per-target objects and source files existing in
225
- dnl multiple subdirs used for different build targets.
226
- dnl
227
- dnl New behavior first removes each dependency tracking
228
- dnl file independently, and only removes each dependency
229
- dnl subdir when it finds out that it no longer holds any
230
- dnl dependency tracking file.
231
- dnl
232
- dnl When configure option --disable-dependency-tracking
233
- dnl is used no amending takes place given that there are
234
- dnl no dependency tracking files.
235
-
236
- AC_DEFUN ( [ XC_AMEND_DISTCLEAN] ,
237
- [ dnl
238
- AC_PREREQ ( [ 2.50] ) dnl
239
- dnl
240
- m4_ifdef ( [ _AC_OUTPUT_MAIN_LOOP] ,
241
- [ m4_provide_if([ _AC_OUTPUT_MAIN_LOOP] , [ ] ,
242
- [ m4_fatal ( [ call to AC_OUTPUT needed before $0 ] ) ] )] ) dnl
243
- dnl
244
- m4_if ( [ $# ] , [ 1] , [ ] , [ m4_fatal ( [ $0 : wrong number of arguments] ) ] ) dnl
245
- m4_if ( [ $1 ] , [ ] , [ m4_fatal ( [ $0 : missing argument] ) ] ) dnl
246
- dnl
247
- AC_REQUIRE ( [ XC_CONFIGURE_PREAMBLE] ) dnl
248
- dnl
249
- m4_ifdef ( [ _AM_PROG_CC_C_O] ,
250
- [
251
- _XC_AMEND_DISTCLEAN_BODY([ $1 ] )
252
- ] ) dnl
253
- m4_define ( [ $0 ] , [ ] ) [ ] dnl
254
- ] )
0 commit comments