Re: have configure generate header dependencies automatically

This is a discussion on Re: have configure generate header dependencies automatically within the OpenSSH Development forums, part of the Networking and Network Related category; On Thu, Jan 10, 2008 at 09:11:18AM +1100, Darren Tucker wrote: [...] > That said, I think something like ...


Go Back   Usenet Forums > Networking and Network Related > OpenSSH Development

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-12-2008
Darren Tucker
 
Posts: n/a
Default Re: have configure generate header dependencies automatically

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/o...depend3.tar.gz

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 12 Jan 2008 01:28:23 -0000
@@ -230,6 +230,7 @@ distprep: catman-do
$(AUTORECONF)
-rm -rf autom4te.cache
(cd scard && $(MAKE) -f Makefile.in distprep)
+ sh mkdepend.sh

install: $(CONFIGFILES) ssh_prng_cmds.out $(MANPAGES) $(TARGETS) install-files install-sysconf host-key check-config
install-nokeys: $(CONFIGFILES) ssh_prng_cmds.out $(MANPAGES) $(TARGETS) install-files install-sysconf
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 12 Jan 2008 01:30:01 -0000
@@ -4003,6 +4003,13 @@ AC_CONFIG_FILES([Makefile buildpkg.sh op
scard/Makefile ssh_prng_cmds survey.sh])
AC_OUTPUT

+for i in . openbsd-compat; do
+ dep="$srcdir/$i/depend"
+ if test -f "$dep"; then
+ cat $srcdir/$i/depend >>Makefile
+ fi
+done
+
# Print summary of options

# Someone please show me a better way :)
Index: mkdepend.sh
================================================== =================
RCS file: mkdepend.sh
diff -N mkdepend.sh
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mkdepend.sh 12 Jan 2008 01:29:32 -0000
@@ -0,0 +1,41 @@
+#!/bin/sh
+# $Id $
+# Author Darren Tucker 2008. Hereby placed in the public domain.
+#
+
+rm -rf .depend depend openbsd-compat/depend
+mkdir -p .depend/openbsd-compat
+touch .depend/config.h
+
+for i in *.c openbsd-compat/*.c; do
+ egrep '#.*include.*"' ${i} >.depend/${i}
+done
+
+#
+# Generate a stripped source tree containing all of the possible includes.
+# Protect headers against multiple includes to prevent loops.
+#
+for i in *.h openbsd-compat/*.h; do
+ echo "#ifndef ${i}" | tr .\\-/ ___ >.depend/${i}
+ echo "#define ${i}" | tr .\\-/ ___ >>.depend/${i}
+ egrep '#.*include.*"' ${i} >>.depend/${i}
+ echo "#endif" >>.depend/${i}
+done
+
+echo "# Machine generated output from mkdepend below. Do not edit." >depend
+cp depend openbsd-compat/depend
+
+d=`pwd`
+
+# process stripped tree to produce dependency files
+(cd ${d} && for i in *.c; do
+ gcc -I ${d} -I ${d}/openbsd-compat -MM ${i}
+ done) | perl -pe "s|${d}/||g" >>depend
+
+(cd ${d}/openbsd-compat && for i in *.c; do
+ gcc -I ${d} -I ${d}/openbsd-compat -MM ${i}
+done) \
+ | perl -pe "s|${d}/openbsd-compat/||g" \
+ | perl -pe "s|${d}/|../|g" >>openbsd-compat/depend
+
+rm -rf .depend

--
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.
_______________________________________________
openssh-unix-dev mailing list
openssh-unix-dev@mindrot.org
https://lists.mindrot.org/mailman/li...enssh-unix-dev
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 05:24 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0