[patch] reorganize utils/Makefile.in

2008-03-08 Thread Brian Dessent

This patch is a revamping of the Makefile in winsup/utils.  The current
Makefile.in is fugly, in my humble opinion.  It's got lots of repeated
rules and it's not very clear how one is supposed to add or change
things.  This patch does use GNU make specific features, but I'm quite
sure we already use them in other places, e.g. $(wildcard ...),
$(patsubst ...), $(shell ...) etc. are all GNU make features AFAIK and
those are all over the place in winsup.

I've also attached a copy of the patched Makefile.in if it's easier to
review that way; the diff is quite ugly.  As you can see the total
number of lines in the file is decreased by about 70, and that's
including a number of comments that I have added to document how to use
the file.

I have tried fairly hard to make sure that no actual behavior has
changed.  I diffed a before and after run and the only real difference
seemed to be the order that things ran, as well as a couple of flags
moved to a different spot in their commands.  I also tested the case
where libbfd.a/libintl.a are absent, causing the dumper parts to be
skipped as well as missing a MinGW zlib for cygcheck.  I haven't tested
a crosscompile but I can if that's necessary.  I have tested builds in
both a combined tree as well as just winsup.

Brian2008-03-08  Brian Dessent  [EMAIL PROTECTED]

* Makefile.in: Reorganize considerably, using GNU make's
static pattern rules and target-specific variables.

 Makefile.in |  229 +---
 1 file changed, 81 insertions(+), 148 deletions(-)

Index: Makefile.in
===
RCS file: /cvs/src/src/winsup/utils/Makefile.in,v
retrieving revision 1.68
diff -u -p -r1.68 Makefile.in
--- Makefile.in 21 Dec 2007 03:32:46 -  1.68
+++ Makefile.in 8 Mar 2008 13:57:57 -
@@ -1,6 +1,6 @@
 # Makefile for Cygwin utilities
 # Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
-# 2005, 2006, 2007 Red Hat, Inc.
+# 2005, 2006, 2007, 2008 Red Hat, Inc.
 
 # This file is part of Cygwin.
 
@@ -36,161 +36,115 @@ override CXXFLAGS+=-fno-exceptions -fno-
 
 include $(srcdir)/../Makefile.common
 
-LIBICONV:[EMAIL PROTECTED]@
-libbfd:=${shell $(CC) -B$(bupdir2)/bfd/ --print-file-name=libbfd.a}
-libintl:=${shell $(CC) -B$(bupdir2)/intl/ --print-file-name=libintl.a}
-build_dumper:=${shell test -r $(libbfd) -a -r $(libintl) -a -n $(LIBICONV) 
 echo 1}
-
-libz:=${shell x=$$($(CC) -mno-cygwin --print-file-name=libz.a); cd $$(dirname 
$$x); dir=$$(pwd); case $$dir in *mingw*) echo $$dir/libz.a ;; esac}
-zlib_h:=-include ${patsubst %/lib/mingw/libz.a,%/include/zlib.h,${patsubst 
%/lib/libz.a,%/include/zlib.h,$(libz)}}
-zconf_h:=${patsubst %/zlib.h,%/zconf.h,$(zlib_h)}
-ifeq ${libz} 
-zlib_h:=
-zconf_h:=
-libz:=
-endif
-
-DUMPER_INCLUDES:=-I$(bupdir2)/bfd -I$(updir1)/include
-
-libcygwin:=$(cygwin_build)/libcygwin.a
-libuser32:=$(w32api_lib)/libuser32.a
-libkernel32:=$(w32api_lib)/libkernel32.a
-ALL_DEP_LDLIBS:=$(libcygwin) $(w32api_lib)/libnetapi32.a \
-   $(w32api_lib)/libadvapi32.a $(w32api_lib)/libkernel32.a \
-   $(w32api_lib)/libuser32.a
-
-ALL_LDLIBS:=${patsubst $(w32api_lib)/lib%.a,-l%,\
- ${filter-out $(libuser32),\
-  ${filter-out $(libkernel32),\
-   ${filter-out $(libcygwin), $(ALL_DEP_LDLIBS)
-
-MINGW_LIB:=$(mingw_build)/libmingw32.a
-DUMPER_LIB:=${libbfd} ${libintl} -L$(bupdir1)/libiberty $(LIBICONV) -liberty
-MINGW_LDLIBS:=${filter-out $(libcygwin),$(ALL_LDLIBS) $(MINGW_LIB)}
-MINGW_DEP_LDLIBS:=${ALL_DEP_LDLIBS} ${MINGW_LIB}
-ALL_LDFLAGS:=-B$(newlib_build)/libc -B$(w32api_lib) $(LDFLAGS) $(ALL_LDLIBS)
-DUMPER_LDFLAGS:=$(ALL_LDFLAGS) $(DUMPER_LIB)
-MINGW_CXX:=${patsubst %/cygwin/include,%/mingw/include,${filter-out 
-I$(newlib_source)/%,$(COMPILE_CXX)}} -I$(updir)
-
-PROGS:=cygcheck.exe cygpath.exe getfacl.exe kill.exe mkgroup.exe \
-   mkpasswd.exe mount.exe passwd.exe ps.exe regtool.exe setfacl.exe \
-   setmetamode.exe ssp.exe strace.exe umount.exe ipcrm.exe ipcs.exe
-
-CLEAN_PROGS:=$(PROGS)
-ifndef build_dumper
-PROGS:=warn_dumper $(PROGS)
-else
-PROGS+=dumper$(EXEEXT)
-CLEAN_PROGS+=dumper.exe
-endif
-
 .SUFFIXES:
 .NOEXPORT:
+.PHONY: all install clean realclean warn_dumper warn_cygcheck_zlib
 
-.PHONY: all install clean realclean warn_dumper
-
-all: Makefile $(PROGS)
-
-strace.exe: strace.o path.o $(MINGW_DEP_LDLIBS)
-ifdef VERBOSE
-   $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,2,$^} -B$(mingw_build)/ 
$(MINGW_LDFLAGS)
-else
-   @echo $(CXX) -o $@ ${wordlist 1,2,$^} ${filter-out -B%, 
$(MINGW_CXXFLAGS) $(MINGW_LDFLAGS)};\
-   $(CXX) $(MINGW_CXXFLAGS) -o $@ ${wordlist 1,2,$^} -B$(mingw_build)/ 
$(MINGW_LDFLAGS)
-endif
-
-cygcheck.exe: cygcheck.o bloda.o path.o dump_setup.o $(MINGW_DEP_LDLIBS)
-ifeq $(libz) 
-   @echo '*** Building cygcheck without package content checking due to 
missing mingw libz.a.'
-endif
-ifdef VERBOSE
-   

Re: [patch] reorganize utils/Makefile.in

2008-03-08 Thread Christopher Faylor
On Sat, Mar 08, 2008 at 07:28:52AM -0800, Brian Dessent wrote:
2008-03-08  Brian Dessent  [EMAIL PROTECTED]

   * Makefile.in: Reorganize considerably, using GNU make's
   static pattern rules and target-specific variables.

Looks good.  Please check in.

Thanks.

cgf