1# This file is part of the aMule project. 2# 3# Copyright (c) 2003-2011 aMule Team ( admin@amule.org / http://www.amule.org ) 4# Copyright (c) 2006-2011 D��vai Tam��s ( gonosztopi@amule.org ) 5# 6# This program is free software; you can redistribute it and/or 7# modify it under the terms of the GNU General Public License 8# as published by the Free Software Foundation; either 9# version 2 of the License, or (at your option) any later version. 10# 11# This program is distributed in the hope that it will be useful, 12# but WITHOUT ANY WARRANTY; without even the implied warranty of 13# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14# GNU General Public License for more details. 15# 16# You should have received a copy of the GNU General Public License 17# along with this program; if not, write to the Free Software 18# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 19# 20 21# The sed script is tested with GNU sed versions 3.02, 4.1.2 22# The generated Makefiles are tested with GNU make versions 3.79.1, 3.80 23 24 25# Denoising levels: 26# 27# 0 - do nothing, handled outside the scope of this script. 28# 29# 1 - only strip Makefiles from comments and empty lines, this should 30# theoretically speed up 'make', although not as much that you could 31# notice it. 32# 33# 2 - leave directory change messages from make, but silence normal 34# command printing. No echo denoising at this level. 35# 36# 3 - silence all messages from make, and partial echo denoising. 37# 38# 4 - full denoising: 39# * silence all messages from make 40# * full echo denoising 41# * compiler warning suppression 42 43 44# Syntax of this file: 45# 46# This file gets preprocessed, all comments and empty lines removed. The 47# preprocessor understands '#if ', '#else' and '#endif' commands, as long 48# as they start on the first character on the line. No whitespace is 49# allowed before the commands. Note that the space character after #if is 50# part of the command, if it is replaced by a tab then it won't make a 51# command anymore! 52# 53# #if truth testing: 54# 55# #if currently understands only one keyword: 'level', followed by a number 56# - the current denoising level. There may be any arbitrary characters 57# between the keyword and the value - i.e. 'levels 2,3' will also match 58# when 'level 3' matches. 59# 60# #if preprocessor commands may be nested for at least 4000 levels deep :-) 61# 62# The preprocessor script can be found at the end of this file. 63 64 65# ----- now the code ----- 66 67# suppress messages from make 68 69#if levels 3,4 701 i\ 71MAKEFLAGS=-s --no-print-directory 72#endif 73 74#if level 2 751 i\ 76MAKEFLAGS=-w -s 77#endif 78 79 80#if levels 2,3,4 81:0 82#endif 83 84 85# delete comments 86/^#/ d 87 88# delete empty lines 89/^[ ]*$/ d 90 91 92# take precedence over automake's silent rules feature 93#if levels 2,3,4 94/^AM_V_[A-Za-z]\+[ ]*=/ d 95/^am__v_[A-Za-z]\+_0\?[ ]*=/ d 96/^AM_DEFAULT_VERBOSITY[ ]*=/ d 97#endif 98 99 100# rewrite compiler flags 101#if level 4 102/=/ { 103 /^[^=]*[^R]CFLAGS/ b 8 104 /^[^=]*CPPFLAGS/ b 8 105 /^[^=]*CXXFLAGS/ b 8 106 b 9 107 :8 108 # save -Wl, -Wa, and -Wp, flags, they're for linker, assember and preprocessor respectively 109 s/ -Wl,/ -%l,/g 110 s/ -Wa,/ -%a,/g 111 s/ -Wp,/ -%p,/g 112 113 # delete all -W flags 114 / -W/ s/ -W[^ ]*//g 115 116 # restore -Wl, -Wa, and -Wp, flags 117 s/ -%l,/ -Wl,/g 118 s/ -%a,/ -Wa,/g 119 s/ -%p,/ -Wp,/g 120 121 # insert -w flag into MULECFLAGS and MULECXXFLAGS if it isn't already in 122 /^MULEC\(XX\)\?FLAGS/! b 9 123 / -w/! s/=/= -w/ 124 :9 125} 126#endif 127 128 129# rewrite rules 130#if levels 2,3,4 131# all rules contain ':' and start at the very beginning of the line 132/^[^ ].*:/ { 133 # no rules contain '=', so just skip these lines 134 /=/ b 135 136 # save rule target in secondary buffer 137 h 138 s/\([^:][^:]*\):.*/\1/ 139 x 140 141 # skip continuation lines 142 :1 143 /\\$/ { 144 n 145 b 1 146 } 147 148 # process rule commands 149 :2 150 n 151 :3 152 153 # delete comments inside rules 154 /^#/ { 155 s/.*// 156 N 157 s/\n//g 158 b 3 159 } 160 161 # if the current line is empty or not anymore a command, parse as usual 162 /^$/ b 0 163 /^[^ ]/ b 0 164 165 # get rid of the last pieces of automake's silent rules feature 166 s/^ $(AM_V_[A-Za-z]\+)/ / 167 168 x 169 /^\n/ b 5 170 171 # skipping install-strip target, since it will trigger the echo-denoiser, 172 # and would silence the whole installation, which is absolutely not wanted 173 /^install-strip$/ { 174 s/.*// 175 x 176 b 0 177 } 178 179 # do some output based on rule target 180 /\.o$/ { 181 i\ 182 echo "Compiling $(<F)" 183 b 4 184 } 185 /\.obj$/ { 186 i\ 187 echo "Compiling $(<F)" 188 b 4 189 } 190 /\.a$/ { 191 i\ 192 echo "Building $(@F)" 193 b 4 194 } 195 /$(EXEEXT)$/ { 196 i\ 197 echo "Linking $(@F)" 198 b 4 199 } 200 /^\.po\.g\?mo$/ { 201 i\ 202 echo "Generating translations for $(<F:.po=)" 203 b 4 204 } 205 /\.cpp$/ { 206 i\ 207 echo "Generating $(@F)" 208 b 4 209 } 210 /\.moc$/ { 211 i\ 212 echo "Compiling meta objects $(@)" 213 b 4 214 } 215 /\.$(OBJEXT)$/ { 216 i\ 217 echo "Compiling $(<F)" 218 b 4 219 } 220 /^$(DOMAIN)\.pot-update$/ { 221 i\ 222 echo "Updating translation catalog template" 223 b 4 224 } 225 /^$(POFILES)$/ { 226 i\ 227 echo "Updating translation catalog for $(@F:.po=)" 228 b 4 229 } 230 /^\.nop\.po-update$/ { 231 i\ 232 echo "Updating translation catalog for $(<F:.nop=)" 233 b 4 234 } 235 :4 236 # indicate that we already did the echo thingie 237 # 238 # s/^/\n/ works with newer sed versions like 4.1.2, 239 # but unfortunately msys uses sed 3.02, which does not 240 # translate \n to a newline in the replacement string. 241 #s/^/\n/ 242 # 243 # Compatible method: include a newline literally 244 s/^/\ 245/ 246 :5 247 248 # If --enable-maintainer-mode, Makefiles may be automatically regenerated. 249 # Denoise new Makefile aswell. 250 /Makefile$/ { 251 x 252 /echo/! { 253 /config\.status[ ][ ]*[^ ][^ ]*/ s/\(config\.status[ ][ ]*[^ ][^ ]*[^;\&\|]*\)\(.*\)/\1 denoiser\2/ 254 } 255 x 256 } 257 258 x 259 260#if levels 3,4 261 # Denoise echo commands (assuming that no echo command contains the ';' character) 262 # 263 # Denoising works by redirecting output to /dev/null, which is slower, though safer 264 # than removing the command. 265 /^[ ]*@*echo/ { 266 x 267 /maintainer-clean-generic/ b 6a 268 /uninstall/ b 6c 269 # Install targets may contain echo commands that must not be redirected, 270 # so skip this echo unless it contains installation code 271 /install/ { 272 x 273 /$(INSTALL/ b 6d 274 /installing/ b 6d 275 b 6 276 :6d 277 x 278 } 279 :6c 280#if level 3 281 /maintainer/ b 6a 282 /$(RECURSIVE_TARGETS)/ b 6a 283 /recursive/ b 6a 284#endif 285 b 6b 286 :6a 287 x 288 b 6 289 :6b 290 x 291 G 292 h 293 s/\(echo[^;][^;]*\).*/\1/ 294 # do not redirect if it's already redirected 295 />/ { 296 g 297 s/[^\n]*// 298 x 299 s/\n.*// 300 b 6 301 } 302 g 303 s/[^\n]*// 304 x 305 s/\n.*// 306 s/\(.*echo[^;][^;]*\)\(.*\)/\1>\/dev\/null\2/ 307 :6 308 } 309#endif (levels 3,4) 310 311 # mkinstalldirs will also echo its job, sink its output too 312 /$(mkinstalldirs)/ { 313 G 314 h 315 s/\($(mkinstalldirs)[^;][^;]*\).*/\1/ 316 # do not redirect if it's already redirected 317 />/ { 318 g 319 s/[^\n]*// 320 x 321 s/\n.*// 322 b 7 323 } 324 g 325 s/[^\n]*// 326 x 327 s/\n.*// 328 s/\(.*$(mkinstalldirs)[^;][^;]*\)\(.*\)/\1>\/dev\/null\2/ 329 :7 330 } 331 332#if level 4 333 # the above applies to msgfmt, but here it's enough to remove the '--statistics' flag 334 /$(GMSGFMT)/ s/--statistics// 335 336 # msgmerge needs a --silent flag 337 s/$(MSGMERGE)/\0 --silent/ 338 s/$(MSGMERGE_UPDATE)/\0 --silent/ 339#endif 340 341 # the following two ruleset must be the last two in this block and in this order! 342 343#if levels 3,4 344 # uninstallation 345 /^[ ]*rm -f[^;]*$(DESTDIR)/ { 346 x 347 /uninstall/ { 348 H 349 g 350 s/.*rm -f[^;]*$(DESTDIR)\([^;" ][^;" ]*\).*/ echo "Uninstalling \1"; \\/ 351 P 352 g 353 s/[^\n]*// 354 x 355 s/\n.*// 356 # skip checking for install: 1) trivially false 2) uninstall would match /install/ 357 b 2 358 } 359 x 360 } 361 362 # installation 363 /^[ ]*$([^)]*INSTALL/ { 364 x 365 /install/ { 366 H 367 g 368 s/.*$(DESTDIR)\([^;" ][^;" ]*\).*/ echo "Installing \1"; \\/ 369 s/$(modulesdir)$$dir/$(modulesdir)/ 370 P 371 g 372 s/[^\n]*// 373 x 374 s/\n.*// 375 b 2 376 } 377 x 378 } 379#endif (levels 3,4) 380 381 b 2 382} 383#endif (levels 2,3,4) 384 385 386# ---- the preprocessor ---- 387 388## default processing mode is 'true' 389#1 { 390# x 391# s/.*/1/ 392# x 393#} 394# 395## delete empty lines 396#/^[ ]*$/ d; 397# 398## look for "#if " 399#/^#if / { 400# /level.*$level/ { 401# x 402# s/^/1/ 403# x 404# b0 405# } 406# x 407# s/^/0/ 408# x 409# :0 410# d 411#} 412# 413## process "#else" 414#/^#else/ { 415# x 416# /^1/ { 417# s/1/0/ 418# b1 419# } 420# s/0/1/ 421# :1 422# x 423# d 424#} 425# 426## check for "#endif" 427#/^#endif/ { 428# x 429# s/.// 430# x 431# d 432#} 433# 434## delete comments 435#/^[ ]*#/ d 436# 437## process code lines according to #if/#else/#endif 438#x 439#/^1/ { 440# x 441# b 442#} 443#x 444#d 445