This is the mail archive of the cygwin-developers@sourceware.cygnus.com mailing list for the Cygwin project. See the Cygwin home page for more information.
Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

repost of "tiny winsup config patch"


Cygwin developers,

I've re-posting this patch because it fixes some annoying problems when 
you try to build winsup snapshots with incompatible version of newlib 
installed. Please consider it for inclusion. 

It solves two problems when building the utils:

- makes sure that the INCLUDES point to the current tree before looking
  at the installed copy which may be incompatible.

- never use LDFLAGS in a sub-Makefile. 

Winsup checks for newlib in the build tree, and if it's there, it always
adds the -B arg to EXE_LDFLAGS. My opinion however is unchanged from the 
last time we discussed this -- winsup should never be built without 
corresponding newlib in the same source tree and we should take measures 
to prevent it. That is, configure should balk if it can't find newlib in 
the build tree instead of just warning you.

Patch against ss-1999-04-27. Patches to auto-generated configure not added.

Thu Apr 29 11:06:37 1999  Mumit Khan  <khan@xraylith.wisc.edu>

	* configure.in (EXE_LDFLAGS): Always add newlib if part of the
	build tree.

	* utils/Makefile.in (INCLUDES): Add newlib include directories.
	(LDFLAGS): Replace this with
	(ALL_LDFLAGS): this to avoid being overridden from higher level 
	Makefiles.


--- configure.in.~1	Thu Apr 29 10:50:58 1999
+++ configure.in	Thu Apr 29 10:55:44 1999
@@ -140,26 +140,36 @@ dnl     program_transform_name="$program
 dnl   fi
 dnl fi
 
-dnl If CC can't create a .exe, which can happen when building from scratch
-dnl because crt0.o hasn't been installed yet, set up EXE_LDFLAGS to find
-dnl newlib.  Newlib is ../newlib when configure runs, but is ../../newlib
-dnl from the perspective of subdirectory makes.
+dnl
+dnl If newlib is part of build tree, always set EXE_LDFLAGS to point to
+dnl it; this is important in cases where the installed newlib is perhaps
+dnl not compatible. Check and warn for installed newlib only if it's not 
+dnl part of the build tree. 
+dnl
+
+AC_MSG_CHECKING([if newlib is part of the build tree])
 
-AC_MSG_CHECKING([if newlib needed])
 EXE_LDFLAGS=
-AC_TRY_LINK(,
-	[/* main already defined */]
-	,
-	AC_MSG_RESULT(no)
-	,
-	AC_MSG_RESULT(yes)
-	if test -d ../newlib
-	then
-		EXE_LDFLAGS="-B../../newlib/ -L.."
-	else
-		AC_MSG_WARN(newlib not found - utility .exe's may not link)
-	fi
-)
+if test -d ../newlib
+then
+  AC_MSG_RESULT(yes)
+  EXE_LDFLAGS="-B../../newlib/ -B../"
+else
+  AC_MSG_RESULT(no)
+fi
+ AC_SUBST(EXE_LDFLAGS)
+
+if test x"$EXE_LDFLAGS" = x
+then
+  AC_MSG_CHECKING([if installed newlib needed])
+  AC_TRY_LINK(,
+    [/* main already defined */]
+    ,
+    AC_MSG_RESULT(no)
+    ,
+    AC_MSG_RESULT(yes)
+    AC_MSG_WARN(newlib not found - utility .exe's may not link))
+fi
 AC_SUBST(EXE_LDFLAGS)
 
 case "$target_cpu" in
--- utils/Makefile.in.~1	Fri Jan 22 10:48:29 1999
+++ utils/Makefile.in	Thu Apr 29 10:57:27 1999
@@ -30,13 +30,15 @@ CC = @CC@
 CFLAGS = @CFLAGS@
 CXXFLAGS = @CXXFLAGS@
 
-INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../include
+INCLUDES = -I$(srcdir)/.. -I$(srcdir)/../include \
+	   -I$(srcdir)/../../newlib/libc/sys/cygwin \
+	   -I$(srcdir)/../../newlib/libc/include
 
 ALL_CFLAGS = $(CFLAGS) $(INCLUDES)
 ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES)
 
 # Passed in from ../Makefile.
-LDFLAGS:=$(EXE_LDFLAGS) ../libcygwin.a
+ALL_LDFLAGS = $(EXE_LDFLAGS) $(LDFLAGS) ../libcygwin.a
 
 PROGS = mount$(EXEEXT) umount$(EXEEXT) ps$(EXEEXT) kill$(EXEEXT) \
 	mkpasswd$(EXEEXT) mkgroup$(EXEEXT) cygpath$(EXEEXT) cygcheck$(EXEEXT) \
@@ -48,34 +50,34 @@ WINSUP_DEPS = $(srcdir)/../winsup.h
 all: $(PROGS)
 
 mount$(EXEEXT): mount.cc $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/mount.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/mount.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 umount$(EXEEXT): umount.cc $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/umount.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/umount.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 ps$(EXEEXT): ps.cc $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/ps.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/ps.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 kill$(EXEEXT): kill.cc  $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/kill.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/kill.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 cygwin$(EXEEXT): cygwin.cc $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/cygwin.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/cygwin.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 mkpasswd$(EXEEXT): mkpasswd.c $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/mkpasswd.c $(ALL_CXXFLAGS) $(LDFLAGS) -lnetapi32 -ladvapi32
+	$(CC) -o $@ $(srcdir)/mkpasswd.c $(ALL_CXXFLAGS) $(ALL_LDFLAGS) -lnetapi32 -ladvapi32
 
 mkgroup$(EXEEXT): mkgroup.c $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/mkgroup.c $(ALL_CXXFLAGS) $(LDFLAGS) -lnetapi32 -ladvapi32
+	$(CC) -o $@ $(srcdir)/mkgroup.c $(ALL_CXXFLAGS) $(ALL_LDFLAGS) -lnetapi32 -ladvapi32
 
 cygpath$(EXEEXT): cygpath.cc $(WINSUP_DEFS)
-	$(CC) -o $@ $(srcdir)/cygpath.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/cygpath.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 cygcheck$(EXEEXT): cygcheck.cc $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/cygcheck.cc $(ALL_CXXFLAGS) $(LDFLAGS)
+	$(CC) -o $@ $(srcdir)/cygcheck.cc $(ALL_CXXFLAGS) $(ALL_LDFLAGS)
 
 passwd$(EXEEXT): passwd.c $(WINSUP_DEPS)
-	$(CC) -o $@ $(srcdir)/passwd.c $(ALL_CXXFLAGS) $(LDFLAGS) -lnetapi32
+	$(CC) -o $@ $(srcdir)/passwd.c $(ALL_CXXFLAGS) $(ALL_LDFLAGS) -lnetapi32
 
 clean:
 	rm -f *.o $(PROGS)

Regards,
Mumit