File: adddebug

package info (click to toggle)
kde-dev-scripts 4%3A18.08.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 3,496 kB
  • sloc: perl: 15,466; lisp: 5,627; sh: 4,157; python: 3,892; ruby: 2,158; makefile: 16; sed: 9
file content (29 lines) | stat: -rwxr-xr-x 959 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/sh
# Modifies the Makefile in the current directory (and optionally its subdirs),
# - to add debug info (-g3)
# - optionally (default) remove optimizations (-O[1-9]?)
# - optionally remove -DNDEBUG and -DNO_DEBUG

# depth is 3 because flags.make is within CMakeFiles/foo.dir/
keep=
mxdp="-maxdepth 3"
ndebug=
for i in "$@"; do
  case $i in
    -k) keep=1;;
    -r) mxdp=;;
    -n) ndebug=1;;
    *) printf "Usage: adddebug [-k] [-r] [-n]\n  -k: keep optimizations (removed by default)\n  -r: recursive (process all subdirectories)\n  -n: compile without NDEBUG and NO_DEBUG being defined (makes kDebug calls work)\n"; exit 1;;
  esac
done

xpr='s/^((C|CXX|LD)_FLAGS[ \t]*=.*)$/\1 -g3/'
if test -z $keep; then
  xpr="$xpr;"'s/[\t ]-O[1-9]?\b//g'
  xpr="$xpr;"'s/[\t ]-march=\S+\b//g'
fi
if test -z $ndebug; then
  xpr="$xpr;"'s/[\t ]-DNDEBUG\b//g'
  xpr="$xpr;"'s/[\t ]-DNO_DEBUG\b//g'
fi
find . $mxdp -name flags.make -print0 | xargs -0 perl -i "$xpr"