File: cheatmake

package info (click to toggle)
kdesdk 4%3A3.3.2-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 27,520 kB
  • ctags: 18,649
  • sloc: cpp: 169,063; sh: 10,505; perl: 8,303; lisp: 6,329; makefile: 1,734; ansic: 1,626; python: 653; xml: 212; lex: 62; ruby: 46
file content (59 lines) | stat: -rwxr-xr-x 1,648 bytes parent folder | download
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
# Helper for saving time when recompiling, skipping files that haven't
# changed in a meaningful way (e.g. if you only change a comment...)
#
# LGPL v2, David Faure <david@mandrakesoft.com>

usage()
{
  echo "Usage:"
  echo " $0 hidechange file    Hides the fact that file was changed (use with care!)"
  echo " $0 show               Lists what make currently has to rebuild"
  echo " $0 why file           Explains why make must rebuild file"
  exit 1;
}

if [ $# -eq 0 ]; then usage; fi
CDPATH=
builddir=$PWD

# 'srcdir != builddir' stuff
if test ! -f Makefile && test -n "$OBJ_SUBDIR"; then
  builddir=$OBJ_SUBDIR
else
  if test ! -f Makefile && test -n "$OBJ_REPLACEMENT"; then
     builddir=`pwd | sed -e "$OBJ_REPLACEMENT"`
  fi
fi

if test ! -f Makefile && test -n "$OBJ_SUBDIR"; then
   builddir=$OBJ_SUBDIR
fi
cd $builddir
srcdir=`egrep '^srcdir *=' Makefile | sed -e "s#srcdir *= *##"`

case $1 in
  hidechange )
    if [ $# -ne 2 ]; then usage; fi
    deps=`make SUBDIRS='' -n | grep '\-o' | sed -e 's/.*-o \([^ ]*\).*/\1/'`;
    if [ -n "$deps" ]; then
      oldestdep=`ls -t $deps 2>/dev/null | tail -1`
      thefile=$2
      if [ -f $srcdir/$thefile ]; then
          thefile=$srcdir/$thefile
      fi
      echo
      echo "Setting date of $thefile back in time with:"
      echo "touch -r $oldestdep $thefile" ; touch -r $oldestdep $thefile
    fi
    ;;
  show )
    if [ $# -ne 1 ]; then usage; fi
    make SUBDIRS='' -n | grep '\-o' | sed -e 's/.*-o \([^ ]*\).*/\1/'
    ;;
  why )
    if [ $# -ne 2 ]; then usage; fi
    make SUBDIRS='' -n -d $2 | egrep -e "(newer than target \`$2'|Must)"
    ;;
  * ) usage ;;
esac