Pacaging/build issues with AIX and vac (dovecot-2.2.25)
Michael Felt
michael at felt.demon.nl
Sat Jun 10 15:42:33 EEST 2017
On 09/10/2016 21:48, Michael Felt wrote:
> I finally decided it was really time to stop being lazy and really
> move away from gmail. After I have a server in my basement using
> power, etc.
>
> So I turned on the imap provided - and did not quite cry - it will
> have to do for now, but imap2 is wanting.
Next chapter in packaging.
a) I have 'patched' several files to get around the 'limitation' of the
xlc parsing of Compound Literals.
b) a bit more difficult is to figure out how to not need GNU C Library
getopt(). Currently stuck at:
xlc_r -DHAVE_CONFIG_H -I. -I../../../src/x071-test/src/doveadm -I../..
-I../../../src/x071-test/src/lib -I../../../src/x071-test/src/lib-test
-I../../../src/x071-test/src/lib-settings
-I../../../src/x071-test/src/lib-auth
-I../../../src/x071-test/src/lib-compression
-I../../../src/x071-test/src/lib-dict
-I../../../src/x071-test/src/lib-fs
-I../../../src/x071-test/src/lib-ssl-iostream
-I../../../src/x071-test/src/lib-master
-I../../../src/x071-test/src/lib-mail
-I../../../src/x071-test/src/lib-imap
-I../../../src/x071-test/src/lib-index
-I../../../src/x071-test/src/lib-storage
-I../../../src/x071-test/src/lib-imap-storage
-I../../../src/x071-test/src/lib-http
-I../../../src/x071-test/src/lib-dcrypt
-I../../../src/x071-test/src/auth -DMODULEDIR=\""/opt/lib/dovecot"\"
-DAUTH_MODULE_DIR=\""/opt/lib/dovecot/auth"\"
-DDOVEADM_MODULEDIR=\""/opt/lib/dovecot/doveadm"\"
-DPKG_RUNDIR=\""/var/x071-test/run/dovecot"\"
-DPKG_STATEDIR=\""/var/x071-test/lib/dovecot"\"
-DPKG_LIBEXECDIR=\""/opt/libexec/dovecot"\" -DBINDIR=\""/opt/bin"\"
-DMANDIR=\""/usr/share/man"\" -I/opt/include -I/opt/include -O2
-qmaxmem=-1 -qarch=pwr5 -c -o doveadm-cmd.o
../../../src/x071-test/src/doveadm/doveadm-cmd.c
"../../../src/x071-test/src/doveadm/doveadm-cmd.c", line 434.24:
1506-007 (S) "struct option" is undefined.
"../../../src/x071-test/src/doveadm/doveadm-cmd.c", line 516.9: 1506-285
(S) The indirection operator cannot be applied to a pointer to an
incomplete struct or union.
"../../../src/x071-test/src/doveadm/doveadm-cmd.c", line 536.37:
1506-285 (S) The indirection operator cannot be applied to a pointer to
an incomplete struct or union.
"../../../src/x071-test/src/doveadm/doveadm-cmd.c", line 548.37:
1506-285 (S) The indirection operator cannot be applied to a pointer to
an incomplete struct or union.
make[1]: *** [doveadm-cmd.o] Error 1
+428 static void
+429 doveadm_build_options(const struct doveadm_cmd_param par[],
+430 string_t *shortopts,
+431 ARRAY_TYPE(getopt_option_array) *longopts)
+432 {
+433 for(size_t i=0; par[i].name != NULL; i++) {
+434 struct option longopt;
+435
+436 i_zero(&longopt);
+437 longopt.name = par[i].name;
+438 if (par[i].short_opt != '\0') {
+439 longopt.val = par[i].short_opt;
+440 str_append_c(shortopts, par[i].short_opt);
+441 if (par[i].type != CMD_PARAM_BOOL)
+442 str_append_c(shortopts, ':');
+443 }
+444 if (par[i].type != CMD_PARAM_BOOL)
+445 longopt.has_arg = 1;
+446 array_append(longopts, &longopt, 1);
+447 }
+448 array_append_zero(longopts);
+449 }
+505 int doveadm_cmd_run_ver2(int argc, const char *const argv[],
+506 struct doveadm_cmd_context *cctx)
+507 {
+508 struct doveadm_cmd_param *param;
+509 ARRAY_TYPE(doveadm_cmd_param_arr_t) pargv;
+510 ARRAY_TYPE(getopt_option_array) opts;
+511 unsigned int pargc;
+512 int c,li;
+513 pool_t pool = pool_datastack_create();
+514 string_t *optbuf = str_new(pool, 64);
+515
+516 p_array_init(&opts, pool, 4);
+517
+518 // build parameters
+519 doveadm_build_options(cctx->cmd->parameters, optbuf, &opts);
+530 while((c = getopt_long(argc, (char*const*)argv,
str_c(optbuf), array_idx(&opts, 0), &li)) > -1) {
+531 switch(c) {
+532 case 0:
+533 for(unsigned int i = 0; i <
array_count(&pargv); i++) {
+534 const struct option *opt =
array_idx(&opts,li);
+535 param =
array_idx_modifiable(&pargv,i);
+536 if (opt->name == param->name)
+537 doveadm_fill_param(param, optarg, pool);
+538 }
+539 break;
+540 case '?':
+541 case ':':
+542 doveadm_cmd_params_clean(&pargv);
+543 return -1;
+544 default:
+545 // hunt the option
+546 for(unsigned int i = 0; i < pargc; i++) {
+547 const struct option *longopt =
array_idx(&opts,i);
+548 if (longopt->val == c)
+549 doveadm_fill_param(array_idx_modifiable(&pargv,i), optarg, pool);
+550 }
+551 }
+552 }
fyi: I solved the <getopt.h> issue with:
+11 #include <stdio.h>
+12 #include <unistd.h>
+13 /*
+14 * getopt.h is non-POSIX
+15 * on AIX getopt() is declared in unistd.h
+16 */
+17 #ifndef _AIX
+18 #include <getopt.h>
+19 #endif
Suggestions welcome!
More information about the dovecot
mailing list