3.0alpha24: make bug (or more...)

David Lee t.d.lee at durham.ac.uk
Thu May 15 19:40:54 GMT 2003


On Thu, 15 May 2003, David Lee wrote:

> I grabbed 3.0alpha24 this morning and began to build it, and quickly hit a
> bug.  (Our platform is Sun/Solaris8 but the bug is a general one.)  I
> logged a patch (bugzilla 83), but it looks as though one bug leads to
> another and so on...
>
> The problem (or connected string of them) probably won't affect a simple
> "builddir == srcdir" configuration.
>
>
> But for those sites (e.g. with multiple architectures) which use multiple
> "builddir", separate from each other and from "srcdir", the start of this
> potentially long string is immediately evident.
>
> [...]
> For the curious:
>
>   cd source
>   mkdir builddir_1
>   cd builddir_1
>   ../configure  <... your favourite --options>
>   make
>
>
> The "make" will fail, unable to write "smbd/build_options.c" because
> directory "builddir_1/smbd" does not exist.  That is easily fixed by the
> one-line patch in bugzilla 83.
>
>
> But then the fun starts, and the string seems to get longer, as it cannot
> completely build "include/proto.h".  (And I think there is a philosophical
> mistake in its trying to build it in "$(srcdir)": it ought to be in
> "$(builddir)".  Etc.)

Further to my message above.

At the time I sent it, I had already done some work, but it had seemed
that each step forward revealed two or more further steps that would need
to be taken.  At the time, it was looking increasingly worrying.

Anyway.  I think I've fixed it, and (I hope) done so reasonably cleanly.

To re-iterate:  The problem almost certainly only affects sites where
"builddir != srcdir".  (If your site has them equal, then you may
reasonably be wondering what the fuss is about!)

Four files are affected:
   Makefile.in
   script/mkproto.sh
   configure.in
   nsswitch/winbindd.h

The trigger is that "proto.h" doesn't build under these circumstances
("builddir != srcdir"), because it needs to reference the new (at alpha24)
"smbd/build_options.c" file.  Quite rightly, this is built in $(builddir).
But it (a ".c") file is now in with ".o" files and so is isolated from the
other ".c" sources.

The first part of the solution is to rework Makefile.in's calling of
script/mkproto.sh and the latter's internal detail.  Hitherto Makefile.in
had invoked script/mkproto.sh with a mixture of mostly ".o" but the
occasional ".c" (the new "smbd/build_options.c").  mkproto.sh had then
simply translated ".o" suffixes to ".c" and prepended with "$(srcdir)".
But that was incorrect for the unusually (but correctly) placed
"smbd/build_options.c".

So I have tidied that up.  Those name transformations are now done within
the Makefile, which knows this idiosyncracy.  Its call of script/mkproto.sh
is now with the ".c" files and their correct locations: usually $(srcdir),
but in the case of "smbd/build_options.c", this is $(builddir).

Also, within Makefile.in I had to separate out "smbd/build_options"
references because of the its ".c" file's "special case" location.

Another problem of Makefile's invocation of "mkproto.sh" was that it was
putting the output files relative to $(srcdir): the wrong place, which
could potentially break multiple builds.

So I have now arranged for it to be run in the context of, and placing its
output relative to, $(builddir) instead.  The rest of the Makefile's
(correct) use of $(srcdir) and $(builddir) makes this correction
transparent.

A side-effect within "mkproto.sh" of its now being in the $(builddir)
context is that the location of "mkproto.awk", a $(srcdir) item, now needs
explicitly stating within it.  But this varies according to the relative
positioning of $(srcdir) and $(builddir).

Accordingly, "mkproto.sh" is renamed to "mkproto.sh.in" and a
corresponding one line change applied in "configure.in".

Basically this then built, although it did expose one weakness in one
compilation, trivially fixed by redefining an "include" with
"nsswitch/winbindd.h".


I attach four "diff -u".

1. Makefile.in
2. scripts/mkproto.sh :  Note that this should be renamed to a ".in"
3. configure.in (to account for rename of "scripts/mkproto.sh")
4. nsswitch/winbindd.h


Phew!!



-- 

:  David Lee                                I.T. Service          :
:  Systems Programmer                       Computer Centre       :
:                                           University of Durham  :
:  http://www.dur.ac.uk/t.d.lee/            South Road            :
:                                           Durham                :
:  Phone: +44 191 334 2752                  U.K.                  :
-------------- next part --------------
--- Makefile.in-	Thu May 15 10:40:13 2003
+++ Makefile.in	Thu May 15 17:52:43 2003
@@ -318,6 +318,8 @@
 
 SMBD_OBJ_MAIN = smbd/server.o
 
+BUILDOPT_OBJ = smbd/build_options.o
+
 SMBD_OBJ_SRV = smbd/files.o smbd/chgpasswd.o smbd/connection.o \
 	       smbd/utmp.o smbd/session.o \
                smbd/dfree.o smbd/dir.o smbd/password.o smbd/conn.o smbd/fileio.o \
@@ -330,12 +332,12 @@
                smbd/posix_acls.o lib/sysacls.o lib/server_mutex.o \
 	       smbd/process.o smbd/service.o smbd/error.o \
 	       printing/printfsp.o lib/util_seaccess.o \
-               smbd/build_options.o lib/sysquotas.o \
+               lib/sysquotas.o \
 	       smbd/change_trust_pw.o smbd/fake_file.o \
 	       smbd/quotas.o smbd/ntquotas.o \
 	       $(MANGLE_OBJ) @VFS_STATIC@
 
-SMBD_OBJ_BASE = $(PARAM_OBJ) $(SMBD_OBJ_SRV) $(MSDFS_OBJ) $(LIBSMB_OBJ) \
+SMBD_OBJ_BASE = $(PARAM_OBJ) $(SMBD_OBJ_SRV) $(BUILDOPT_OBJ) $(MSDFS_OBJ) $(LIBSMB_OBJ) \
 		$(RPC_SERVER_OBJ) $(RPC_PARSE_OBJ) $(SECRETS_OBJ) $(UBIQX_OBJ) \
 		$(LOCKING_OBJ) $(PASSDB_OBJ) $(PRINTING_OBJ) $(PROFILE_OBJ) \
 		$(LIB_OBJ) $(PRINTBACKEND_OBJ) $(OPLOCK_OBJ) \
@@ -608,6 +610,9 @@
 
 NTLM_AUTH_OBJ = utils/ntlm_auth.o $(LIBSAMBA_OBJ) $(POPT_LIB_OBJ)
 
+# Location of mkproto.sh
+MKPROTO_SH = $(builddir)/script/mkproto.sh
+
 ######################################################################
 # now the rules...
 ######################################################################
@@ -1250,39 +1255,45 @@
 
 include/proto.h: smbd/build_options.c
 	@echo Building include/proto.h
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
 	  -h _PROTO_H_ $(builddir)/include/proto.h \
-	  $(PROTO_OBJ)
+	  `echo $(PROTO_OBJ) $(builddir)/smbd/build_options.c | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 include/build_env.h: script/build_env.sh
 	@echo Building include/build_env.h
-	@cd $(srcdir) && $(SHELL) script/build_env.sh $(srcdir) $(builddir) $(CC) > $(builddir)/include/build_env.h
+	@$(SHELL) $(srcdir)/script/build_env.sh $(srcdir) $(builddir) $(CC) > $(builddir)/include/build_env.h
 
 include/wrepld_proto.h:
 	@echo Building include/wrepld_proto.h
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
 	  -h _WREPLD_PROTO_H_ $(builddir)/include/wrepld_proto.h \
-	  $(WREPL_OBJ1)
+	  `echo $(WREPL_OBJ1) | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 nsswitch/winbindd_proto.h: 
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
-	  -h _WINBINDD_PROTO_H_ nsswitch/winbindd_proto.h \
-	  $(WINBINDD_OBJ1)
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
+	  -h _WINBINDD_PROTO_H_ $(builddir)/nsswitch/winbindd_proto.h \
+	  `echo $(WINBINDD_OBJ1) | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 web/swat_proto.h: 
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
-	  -h _SWAT_PROTO_H_ web/swat_proto.h \
-	  $(SWAT_OBJ1)
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
+	  -h _SWAT_PROTO_H_ $(builddir)/web/swat_proto.h \
+	  `echo $(SWAT_OBJ1) | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 client/client_proto.h: 
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
-	  -h _CLIENT_PROTO_H_ client/client_proto.h \
-	  $(CLIENT_OBJ1)
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
+	  -h _CLIENT_PROTO_H_ $(builddir)/client/client_proto.h \
+	  `echo $(CLIENT_OBJ1) | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 utils/net_proto.h: 
-	@cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \
-	  -h _CLIENT_PROTO_H_ utils/net_proto.h \
-	  $(NET_OBJ1)
+	@$(SHELL) $(MKPROTO_SH) $(AWK) \
+	  -h _CLIENT_PROTO_H_ $(builddir)/utils/net_proto.h \
+	  `echo $(NET_OBJ1) | tr ' ' '\n' \
+	    | sed -e 's/^\(.*\)\.o/$(srcdir)\/\1\.c/g'`
 
 # "make headers" or "make proto" calls a subshell because we need to
 # make sure these commands are executed in sequence even for a
-------------- next part --------------
--- script/mkproto.sh.orig	Mon Jul 29 13:51:31 2002
+++ script/mkproto.sh.in	Thu May 15 18:50:41 2003
@@ -4,6 +4,10 @@
 LC_ALL=C; export LC_ALL
 LC_COLLATE=C; export LC_COLLATE
 
+# Need reference point for "mkproto.awk", including when "srcdir != builddir".
+# Use of "abs_..." is unpleasant.  Is there another way?
+abs_srcdir=@abs_srcdir@
+
 if [ $# -lt 3 ]
 then
   echo "Usage: $0 awk [-h headerdefine] outputheader proto_obj"
@@ -25,14 +29,14 @@
 shift
 headertmp="$header.$$.tmp~"
 
-proto_src="`echo $@ | tr ' ' '\n' | sed -e 's/\.o/\.c/g' | sort | uniq | egrep -v 'ubiqx/|wrapped'`"
+proto_src="`echo $@ | tr ' ' '\n' | sort | uniq | egrep -v 'ubiqx/|wrapped'`"
 
 echo creating $header
 
 mkdir -p `dirname $header`
 
 ${awk} $headeropt \
-  -f script/mkproto.awk $proto_src > $headertmp
+  -f $abs_srcdir/mkproto.awk $proto_src > $headertmp
 
 if cmp -s $header $headertmp 2>/dev/null
 then
-------------- next part --------------
--- configure.in.orig	Wed May 14 19:56:18 2003
+++ configure.in	Thu May 15 18:09:17 2003
@@ -3757,7 +3757,7 @@
 CFLAGS_REMOVE_USR_INCLUDE(CFLAGS)
 CFLAGS_REMOVE_USR_INCLUDE(CPPFLAGS)
 
-AC_OUTPUT(include/stamp-h Makefile script/findsmb)
+AC_OUTPUT(include/stamp-h Makefile script/findsmb script/mkproto.sh)
 
 #################################################
 # Print very concise instructions on building/use
-------------- next part --------------
--- nsswitch/winbindd.h.orig	Wed May 14 19:56:26 2003
+++ nsswitch/winbindd.h	Thu May 15 19:28:04 2003
@@ -219,7 +219,7 @@
   void (*status)(void);
 };
 
-#include "winbindd_proto.h"
+#include "../nsswitch/winbindd_proto.h"
 
 #include "rpc_parse.h"
 #include "rpc_client.h"


More information about the samba-technical mailing list