Attached is a patch to automatically generate smbd/build_options.c from the contents of include/config.h.in . I'm really not too sure about how the stuff I've done to the Makefile - could someone who understands Makefiles better than me take a look and comment? And of course, comments on the awk too!
I was also a little unsure about what the output should look like, so I've included all three of my ideas. 1) Just the define: Build Options: COMPILER_SUPPORTS_LL LDAP_SET_REBIND_PROC_ARGS 2) The define and the comment on different lines: Build Options: /* Whether the compiler supports the LL prefix on long long integers */ COMPILER_SUPPORTS_LL /* Number of arguments to ldap_set_rebind_proc */ LDAP_SET_REBIND_PROC_ARGS 3) the define and the comment on one line: Build Options: COMPILER_SUPPORTS_LL /* Whether the compiler supports the LL prefix on long long integers */ LDAP_SET_REBIND_PROC_ARGS /* Number of arguments to ldap_set_rebind_proc */ Personally, I prefer the third option, but the lines are long, which probably isn't to everyone's likings. To try out the various options, comment/uncomment lines 215-217 of script/mkbuildoptions.awk as necessary. Vance Lankhaar
Index: Makefile.in =================================================================== RCS file: /cvsroot/samba/source/Makefile.in,v retrieving revision 1.628 diff -u -r1.628 Makefile.in --- Makefile.in 14 Mar 2003 23:11:18 -0000 1.628 +++ Makefile.in 15 Mar 2003 04:37:11 -0000 @@ -697,6 +697,13 @@ @BROKEN_CC@ -mv `echo $@ | sed -e 's%^.*/%%g' -e 's%\.po$$%.o%'` $@ @POBAD_CC@ @mv $*.po.o $@ +smbd/build_options.o: smbd/build_options.c Makefile include/config.h + @echo Compiling $*.c + @$(CC) $(FLAGS) $(PATH_FLAGS) -c $< -o $@ + +smbd/build_options.c: include/config.h.in script/mkbuildoptions.awk + @echo Generating $@ + @$(AWK) -f $(srcdir)/script/mkbuildoptions.awk > $(builddir)/smbd/build_options.c < $(srcdir)/include/config.h.in .c.po: @if (: >> $@ || : > $@) >/dev/null 2>&1; then rm -f $@; else \ dir=`echo $@ | sed 's,/[^/]*$$,,;s,^$$,.,'` $(MAKEDIR); fi @@ -1145,7 +1152,7 @@ proto_exists: include/proto.h include/wrepld_proto.h include/build_env.h \ nsswitch/winbindd_proto.h web/swat_proto.h \ client/client_proto.h utils/net_proto.h \ - include/tdbsam2_parse_info.h + include/tdbsam2_parse_info.h smbd/build_options.c delheaders: @echo Removing prototype headers @@ -1154,13 +1161,14 @@ @/bin/rm -f $(srcdir)/web/swat_proto.h @/bin/rm -f $(srcdir)/client/client_proto.h $(srcdir)/utils/net_proto.h @/bin/rm -f $(srcdir)/include/tdbsam2_parse_info.h + @/bin/rm -f $(srcdir)/smbd/build_options.c @/bin/rm -f include/proto.h include/build_env.h include/wrepld_proto.h \ nsswitch/winbindd_proto.h web/swat_proto.h \ client/client_proto.h utils/net_proto.h \ - include/tdbsam2_parse_info.h + include/tdbsam2_parse_info.h smbd/build_options.c -include/proto.h: +include/proto.h: smbd/build_options.c @echo Building include/proto.h @cd $(srcdir) && $(SHELL) script/mkproto.sh $(AWK) \ -h _PROTO_H_ $(builddir)/include/proto.h \ @@ -1206,6 +1214,7 @@ # parallel make. headers: $(MAKE) delheaders; \ + $(MAKE) smbd/build_options.c \ $(MAKE) include/proto.h; \ $(MAKE) include/build_env.h; \ $(MAKE) include/wrepld_proto.h; \ --- /dev/null 2003-01-27 19:23:49.000000000 -0700 +++ script/mkbuildoptions.awk 2003-03-14 21:37:00.000000000 -0700 @@ -0,0 +1,249 @@ +BEGIN { + print "/* "; + print " Unix SMB/CIFS implementation."; + print " Build Options for Samba Suite"; + print " Copyright (C) Vance Lankhaar <[EMAIL PROTECTED]> 2003"; + print " Copyright (C) Andrew Bartlett <[EMAIL PROTECTED]> 2001"; + print " "; + print " This program is free software; you can redistribute it and/or modify"; + print " it under the terms of the GNU General Public License as published by"; + print " the Free Software Foundation; either version 2 of the License, or"; + print " (at your option) any later version."; + print " "; + print " This program is distributed in the hope that it will be useful,"; + print " but WITHOUT ANY WARRANTY; without even the implied warranty of"; + print " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the"; + print " GNU General Public License for more details."; + print " "; + print " You should have received a copy of the GNU General Public License"; + print " along with this program; if not, write to the Free Software"; + print " Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA."; + print "*/"; + print ""; + print "#include \"includes.h\""; + print "#include \"build_env.h\""; + print "#include \"dynconfig.h\""; + print ""; + print "static void output(BOOL screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);"; + print ""; + print ""; + print "/****************************************************************************"; + print "helper function for build_options"; + print "****************************************************************************/"; + print "static void output(BOOL screen, const char *format, ...)"; + print "{"; + print " char *ptr;"; + print " va_list ap;"; + print " "; + print " va_start(ap, format);"; + print " vasprintf(&ptr,format,ap);"; + print " va_end(ap);"; + print ""; + print " if (screen) {"; + print " d_printf(\"%s\", ptr);"; + print " } else {"; + print " DEBUG(4,(\"%s\", ptr));"; + print " }"; + print " "; + print " SAFE_FREE(ptr);"; + print "}"; + print ""; + print "/****************************************************************************"; + print "options set at build time for the samba suite"; + print "****************************************************************************/"; + print "void build_options(BOOL screen)"; + print "{"; + print " if ((DEBUGLEVEL < 4) && (!screen)) {"; + print " return;"; + print " }"; + print ""; + print "#ifdef _BUILD_ENV_H"; + print " /* Output information about the build environment */"; + print " output(screen,\"Build environment:\\n\");"; + print " output(screen,\" Built by: [EMAIL PROTECTED]",BUILD_ENV_USER,BUILD_ENV_HOST);"; + print " output(screen,\" Built on: %s\\n\",BUILD_ENV_DATE);"; + print ""; + print " output(screen,\" Built using: %s\\n\",BUILD_ENV_COMPILER);"; + print " output(screen,\" Build host: %s\\n\",BUILD_ENV_UNAME);"; + print " output(screen,\" SRCDIR: %s\\n\",BUILD_ENV_SRCDIR);"; + print " output(screen,\" BUILDDIR: %s\\n\",BUILD_ENV_BUILDDIR);"; + print ""; + print " "; + print "#endif"; + print ""; + + print " /* Output various paths to files and directories */"; + print " output(screen,\"\\nPaths:\\n\");"; + print " output(screen,\" CONFIGFILE: %s\\n\", dyn_CONFIGFILE);"; + print "#ifdef PRIVATE_DIR"; + print " output(screen,\" PRIVATE_DIR: %s\\n\",PRIVATE_DIR);"; + print "#endif"; + print "#ifdef LMHOSTSFILE"; + print " output(screen,\" LMHOSTSFILE: %s\\n\",LMHOSTSFILE);"; + print "#endif"; + print " output(screen,\" SBINDIR: %s\\n\", dyn_SBINDIR);"; + print " output(screen,\" BINDIR: %s\\n\", dyn_BINDIR);"; + print " output(screen,\" LOCKDIR: %s\\n\",dyn_LOCKDIR);"; + print " output(screen,\" LOGFILEBASE: %s\\n\", dyn_LOGFILEBASE);"; + print ""; + + +################################################## +# predefine first element of *_ary +# predefine *_i (num of elements in *_ary) + with_ary[0]=""; + with_i=0; + have_ary[0]=""; + have_i=0; + utmp_ary[0]=""; + utmp_i=0; + misc_ary[0]=""; + misc_i=0; + sys_ary[0]=""; + sys_i=0; + headers_ary[0]=""; + headers_i=0; + in_comment = 0; +} + +# capture single line comments +/^\/\* (.*?)\*\// { + last_comment = $0; + next; +} + +# end capture multi-line comments +/(.*?)\*\// { + last_comment = last_comment $0; + in_comment = 0; + next; +} + +# capture middle lines of multi-line comments +in_comment { + last_comment = last_comment $0; + next; +} + +# begin capture multi-line comments +/^\/\* (.*?)/ { + last_comment = $0; + in_comment = 1; + next +} + +################################################## +# if we have an #undef and a last_comment, store it +/^\#undef/ { + split($0,a); + comments_ary[a[2]] = last_comment; + last_comment = ""; +} + +################################################## +# for each line, sort into appropriate section +# then move on + +/^\#undef WITH/ { + with_ary[with_i++] = a[2]; + # we want (I think) to allow --with to show up in more than one place, so no next +} + + +/^\#undef HAVE_UT_UT_/ || /^\#undef .*UTMP/ { + utmp_ary[utmp_i++] = a[2]; + next; +} + +/^\#undef HAVE_SYS_.*?_H$/ { + sys_ary[sys_i++] = a[2]; + next; +} + +/^\#undef HAVE_.*?_H$/ { + headers_ary[headers_i++] = a[2]; + next; +} + +/^\#undef HAVE_/ { + have_ary[have_i++] = a[2]; + next; +} + +/^\#undef/ { + misc_ary[misc_i++] = a[2]; + next; +} + + +################################################## +# simple sort function +function sort(ARRAY, ELEMENTS) { + for (i = 1; i <= ELEMENTS; ++i) { + for (j = i; (j-1) in ARRAY && (j) in ARRAY && ARRAY[j-1] > ARRAY[j]; --j) { + temp = ARRAY[j]; + ARRAY[j] = ARRAY[j-1]; + ARRAY[j-1] = temp; + } + } + return; +} + + +################################################## +# output code from list of defined +# expects: ARRAY an array of things defined +# ELEMENTS number of elements in ARRAY +# TITLE title for section +# returns: nothing +function output(ARRAY, ELEMENTS, TITLE) { + + # add section header + print "\n\t/* Show " TITLE " */"; + print "\toutput(screen, \"\\n " TITLE ":\\n\");\n"; + + + # sort element using bubble sort (slow, but easy) + sort(ARRAY, ELEMENTS); + + # loop through array of defines, outputting code + for (i = 0; i < ELEMENTS; i++) { + print "#ifdef " ARRAY[i]; + + # I don't know which one to use.... + + print "\toutput(screen, \" " ARRAY[i] "\\n\");"; + #printf "\toutput(screen, \" %s\\n %s\\n\\n\");\n", comments_ary[ARRAY[i]], ARRAY[i]; + #printf "\toutput(screen, \" %-35s %s\\n\");\n", ARRAY[i], comments_ary[ARRAY[i]]; + + print "#endif"; + } + return; +} + +END { + ################################################## + # add code to show various options + print "/* Output various other options (as gleaned from include/config.h.in) */"; + output(sys_ary, sys_i, "System Headers"); + output(headers_ary, headers_i, "Headers"); + output(utmp_ary, utmp_i, "UTMP Options"); + output(have_ary, have_i, "HAVE_* Defines"); + output(with_ary, with_i, "--with Options"); + output(misc_ary, misc_i, "Build Options"); + + ################################################## + # add code to display the various type sizes + print " /* Output the sizes of the various types */"; + print " output(screen,\"\\nType sizes:\\n\");"; + print " output(screen,\" sizeof(char): %d\\n\",sizeof(char));"; + print " output(screen,\" sizeof(int): %d\\n\",sizeof(int));"; + print " output(screen,\" sizeof(long): %d\\n\",sizeof(long));"; + print " output(screen,\" sizeof(uint8): %d\\n\",sizeof(uint8));"; + print " output(screen,\" sizeof(uint16): %d\\n\",sizeof(uint16));"; + print " output(screen,\" sizeof(uint32): %d\\n\",sizeof(uint32));"; + print " output(screen,\" sizeof(short): %d\\n\",sizeof(short));"; + print " output(screen,\" sizeof(void*): %d\\n\",sizeof(void*));"; + print "}"; +} + Index: smbd/.cvsignore =================================================================== RCS file: /cvsroot/samba/source/smbd/.cvsignore,v retrieving revision 1.4 diff -u -r1.4 .cvsignore --- smbd/.cvsignore 12 Dec 2001 16:04:36 -0000 1.4 +++ smbd/.cvsignore 15 Mar 2003 04:39:07 -0000 @@ -1,2 +1,3 @@ *.po *.po32 +build_options.c