Darren Tucker
2008-Jan-08 06:12 UTC
have configure generate header dependencies automatically
Hi all. While working on something I got bitten by a mismatch between .o files due to a changed struct. This is easily prevented. Building proper dependency information into the Makefiles would be major surgery and require ongoing maintenance (although some of that could be automated by parsing the .depend files generated on OpenBSD). This patch is basically the brute-force approach: it will cause a recompile everything in a given directory if any header file changes. It should have no effect on building the releases, only for folks who modify stuff. Can anyone see any possible downsides to this patch, other than unnecessary recompiles for people hacking the headers? Index: Makefile.in ==================================================================RCS file: /usr/local/src/security/openssh/cvs/openssh/Makefile.in,v retrieving revision 1.285 diff -u -p -r1.285 Makefile.in --- Makefile.in 11 Jun 2007 04:01:42 -0000 1.285 +++ Makefile.in 8 Jan 2008 05:36:33 -0000 @@ -56,6 +56,7 @@ ENT=@ENT@ XAUTH_PATH=@XAUTH_PATH@ LDFLAGS=-L. -Lopenbsd-compat/ @LDFLAGS@ EXEEXT=@EXEEXT@ +INCLUDES=@INCLUDES@ INSTALL_SSH_PRNG_CMDS=@INSTALL_SSH_PRNG_CMDS@ INSTALL_SSH_RAND_HELPER=@INSTALL_SSH_RAND_HELPER@ @@ -120,7 +121,7 @@ $(LIBSSH_OBJS): Makefile.in config.h $(SSHOBJS): Makefile.in config.h $(SSHDOBJS): Makefile.in config.h -.c.o: +.c.o: $(INCLUDES) $(CC) $(CFLAGS) $(CPPFLAGS) -c $< LIBCOMPAT=openbsd-compat/libopenbsd-compat.a Index: configure.ac ==================================================================RCS file: /usr/local/src/security/openssh/cvs/openssh/configure.ac,v retrieving revision 1.389 diff -u -p -r1.389 configure.ac --- configure.ac 2 Jan 2008 07:08:45 -0000 1.389 +++ configure.ac 8 Jan 2008 05:41:21 -0000 @@ -88,6 +88,12 @@ AC_SUBST(LD) AC_C_INLINE +INCLUDES="`echo $srcdir/*.h`" +AC_SUBST(INCLUDES, [$INCLUDES]) + +COMPAT_INCLUDES="`cd openbsd-compat && echo $srcdir/../openbsd-compat/*.h`" +AC_SUBST(COMPAT_INCLUDES, [$COMPAT_INCLUDES]) + AC_CHECK_DECL(LLONG_MAX, have_llong_max=1, , [#include <limits.h>]) if test "$GCC" = "yes" || test "$GCC" = "egcs"; then Index: openbsd-compat/Makefile.in ==================================================================RCS file: /usr/local/src/security/openssh/cvs/openssh_cvs/openbsd-compat/Makefile.in,v retrieving revision 1.41 diff -u -p -r1.41 Makefile.in --- openbsd-compat/Makefile.in 25 Jun 2007 12:15:13 -0000 1.41 +++ openbsd-compat/Makefile.in 8 Jan 2008 05:45:45 -0000 @@ -15,6 +15,7 @@ AR=@AR@ RANLIB=@RANLIB@ INSTALL=@INSTALL@ LDFLAGS=-L. @LDFLAGS@ +COMPAT_INCLUDES=@COMPAT_INCLUDES@ OPENBSD=base64.o basename.o bindresvport.o daemon.o dirname.o getcwd.o getgrouplist.o getopt.o getrrsetbyname.o glob.o inet_aton.o inet_ntoa.o inet_ntop.o mktemp.o readpassphrase.o realpath.o rresvport.o setenv.o setproctitle.o sha2.o sigact.o strlcat.o strlcpy.o strmode.o strsep.o strtonum.o strtoll.o strtoul.o vis.o @@ -22,14 +23,14 @@ COMPAT=bsd-arc4random.o bsd-asprintf.o b PORTS=port-aix.o port-irix.o port-linux.o port-solaris.o port-tun.o port-uw.o -.c.o: +.c.o: ../config.h $(COMPAT_INCLUDES) $(CC) $(CFLAGS) $(CPPFLAGS) -c $< all: libopenbsd-compat.a -$(COMPAT): ../config.h -$(OPENBSD): ../config.h -$(PORTS): ../config.h +$(COMPAT): ../config.h $(COMPAT_INCLUDES) +$(OPENBSD): ../config.h $(COMPAT_INCLUDES) +$(PORTS): ../config.h $(COMPAT_INCLUDES) libopenbsd-compat.a: $(COMPAT) $(OPENBSD) $(PORTS) $(AR) rv $@ $(COMPAT) $(OPENBSD) $(PORTS) -- Darren Tucker (dtucker at zip.com.au) GPG key 8FF4FA69 / D9A3 86E9 7EEE AF4B B2D4 37C9 C982 80C7 8FF4 FA69 Good judgement comes with experience. Unfortunately, the experience usually comes from bad judgement.
Corinna Vinschen
2008-Jan-09 09:01 UTC
have configure generate header dependencies automatically
On Jan 8 17:12, Darren Tucker wrote:> Hi all. > > While working on something I got bitten by a mismatch between .o files > due to a changed struct. This is easily prevented. > > Building proper dependency information into the Makefiles would be major > surgery and require ongoing maintenance (although some of that could be > automated by parsing the .depend files generated on OpenBSD).I don't know if that's helpful, but there's also the gcc -MMD option to create local dependencies per compilation unit. It's pretty easy to use in Makefiles. Corinna -- Corinna Vinschen Cygwin Project Co-Leader Red Hat
Roumen Petrov
2008-Jan-27 12:41 UTC
have configure generate header dependencies automatically
Hi Darren,> On Thu, Jan 10, 2008 at 09:11:18AM +1100, Darren Tucker wrote: > [...] >> That said, I think something like that (or mkdep from OpenBSD as >> mentioned in my original mail) would be OK as long as either the result >> is checked into CVS (not done at build time) or is an optional extra. >> >> The down side of this strategy is that the output of those types of >> tools is usually dependent on the compiler flags passed to the tool. >> Hence my "if all you have is a hammer, every problem looks like a nail" >> solution using configure :-) > > Here's one possible solution. It preprocesses the entire tree and > strips out everything except the #includes, processes the tree > with gcc -MM and stores the result. Because the #ifdefs have been > removed, the result is effectively the dependencies for every possible > configuration (all at once). > > At configure time, if the dependency info is available then it's > appended to the Makefile, otherwise it's a no-op. If we check the > depend files into CVS and make sure they're current when building > releases then I think it would work out. > > If anyone wants to try this (particularly with a non-gcc compiler > and vendor make) I have put up a snapshot with this change here: > http://www.zip.com.au/~dtucker/tmp/openssh-depend3.tar.gz > > Index: Makefile.in > ==================================================================> [SNIP]What about makedepend or ccmakedep command ? I think that dependency should be generated only if is requested. As example Makefile.in to end with: ====depend: (cd openbsd-compat && $(MAKE)) makedepend -- $(CFLAGS) -- $(srcdir)/*.c ==== If the commands above are not so good then I don't have objections depend-files to be distributed with source. In this case proposed by you shell script mkdepend.sh could be used to generate them before source packages to be created. I don't agree with changes in configure. The command config.status can recreate makefiles and dependency will lost. I attach file "bootstrap.sh" to show sample solution - macro AC_CONFIG_COMMANDS. Since the dependency is suitable mostly for developers I prefer solution based on new tag(in makefile{.in}) without dependency information to be distributed with source code. Regards, Roumen -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: bootstrap.sh Url: http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20080127/5e9165c9/attachment.ksh