[PATCH:gccmakedep] Use autoconf instead of XORG_RAWCPP to substitute text in gccmakedep

Alan Coopersmith alan.coopersmith at oracle.com
Sat Jun 4 21:50:10 PDT 2011


Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---

I don't know if anyone still uses/ships gccmakedep, but if so, this gets rid
of one more needless use of XORG_RAWCPP where simpler tools (in this case
autoconf itself) will do.

This depends on a series of configuration modernization patches I just pushed
to git master, to bring the configure.ac & Makefile.am in line with our 
current standards.

 Makefile.am   |   24 ++---------
 configure.ac  |    4 +-
 gccmakedep.in |  130 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 gccmdep.cpp   |  130 ---------------------------------------------------------
 4 files changed, 135 insertions(+), 153 deletions(-)
 create mode 100644 gccmakedep.in
 delete mode 100644 gccmdep.cpp

diff --git a/Makefile.am b/Makefile.am
index 3854465..3cb08f3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,23 +19,7 @@
 #  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 #  PERFORMANCE OF THIS SOFTWARE.
 
-gccmakedep_DATA = gccmakedep
-gccmakedepdir = $(bindir)
-
-include cpprules.in
-
-DEFS = \
-	-DCCCMD=$(CC)\
-	-DRMCMD='"rm -f"'\
-	-DLNCMD="ln"\
-	-DMVCMD="mv"
-
-CPP_FILES_FLAGS = $(DEFS)
-
-gccmakedep: gccmdep
-	cp gccmdep gccmakedep
-install-data-hook:
-	chmod +x $(DESTDIR)/$(bindir)/gccmakedep
+bin_SCRIPTS = gccmakedep
 
 appmandir = $(APP_MAN_DIR)
 
@@ -43,14 +27,14 @@ appman_PRE = gccmakedep.man
 
 appman_DATA = $(appman_PRE:man=@APP_MAN_SUFFIX@)
 
-CLEANFILES = $(appman_DATA) gccmakedep gccmdep
+CLEANFILES = $(appman_DATA)
 
-SUFFIXES += .$(APP_MAN_SUFFIX) .man
+SUFFIXES = .$(APP_MAN_SUFFIX) .man
 
 .man.$(APP_MAN_SUFFIX):
 	$(AM_V_GEN)$(SED) $(MAN_SUBSTS) < $< > $@
 
-EXTRA_DIST = $(appman_PRE) gccmdep.cpp
+EXTRA_DIST = $(appman_PRE)
 
 MAINTAINERCLEANFILES = ChangeLog
 
diff --git a/configure.ac b/configure.ac
index 1ad21cd..b79b64d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -37,7 +37,5 @@ m4_ifndef([XORG_MACROS_VERSION],
 XORG_MACROS_VERSION(1.8)
 XORG_DEFAULT_OPTIONS
 
-XORG_PROG_RAWCPP
-
-AC_CONFIG_FILES([Makefile])
+AC_CONFIG_FILES([Makefile gccmakedep])
 AC_OUTPUT
diff --git a/gccmakedep.in b/gccmakedep.in
new file mode 100644
index 0000000..860d102
--- /dev/null
+++ b/gccmakedep.in
@@ -0,0 +1,130 @@
+#!/bin/sh
+
+#
+# makedepend which uses 'gcc -M'
+#
+# $XFree86: xc/config/util/gccmdep.cpp,v 3.10tsi Exp $
+#
+# Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl at nynexst.com>
+#
+
+TMP=mdep$$.tmp
+CC="@CC@"
+RM="rm -f"
+LN="ln"
+MV="mv"
+
+${RM} ${TMP}
+
+trap "${RM} ${TMP}*; exit 1" 1 2 15
+trap "${RM} ${TMP}*; exit 0" 1 2 13
+
+files=
+makefile=
+endmarker=
+magic_string='# DO NOT DELETE'
+append=n
+args=
+
+while [ $# != 0 ]; do
+    if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
+	endmarker=
+    else
+	case "$1" in
+	    -D*|-I*|-U*)
+# arg may contain single quotes
+		qarg=`echo "$1" | sed "s/'/'\\\\\\\\''/g"`
+                args="$args '$qarg'"
+		;;
+	    -g*|-O*)
+		;;
+	    *)
+		if [ "$endmarker"x = x ]; then
+		    case $1 in
+# ignore these flags
+			-w|-o|-cc)
+			    shift
+			    ;;
+			-v)
+			    ;;
+			-s)
+			    magic_string="$2"
+			    shift
+			    ;;
+			-f*)
+			    if [ "$1" = "-f-" ]; then
+				makefile="-"
+			    elif [ "$1" = "-f" ]; then
+				makefile="$2"
+				shift
+			    else
+				echo "$1" | sed 's/^\-f//' >${TMP}arg
+				makefile="`cat ${TMP}arg`"
+				rm -f ${TMP}arg
+			    fi
+			    ;;
+			--*)
+			    endmarker=`echo $1 | sed 's/^\-\-//'`
+			    if [ "$endmarker"x = x ]; then
+				endmarker="--"
+			    fi
+			    ;;
+			-a)
+			    append=y
+			    ;;
+			-*)
+			    echo "Unknown option '$1' ignored" 1>&2
+			    ;;
+			*)
+# filename may contain blanks
+			    files="$files '$1'"
+			    ;;
+		    esac
+		fi
+		;;
+	esac
+    fi
+    shift
+done
+
+if [ x"$files" = x ]; then
+# Nothing to do
+    exit 0
+fi
+
+case "$makefile" in
+    '')
+	if [ -r makefile ]; then
+	    makefile=makefile
+	elif [ -r Makefile ]; then
+	    makefile=Makefile
+	else
+	    echo 'no makefile or Makefile found' 1>&2
+	    exit 1
+	fi
+	;;
+esac
+
+if [ X"$makefile" != X- ]; then
+    if [ x"$append" = xn ]; then
+        sed -e "/^$magic_string/,\$d" < $makefile > $TMP
+        echo "$magic_string" >> $TMP
+    else
+        cp $makefile $TMP
+    fi
+fi
+
+CMD="$CC -M $args $files"
+if [ X"$makefile" != X- ]; then
+    CMD="$CMD >> $TMP"
+fi
+# Do not wildcard expand '*' in args
+eval "$CMD"
+if [ X"$makefile" != X- ]; then
+    $RM ${makefile}.bak
+    $MV $makefile ${makefile}.bak
+    $MV $TMP $makefile
+fi
+
+$RM ${TMP}*
+exit 0
diff --git a/gccmdep.cpp b/gccmdep.cpp
deleted file mode 100644
index abab70d..0000000
--- a/gccmdep.cpp
+++ /dev/null
@@ -1,130 +0,0 @@
-XCOMM!/bin/sh
-
-XCOMM
-XCOMM makedepend which uses 'gcc -M'
-XCOMM
-XCOMM $XFree86: xc/config/util/gccmdep.cpp,v 3.10tsi Exp $
-XCOMM
-XCOMM Based on mdepend.cpp and code supplied by Hongjiu Lu <hjl at nynexst.com>
-XCOMM
-
-TMP=mdep$$.tmp
-CC=CCCMD
-RM=RMCMD
-LN=LNCMD
-MV=MVCMD
-
-${RM} ${TMP}
-
-trap "${RM} ${TMP}*; exit 1" 1 2 15
-trap "${RM} ${TMP}*; exit 0" 1 2 13
-
-files=
-makefile=
-endmarker=
-magic_string='# DO NOT DELETE'
-append=n
-args=
-
-while [ $# != 0 ]; do
-    if [ "$endmarker"x != x -a "$endmarker" = "$1" ]; then
-	endmarker=
-    else
-	case "$1" in
-	    -D*|-I*|-U*)
-XCOMM arg may contain single quotes
-		qarg=`echo "$1" | sed "s/'/'\\\\\\\\''/g"`
-                args="$args '$qarg'"
-		;;
-	    -g*|-O*)
-		;;
-	    *)
-		if [ "$endmarker"x = x ]; then
-		    case $1 in
-XCOMM ignore these flags
-			-w|-o|-cc)
-			    shift
-			    ;;
-			-v)
-			    ;;
-			-s)
-			    magic_string="$2"
-			    shift
-			    ;;
-			-f*)
-			    if [ "$1" = "-f-" ]; then
-				makefile="-"
-			    elif [ "$1" = "-f" ]; then
-				makefile="$2"
-				shift
-			    else
-				echo "$1" | sed 's/^\-f//' >${TMP}arg
-				makefile="`cat ${TMP}arg`"
-				rm -f ${TMP}arg
-			    fi
-			    ;;
-			--*)
-			    endmarker=`echo $1 | sed 's/^\-\-//'`
-			    if [ "$endmarker"x = x ]; then
-				endmarker="--"
-			    fi
-			    ;;
-			-a)
-			    append=y
-			    ;;
-			-*)
-			    echo "Unknown option '$1' ignored" 1>&2
-			    ;;
-			*)
-XCOMM filename may contain blanks
-			    files="$files '$1'"
-			    ;;
-		    esac
-		fi
-		;;
-	esac
-    fi
-    shift
-done
-
-if [ x"$files" = x ]; then
-XCOMM Nothing to do
-    exit 0
-fi
-
-case "$makefile" in
-    '')
-	if [ -r makefile ]; then
-	    makefile=makefile
-	elif [ -r Makefile ]; then
-	    makefile=Makefile
-	else
-	    echo 'no makefile or Makefile found' 1>&2
-	    exit 1
-	fi
-	;;
-esac
-
-if [ X"$makefile" != X- ]; then
-    if [ x"$append" = xn ]; then
-        sed -e "/^$magic_string/,\$d" < $makefile > $TMP
-        echo "$magic_string" >> $TMP
-    else
-        cp $makefile $TMP
-    fi
-fi
-
-CMD="$CC -M $args $files"
-if [ X"$makefile" != X- ]; then
-    CMD="$CMD >> $TMP"
-fi
-XCOMM Do not wildcard expand '*' in args
-eval "$CMD"
-if [ X"$makefile" != X- ]; then
-    $RM ${makefile}.bak
-    $MV $makefile ${makefile}.bak
-    $MV $TMP $makefile
-fi
-
-$RM ${TMP}*
-exit 0
-- 
1.7.3.2



More information about the xorg-devel mailing list