From 855a9cb40ca734e1c99c3a1032630281d99572d1 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sat, 4 Jun 2011 21:36:36 -0700 Subject: Use autoconf instead of XORG_RAWCPP to substitute text in gccmakedep Signed-off-by: Alan Coopersmith Reviewed-by: Gaetan Nadon --- Makefile.am | 24 ++--------- configure.ac | 4 +- cpprules.in | 26 ------------ gccmakedep.in | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gccmdep.cpp | 130 ---------------------------------------------------------- 5 files changed, 135 insertions(+), 179 deletions(-) delete mode 100644 cpprules.in 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/cpprules.in b/cpprules.in deleted file mode 100644 index 09b7567..0000000 --- a/cpprules.in +++ /dev/null @@ -1,26 +0,0 @@ -# -*- Makefile -*- -# Rules for generating files using the C pre-processor -# (Replaces CppFileTarget from Imake) - -SED = sed - -SUFFIXES = .cpp - -WCHAR32_FLAGS = -DWCHAR32=@WCHAR32@ - -# Translate XCOMM into pound sign with sed, rather than passing -DXCOMM=XCOMM -# to cpp, because that trick does not work on all ANSI C preprocessors. -# Delete line numbers from the cpp output (-P is not portable, I guess). -# Allow XCOMM to be preceded by whitespace and provide a means of generating -# output lines with trailing backslashes. -# Allow XHASH to always be substituted, even in cases where XCOMM isn't. - -CPP_SED_MAGIC = $(SED) -e '/^\# *[0-9][0-9]* *.*$$/d' \ - -e '/^\#line *[0-9][0-9]* *.*$$/d' \ - -e '/^[ ]*XCOMM$$/s/XCOMM/\#/' \ - -e '/^[ ]*XCOMM[^a-zA-Z0-9_]/s/XCOMM/\#/' \ - -e '/^[ ]*XHASH/s/XHASH/\#/' \ - -e '/\@\@$$/s/\@\@$$/\\/' - -.cpp: - $(RAWCPP) $(RAWCPPFLAGS) $(CPP_FILES_FLAGS) < $< | $(CPP_SED_MAGIC) > $@ 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 +# + +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 -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 -- cgit v1.2.3