[206] | 1 | BEGIN {
|
---|
| 2 | print "/* ";
|
---|
| 3 | print " Unix SMB/CIFS implementation.";
|
---|
| 4 | print " Build Options for Samba Suite";
|
---|
| 5 | print " Copyright (C) Vance Lankhaar <vlankhaar@linux.ca> 2003";
|
---|
| 6 | print " Copyright (C) Andrew Bartlett <abartlet@samba.org> 2001";
|
---|
| 7 | print " ";
|
---|
| 8 | print " This program is free software; you can redistribute it and/or modify";
|
---|
| 9 | print " it under the terms of the GNU General Public License as published by";
|
---|
| 10 | print " the Free Software Foundation; either version 3 of the License, or";
|
---|
| 11 | print " (at your option) any later version.";
|
---|
| 12 | print " ";
|
---|
| 13 | print " This program is distributed in the hope that it will be useful,";
|
---|
| 14 | print " but WITHOUT ANY WARRANTY; without even the implied warranty of";
|
---|
| 15 | print " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the";
|
---|
| 16 | print " GNU General Public License for more details.";
|
---|
| 17 | print " ";
|
---|
| 18 | print " You should have received a copy of the GNU General Public License";
|
---|
| 19 | print " along with this program; if not, see <http://www.gnu.org/licenses/>."
|
---|
| 20 | print "*/";
|
---|
| 21 | print "";
|
---|
| 22 | print "#include \"includes.h\"";
|
---|
| 23 | print "#include \"build_env.h\"";
|
---|
| 24 | print "#include \"dynconfig.h\"";
|
---|
| 25 | print "";
|
---|
| 26 | print "static int output(bool screen, const char *format, ...) PRINTF_ATTRIBUTE(2,3);";
|
---|
| 27 | print "void build_options(bool screen);";
|
---|
| 28 | print "";
|
---|
| 29 | print "";
|
---|
| 30 | print "/****************************************************************************";
|
---|
| 31 | print "helper function for build_options";
|
---|
| 32 | print "****************************************************************************/";
|
---|
| 33 | print "static int output(bool screen, const char *format, ...)";
|
---|
| 34 | print "{";
|
---|
| 35 | print " char *ptr = NULL;";
|
---|
| 36 | print " int ret = 0;";
|
---|
| 37 | print " va_list ap;";
|
---|
| 38 | print " ";
|
---|
| 39 | print " va_start(ap, format);";
|
---|
| 40 | print " ret = vasprintf(&ptr,format,ap);";
|
---|
| 41 | print " va_end(ap);";
|
---|
| 42 | print "";
|
---|
| 43 | print " if (screen) {";
|
---|
| 44 | print " d_printf(\"%s\", ptr ? ptr : \"\");";
|
---|
| 45 | print " } else {";
|
---|
| 46 | print " DEBUG(4,(\"%s\", ptr ? ptr : \"\"));";
|
---|
| 47 | print " }";
|
---|
| 48 | print " ";
|
---|
| 49 | print " SAFE_FREE(ptr);";
|
---|
| 50 | print " return ret;";
|
---|
| 51 | print "}";
|
---|
| 52 | print "";
|
---|
| 53 | print "/****************************************************************************";
|
---|
| 54 | print "options set at build time for the samba suite";
|
---|
| 55 | print "****************************************************************************/";
|
---|
| 56 | print "void build_options(bool screen)";
|
---|
| 57 | print "{";
|
---|
| 58 | print " if ((DEBUGLEVEL < 4) && (!screen)) {";
|
---|
| 59 | print " return;";
|
---|
| 60 | print " }";
|
---|
| 61 | print "";
|
---|
| 62 | print "#ifdef _BUILD_ENV_H";
|
---|
| 63 | print " /* Output information about the build environment */";
|
---|
| 64 | print " output(screen,\"Build environment:\\n\");";
|
---|
| 65 | print " output(screen,\" Built by: %s@%s\\n\",BUILD_ENV_USER,BUILD_ENV_HOST);";
|
---|
| 66 | print " output(screen,\" Built on: %s\\n\",BUILD_ENV_DATE);";
|
---|
| 67 | print "";
|
---|
| 68 | print " output(screen,\" Built using: %s\\n\",BUILD_ENV_COMPILER);";
|
---|
| 69 | print " output(screen,\" Build host: %s\\n\",BUILD_ENV_UNAME);";
|
---|
| 70 | print " output(screen,\" SRCDIR: %s\\n\",BUILD_ENV_SRCDIR);";
|
---|
| 71 | print " output(screen,\" BUILDDIR: %s\\n\",BUILD_ENV_BUILDDIR);";
|
---|
| 72 | print "";
|
---|
| 73 | print " ";
|
---|
| 74 | print "#endif";
|
---|
| 75 | print "";
|
---|
| 76 |
|
---|
| 77 | print " /* Output various paths to files and directories */";
|
---|
| 78 | print " output(screen,\"\\nPaths:\\n\");";
|
---|
| 79 |
|
---|
| 80 | print " output(screen,\" SBINDIR: %s\\n\", get_dyn_SBINDIR());";
|
---|
| 81 | print " output(screen,\" BINDIR: %s\\n\", get_dyn_BINDIR());";
|
---|
| 82 | print " output(screen,\" SWATDIR: %s\\n\", get_dyn_SWATDIR());";
|
---|
| 83 |
|
---|
| 84 | print " output(screen,\" CONFIGFILE: %s\\n\", get_dyn_CONFIGFILE());";
|
---|
| 85 | print " output(screen,\" LOGFILEBASE: %s\\n\", get_dyn_LOGFILEBASE());";
|
---|
| 86 | print " output(screen,\" LMHOSTSFILE: %s\\n\",get_dyn_LMHOSTSFILE());";
|
---|
| 87 |
|
---|
| 88 | print " output(screen,\" LIBDIR: %s\\n\",get_dyn_LIBDIR());";
|
---|
| 89 | print " output(screen,\" MODULESDIR: %s\\n\",get_dyn_MODULESDIR());";
|
---|
| 90 | print " output(screen,\" SHLIBEXT: %s\\n\",get_dyn_SHLIBEXT());";
|
---|
| 91 |
|
---|
| 92 | print " output(screen,\" LOCKDIR: %s\\n\",get_dyn_LOCKDIR());";
|
---|
| 93 | print " output(screen,\" PIDDIR: %s\\n\", get_dyn_PIDDIR());";
|
---|
| 94 |
|
---|
| 95 | print " output(screen,\" SMB_PASSWD_FILE: %s\\n\",get_dyn_SMB_PASSWD_FILE());";
|
---|
| 96 | print " output(screen,\" PRIVATE_DIR: %s\\n\",get_dyn_PRIVATE_DIR());";
|
---|
| 97 | print "";
|
---|
| 98 |
|
---|
| 99 |
|
---|
| 100 | ##################################################
|
---|
| 101 | # predefine first element of *_ary
|
---|
| 102 | # predefine *_i (num of elements in *_ary)
|
---|
| 103 | with_ary[0]="";
|
---|
| 104 | with_i=0;
|
---|
| 105 | have_ary[0]="";
|
---|
| 106 | have_i=0;
|
---|
| 107 | utmp_ary[0]="";
|
---|
| 108 | utmp_i=0;
|
---|
| 109 | misc_ary[0]="";
|
---|
| 110 | misc_i=0;
|
---|
| 111 | sys_ary[0]="";
|
---|
| 112 | sys_i=0;
|
---|
| 113 | headers_ary[0]="";
|
---|
| 114 | headers_i=0;
|
---|
| 115 | in_comment = 0;
|
---|
| 116 | }
|
---|
| 117 |
|
---|
| 118 | # capture single line comments
|
---|
| 119 | /^\/\* (.*?)\*\// {
|
---|
| 120 | last_comment = $0;
|
---|
| 121 | next;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | # end capture multi-line comments
|
---|
| 125 | /(.*?)\*\// {
|
---|
| 126 | last_comment = last_comment $0;
|
---|
| 127 | in_comment = 0;
|
---|
| 128 | next;
|
---|
| 129 | }
|
---|
| 130 |
|
---|
| 131 | # capture middle lines of multi-line comments
|
---|
| 132 | in_comment {
|
---|
| 133 | last_comment = last_comment $0;
|
---|
| 134 | next;
|
---|
| 135 | }
|
---|
| 136 |
|
---|
| 137 | # begin capture multi-line comments
|
---|
| 138 | /^\/\* (.*?)/ {
|
---|
| 139 | last_comment = $0;
|
---|
| 140 | in_comment = 1;
|
---|
| 141 | next
|
---|
| 142 | }
|
---|
| 143 |
|
---|
| 144 | ##################################################
|
---|
| 145 | # if we have an #undef and a last_comment, store it
|
---|
| 146 | /^\#undef/ {
|
---|
| 147 | split($0,a);
|
---|
| 148 | comments_ary[a[2]] = last_comment;
|
---|
| 149 | last_comment = "";
|
---|
| 150 | }
|
---|
| 151 |
|
---|
| 152 | ##################################################
|
---|
| 153 | # for each line, sort into appropriate section
|
---|
| 154 | # then move on
|
---|
| 155 |
|
---|
| 156 | /^\#undef WITH/ {
|
---|
| 157 | with_ary[with_i++] = a[2];
|
---|
| 158 | # we want (I think) to allow --with to show up in more than one place, so no next
|
---|
| 159 | }
|
---|
| 160 |
|
---|
| 161 |
|
---|
| 162 | /^\#undef HAVE_UT_UT_/ || /^\#undef .*UTMP/ {
|
---|
| 163 | utmp_ary[utmp_i++] = a[2];
|
---|
| 164 | next;
|
---|
| 165 | }
|
---|
| 166 |
|
---|
| 167 | /^\#undef HAVE_SYS_.*?_H$/ {
|
---|
| 168 | sys_ary[sys_i++] = a[2];
|
---|
| 169 | next;
|
---|
| 170 | }
|
---|
| 171 |
|
---|
| 172 | /^\#undef HAVE_.*?_H$/ {
|
---|
| 173 | headers_ary[headers_i++] = a[2];
|
---|
| 174 | next;
|
---|
| 175 | }
|
---|
| 176 |
|
---|
| 177 | /^\#undef HAVE_/ {
|
---|
| 178 | have_ary[have_i++] = a[2];
|
---|
| 179 | next;
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /^\#undef/ {
|
---|
| 183 | misc_ary[misc_i++] = a[2];
|
---|
| 184 | next;
|
---|
| 185 | }
|
---|
| 186 |
|
---|
| 187 |
|
---|
| 188 | ##################################################
|
---|
| 189 | # simple sort function
|
---|
| 190 | function sort(ARRAY, ELEMENTS) {
|
---|
| 191 | for (i = 1; i <= ELEMENTS; ++i) {
|
---|
| 192 | for (j = i; (j-1) in ARRAY && (j) in ARRAY && ARRAY[j-1] > ARRAY[j]; --j) {
|
---|
| 193 | temp = ARRAY[j];
|
---|
| 194 | ARRAY[j] = ARRAY[j-1];
|
---|
| 195 | ARRAY[j-1] = temp;
|
---|
| 196 | }
|
---|
| 197 | }
|
---|
| 198 | return;
|
---|
| 199 | }
|
---|
| 200 |
|
---|
| 201 |
|
---|
| 202 | ##################################################
|
---|
| 203 | # output code from list of defined
|
---|
| 204 | # expects: ARRAY an array of things defined
|
---|
| 205 | # ELEMENTS number of elements in ARRAY
|
---|
| 206 | # TITLE title for section
|
---|
| 207 | # returns: nothing
|
---|
| 208 | function output(ARRAY, ELEMENTS, TITLE) {
|
---|
| 209 |
|
---|
| 210 | # add section header
|
---|
| 211 | print "\n\t/* Show " TITLE " */";
|
---|
| 212 | print "\toutput(screen, \"\\n " TITLE ":\\n\");\n";
|
---|
| 213 |
|
---|
| 214 |
|
---|
| 215 | # sort element using bubble sort (slow, but easy)
|
---|
| 216 | sort(ARRAY, ELEMENTS);
|
---|
| 217 |
|
---|
| 218 | # loop through array of defines, outputting code
|
---|
| 219 | for (i = 0; i < ELEMENTS; i++) {
|
---|
| 220 | print "#ifdef " ARRAY[i];
|
---|
| 221 |
|
---|
| 222 | # I don't know which one to use....
|
---|
| 223 |
|
---|
| 224 | print "\toutput(screen, \" " ARRAY[i] "\\n\");";
|
---|
| 225 | #printf "\toutput(screen, \" %s\\n %s\\n\\n\");\n", comments_ary[ARRAY[i]], ARRAY[i];
|
---|
| 226 | #printf "\toutput(screen, \" %-35s %s\\n\");\n", ARRAY[i], comments_ary[ARRAY[i]];
|
---|
| 227 |
|
---|
| 228 | print "#endif";
|
---|
| 229 | }
|
---|
| 230 | return;
|
---|
| 231 | }
|
---|
| 232 |
|
---|
| 233 | END {
|
---|
| 234 | ##################################################
|
---|
| 235 | # add code to show various options
|
---|
| 236 | print "/* Output various other options (as gleaned from include/config.h.in) */";
|
---|
| 237 | output(sys_ary, sys_i, "System Headers");
|
---|
| 238 | output(headers_ary, headers_i, "Headers");
|
---|
| 239 | output(utmp_ary, utmp_i, "UTMP Options");
|
---|
| 240 | output(have_ary, have_i, "HAVE_* Defines");
|
---|
| 241 | output(with_ary, with_i, "--with Options");
|
---|
| 242 | output(misc_ary, misc_i, "Build Options");
|
---|
| 243 |
|
---|
| 244 | ##################################################
|
---|
| 245 | # add code to display the various type sizes
|
---|
| 246 | print " /* Output the sizes of the various types */";
|
---|
| 247 | print " output(screen, \"\\nType sizes:\\n\");";
|
---|
| 248 | print " output(screen, \" sizeof(char): %lu\\n\",(unsigned long)sizeof(char));";
|
---|
| 249 | print " output(screen, \" sizeof(int): %lu\\n\",(unsigned long)sizeof(int));";
|
---|
| 250 | print " output(screen, \" sizeof(long): %lu\\n\",(unsigned long)sizeof(long));";
|
---|
| 251 | print "#if HAVE_LONGLONG"
|
---|
| 252 | print " output(screen, \" sizeof(long long): %lu\\n\",(unsigned long)sizeof(long long));";
|
---|
| 253 | print "#endif"
|
---|
| 254 | print " output(screen, \" sizeof(uint8): %lu\\n\",(unsigned long)sizeof(uint8));";
|
---|
| 255 | print " output(screen, \" sizeof(uint16): %lu\\n\",(unsigned long)sizeof(uint16));";
|
---|
| 256 | print " output(screen, \" sizeof(uint32): %lu\\n\",(unsigned long)sizeof(uint32));";
|
---|
| 257 | print " output(screen, \" sizeof(short): %lu\\n\",(unsigned long)sizeof(short));";
|
---|
| 258 | print " output(screen, \" sizeof(void*): %lu\\n\",(unsigned long)sizeof(void*));";
|
---|
| 259 | print " output(screen, \" sizeof(size_t): %lu\\n\",(unsigned long)sizeof(size_t));";
|
---|
| 260 | print " output(screen, \" sizeof(off_t): %lu\\n\",(unsigned long)sizeof(off_t));";
|
---|
| 261 | print " output(screen, \" sizeof(ino_t): %lu\\n\",(unsigned long)sizeof(ino_t));";
|
---|
| 262 | print " output(screen, \" sizeof(dev_t): %lu\\n\",(unsigned long)sizeof(dev_t));";
|
---|
| 263 |
|
---|
| 264 | ##################################################
|
---|
| 265 | # add code to give information about modules
|
---|
| 266 | print " output(screen, \"\\nBuiltin modules:\\n\");";
|
---|
| 267 | print " output(screen, \" %s\\n\", STRING_STATIC_MODULES);";
|
---|
| 268 |
|
---|
| 269 | print "}";
|
---|
| 270 |
|
---|
| 271 | }
|
---|
| 272 |
|
---|