File: create_makefile

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 (100 lines) | stat: -rwxr-xr-x 2,690 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/sh

# Create Makefile.in and Makefile in a directory (containing a Makefile.am !)
# Saves time compared to re-running configure completely

if [ $# -ne 1 ]; then 
  echo "$0 : creates a Makefile from a Makefile.am"
  echo
  echo "Usage : $0 relativepath/Makefile"
  echo "So the argument is the file you want to create."
  echo
else
  srcdir=
  if test -f config.status && test -f configure; then
	srcdir=.
  else
    if test ! -f Makefile && test -n "$OBJ_SUBDIR"; then
      cd $OBJ_SUBDIR
    else
      if test ! -f Makefile && test -n "$OBJ_REPLACEMENT"; then
         objdir=`pwd | sed -e "$OBJ_REPLACEMENT"`
         cd $objdir
      fi
    fi

    if test ! -f Makefile && test -n "$OBJ_SUBDIR"; then
       cd $OBJ_SUBDIR
    fi

    if test ! -f Makefile; then 
      echo "$0: in the current directory there is no Makefile"
      echo "you will have to run it from the top build dir."
      echo "if you do not have a Makefile there - rerun configure"
      exit
    fi

  fi

  # Handle arg with missing "/Makefile"
  relpath=$1
  if test -n "`echo $relpath | grep \/$`"; then
    relpath=`echo $relpath | sed 's/\/$//'`
  fi
  if test -z "`echo $relpath | grep 'Makefile$'`"; then 
    relpath="$relpath/Makefile"
  fi

  # Strip leading ./, otherwise config.status chokes
  relpath=`echo "$relpath" | sed -e 's,^\./,,'`

  # Go up to toplevel dir
  while test ! -f config.status; do
    relpath="`basename $PWD`/$relpath"
    cd ..
  done

  # Find out srcdir
  srcdir=`egrep '^srcdir *=' Makefile | sed -e "s#srcdir *= *##"`

  (  
    if cd $srcdir ; then
     # Check if unsermake or automake was used to create the toplevel Makefile.in
     # (the one in $relpath might not exist yet)
     if test -n "`sed -n -e '1p' Makefile.in | grep unsermake`"; then
       if test -z "$UNSERMAKE"; then
         echo "unsermake was used to build this module, but \$UNSERMAKE isn't set!"
	 exit 1
       fi
       $UNSERMAKE $relpath
       exit 2
     else
       # Suck in AUTOCONF/AUTOMAKE detection code
       . admin/detect-autoconf.sh
       /bin/sh admin/missing --run $AUTOMAKE $relpath || exit
       if test -f admin/am_edit; then perl admin/am_edit $relpath.in ;\
       else 
         if test -f ../admin/am_edit; then perl ../admin/am_edit $relpath.in ; \
         fi
       fi
     fi
    fi
  )
  case $? in
    1)
      exit 1
      ;;
    2)
      createrulesfile="true"
      ;;
    *)
      ;;
  esac
  if test -f `dirname $relpath`; then 
	rm `dirname $relpath`
  fi
  CONFIG_FILES=$relpath CONFIG_HEADERS= ./config.status
  if test "$createrulesfile" = "true"; then
    CONFIG_FILES="$relpath.rules $relpath.calls" CONFIG_HEADERS= ./config.status
  fi
fi