File: makedepend

package info (click to toggle)
eggdrop 1.6.18-1etch2
  • links: PTS
  • area: main
  • in suites: etch
  • size: 5,260 kB
  • ctags: 5,135
  • sloc: ansic: 55,311; sh: 4,101; tcl: 2,423; makefile: 1,505
file content (128 lines) | stat: -rwxr-xr-x 3,643 bytes parent folder | download | duplicates (2)
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#! /bin/sh
#
# makedepend - updates Makefile dependencies throughout the tree
#
# Copyright (C) 2004 - 2006 Eggheads Development Team
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
#
# $Id: makedepend,v 1.3 2006-03-28 02:35:49 wcc Exp $

show_usage() {
	echo "Usage: `basename $0` [-h|-f]"
	echo ""
	echo "  -h, --help      - Print this help and exit."
	echo "  -n, --nocleanup - Don't run 'make distclean' when finished."
	echo "  -f, --force     - Continue even if 'make depend' fails."
	exit 1
}

update_makefile() {
	if test ! -f ${1}/.depend; then
		echo "Warning: no .depend found in ${1}/; skipping."
	elif ! grep '#safety hash' >/dev/null 2>/dev/null ${1}/${2}; then
		echo "Warning: no '#safety hash' found in ${1}/${2}; skipping."
	else
		sed '/#safety hash/,$d' < ${1}/$2 > ${1}/${2}_
		echo "#safety hash" >> ${1}/${2}_
		cat ${1}/.depend >> ${1}/${2}_
		mv ${1}/${2}_ ${1}/${2}
		echo "Updated ${1}/${2}."
	fi
}

update_disabled() {
	cd ./src/mod/${1}.mod/ && make 'CC=gcc' \
	'CFLAGS = -I. -I../../.. -I../../../src/mod -DMAKING_DEPEND -DHAVE_CONFIG_H -DMAKING_MODS' depend
	if test ! $? = 0; then
		echo "Error: 'make depend' failed in ./src/mod/${1}.mod/." >&2
		echo "" >&2
		test $use_force = 1 || exit 1
	fi
	cd $CURRENT_PWD
}

if test ! -f src/main.c; then
	echo "You are not in the Eggdrop root directory."
	exit 1
fi

use_force=0
no_cleanup=0
for arg in $@; do
	if test "x${arg}" = "x-h" || test "x${arg}" = "x--help"; then
		show_usage
	fi
	if test "x${arg}" = "x-f" || test "x${arg}" = "x--force"; then
		use_force=1
	fi
	if test "x${arg}" = "x-n" || test "x${arg}" = "x--nocleanup"; then
		no_cleanup=1
	fi
done

echo ""
echo -n "Running 'make distclean'..."
make distclean >/dev/null 2>/dev/null
echo " done."
echo -n "Running configure..."
sh configure >/dev/null 2>/dev/null && make config >/dev/null 2>/dev/null
echo " done."

echo ""
echo "Running 'make depend'..."
echo ""
make depend
if test ! $? = 0; then
	echo "Error: 'make depend' failed." >&2
	echo "" >&2
	test $use_force = 1 || exit 1
fi

echo ""
echo "Running 'make depend' for disabled modules..."
echo ""
DISABLED_MODULES=$(cat disabled_modules | grep '^[a-z]')
CURRENT_PWD=$(pwd)
for i in ${DISABLED_MODULES}; do
	update_disabled $i
done

echo ""
echo "Updating Makefiles and Makefile.ins..."
echo ""
for i in $(find ./src/ -name "Makefile.in" -exec dirname '{}' ';' | grep -v '^\./src/mod$'); do
	update_makefile $i "Makefile.in"
done

for i in $(find ./src/ -name "Makefile" -exec dirname '{}' ';' | grep -v '^\./src/mod$'); do
	update_makefile $i "Makefile"
done

if test $no_cleanup = 0; then
	echo ""
	echo -n "Running 'make distclean'..."
	make distclean >/dev/null
	echo " done."
fi

echo ""
echo "Complete."
echo ""