diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-24 21:18:58 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2010-10-24 21:29:16 +0300 |
commit | eb3a07ec466ebc923230618d059bdb4c29b170b9 (patch) | |
tree | 242661cccc24d12e2328d43997b558fb287c8960 | |
parent | 686a73448881868fbbf0a6d9d83fa3fc6fc692af (diff) | |
download | mailutils-eb3a07ec466ebc923230618d059bdb4c29b170b9.tar.gz mailutils-eb3a07ec466ebc923230618d059bdb4c29b170b9.tar.bz2 |
Move `mailutils-config' functionality to `mu'. Retain `mailutils-config' for backward compatibility.
* config/.gitignore: Remove.
* config/Makefile.am: Remove.
* config/mailutils-config.c: Remove.
* config/maint.mk: Remove.
* config/mailutils.m4: Move to mu-aux/mailutils.m4
* mu-aux/Makefile.am (m4datadir, dist_m4data_DATA): New variables.
* Makefile.am (SUBDIRS) <config>: Remove.
* configure.ac (AC_CONFIG_FILES): Remove config.
* mu/mailutils-config: New file.
* mu/cflags.c: New file.
* mu/ldflags.c: New file.
* mu/Makefile.am (dist_bin_SCRIPTS, EXTRA_DIST): Add mailutils-config.
(mu_SOURCES): Add cflags.c and ldflags.c.
(AM_CPPFLAGS): New variable.
* mu/mu.c: Add new modes: cflags and ldflags.
* mu/mu.h (mutool_ldflags, mutool_cflags): New protos.
* po/POTFILES.in: Update.
-rw-r--r-- | Makefile.am | 1 | ||||
-rw-r--r-- | config/.gitignore | 5 | ||||
-rw-r--r-- | config/Makefile.am | 39 | ||||
-rw-r--r-- | config/mailutils-config.c | 367 | ||||
-rw-r--r-- | config/maint.mk | 29 | ||||
-rw-r--r-- | configure.ac | 1 | ||||
-rw-r--r-- | libmailutils/cfg/.gitignore | 6 | ||||
-rw-r--r-- | mu-aux/Makefile.am | 2 | ||||
-rw-r--r-- | mu-aux/mailutils.m4 (renamed from config/mailutils.m4) | 0 | ||||
-rw-r--r-- | mu/Makefile.am | 11 | ||||
-rw-r--r-- | mu/cflags.c | 46 | ||||
-rw-r--r-- | mu/ldflags.c | 193 | ||||
-rwxr-xr-x | mu/mailutils-config | 109 | ||||
-rw-r--r-- | mu/mu.c | 4 | ||||
-rw-r--r-- | mu/mu.h | 4 | ||||
-rw-r--r-- | po/POTFILES.in | 5 |
16 files changed, 374 insertions, 448 deletions
diff --git a/Makefile.am b/Makefile.am index 3558c9235..aed3f5ac4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -104,7 +104,6 @@ SUBDIRS = . \ libmu_sieve\ $(PYTHON_DIR)\ doc\ - config\ examples\ mu\ $(FRM_DIR)\ diff --git a/config/.gitignore b/config/.gitignore deleted file mode 100644 index 94e05b5af..000000000 --- a/config/.gitignore +++ /dev/null @@ -1,5 +0,0 @@ -.deps -.libs -Makefile -Makefile.in -mailutils-config diff --git a/config/Makefile.am b/config/Makefile.am deleted file mode 100644 index b850f7f52..000000000 --- a/config/Makefile.am +++ /dev/null @@ -1,39 +0,0 @@ -## This file is part of GNU Mailutils. -## Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software -## Foundation, Inc. -## -## GNU Mailutils is free software; you can redistribute it and/or -## modify it under the terms of the GNU General Public License as -## published by the Free Software Foundation; either version 3, or (at -## your option) any later version. -## -## GNU Mailutils is distributed in the hope that it will be useful, but -## WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. - -INCLUDES = @MU_APP_COMMON_INCLUDES@ - -bin_PROGRAMS = mailutils-config - -mailutils_config_SOURCES = mailutils-config.c -mailutils_config_LDADD = \ - ${MU_APP_LIBRARIES}\ - ${MU_LIB_MAILUTILS}\ - @MU_COMMON_LIBRARIES@ - -mailutils_config_CFLAGS = -DCOMPILE_FLAGS="\"-I$(includedir)\"" \ - -I$(top_srcdir)/intl \ - -I${top_srcdir}/lib \ - -DLINK_FLAGS="\"-L$(libdir)\"" \ - -DLINK_POSTFLAGS="\"$(MU_LINK_POSTFLAGS)\"" \ - -DAUTHLIBS="\"$(MU_AUTHLIBS)\"" \ - -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ - -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ - -DI18NLIBS="\"$(LIBINTL)\"" - -m4datadir = $(datadir)/aclocal -dist_m4data_DATA = mailutils.m4 diff --git a/config/mailutils-config.c b/config/mailutils-config.c deleted file mode 100644 index 6a3449744..000000000 --- a/config/mailutils-config.c +++ /dev/null @@ -1,367 +0,0 @@ -/* GNU Mailutils -- a suite of utilities for electronic mail - Copyright (C) 1999, 2000, 2001, 2002, 2007, 2009, 2010 Free Software - Foundation, Inc. - - GNU Mailutils is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3, or (at your option) - any later version. - - GNU Mailutils is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ - -#ifdef HAVE_CONFIG_H -# include <config.h> -#endif -#include <string.h> -#include <mailutils/mailutils.h> -#include <mu_asprintf.h> -#include "mailutils/libargp.h" - -static char doc[] = N_("GNU mailutils-config -- display compiler and loader options needed for building a program with mailutils."); -static char args_doc[] = N_("[arg...]"); - -static struct argp_option options[] = { - {"compile", 'c', NULL, 0, - N_("print C compiler flags to compile with"), 0}, - {"link", 'l', NULL, 0, - N_("print libraries to link with; possible arguments are: auth, guile, " - "mbox, mh, maildir, mailer, imap, pop, sieve and all"), 0}, - {"info", 'i', NULL, 0, - N_("print a list of configuration options used to build mailutils; " - "optional arguments are interpreted as a list of configuration " - "options to check for"), 0}, - {"query", 'q', N_("FILE"), OPTION_ARG_OPTIONAL, - N_("query configuration values from FILE (default mailutils.rc)"), - 0 }, - {"verbose", 'v', NULL, 0, - N_("increase output verbosity"), 0}, - {0, 0, 0, 0} -}; - -enum config_mode { - MODE_VOID, - MODE_COMPILE, - MODE_LINK, - MODE_INFO, - MODE_QUERY -}; - -enum config_mode mode; -int verbose; -char *query_config_file; - -static error_t -parse_opt (int key, char *arg, struct argp_state *state) -{ - switch (key) - { - case 'l': - mode = MODE_LINK; - break; - - case 'c': - mode = MODE_COMPILE; - break; - - case 'i': - mode = MODE_INFO; - break; - - case 'q': - if (arg) - query_config_file = arg; - mode = MODE_QUERY; - break; - - case 'v': - verbose++; - break; - - default: - return ARGP_ERR_UNKNOWN; - } - return 0; -} - -static struct argp argp = { - options, - parse_opt, - args_doc, - doc, - NULL, - NULL, NULL -}; - -static const char *argp_capa[] = { - "common", - "license", - NULL -}; - -#ifdef WITH_TLS -# define NEEDAUTH 1 -#else -# define NEEDAUTH 0 -#endif -#define NOTALL 2 - -struct lib_descr { - char *name; - char *libname; - int flags; -} lib_descr[] = { - { "mbox", "mu_mbox", 0 }, - { "mh", "mu_mh", 0 }, - { "maildir","mu_maildir", 0 }, - { "imap", "mu_imap", NEEDAUTH }, - { "pop", "mu_pop", NEEDAUTH }, - { "nntp", "mu_nntp", 0 }, - { "mailer", "mu_mailer", 0 }, - { "sieve", "mu_sieve", NOTALL }, - { NULL } -}; - -struct lib_entry { - int level; - char *ptr; -} lib_entry[16]; - -int nentry; - -void -add_entry (int level, char *ptr) -{ - int i; - if (nentry >= sizeof(lib_entry)/sizeof(lib_entry[0])) - { - mu_error (_("too many arguments")); - exit (1); - } - - for (i = 0; i < nentry; i++) - if (strcmp (lib_entry[i].ptr, ptr) == 0) - return; - lib_entry[nentry].level = level; - lib_entry[nentry].ptr = ptr; - nentry++; -} - -/* Sort the entries by their level. */ -void -sort_entries () -{ - int j; - - for (j = 0; j < nentry; j++) - { - int i; - - for (i = j; i < nentry; i++) - if (lib_entry[j].level > lib_entry[i].level) - { - struct lib_entry tmp; - tmp = lib_entry[i]; - lib_entry[i] = lib_entry[j]; - lib_entry[j] = tmp; - } - - } -} - -int -main (int argc, char **argv) -{ - int index; - int i, rc; - struct argp *myargp; - char **excapa; - mu_cfg_tree_t *tree = NULL; - mu_stream_t stream; - int fmtflags = 0; - - mu_argp_init (NULL, NULL); - - mu_set_program_name (argv[0]); - mu_libargp_init (); - for (i = 0; argp_capa[i]; i++) - mu_gocs_register_std (argp_capa[i]); /*FIXME*/ - myargp = mu_argp_build (&argp, &excapa); - - if (argp_parse (myargp, argc, argv, 0, &index, NULL)) - { - argp_help (myargp, stdout, ARGP_HELP_SEE, program_invocation_short_name); - return 1; - } - mu_argp_done (myargp); - mu_set_program_name (program_invocation_name); - - argc -= index; - argv += index; - - switch (mode) - { - case MODE_VOID: - break; - - case MODE_LINK: - { - int j; - char *ptr; - - add_entry (-100, LINK_FLAGS); - add_entry (100, LINK_POSTFLAGS); - add_entry (1, "-lmailutils"); -#ifdef ENABLE_NLS - if (sizeof (I18NLIBS) > 1) - add_entry (10, I18NLIBS); -#endif - - for ( ; argc > 0; argc--, argv++) - { - if (strcmp (argv[0], "auth") == 0) - { - add_entry (2, "-lmu_auth " AUTHLIBS); - } -#ifdef WITH_GUILE - else if (strcmp (argv[0], "guile") == 0) - { - add_entry (-1, "-lmu_scm " GUILE_LIBS); - } -#endif -#ifdef WITH_PYTHON - else if (strcmp (argv[0], "python") == 0) - { - add_entry (-1, "-lmu_py " PYTHON_LIBS); - } -#endif - else if (strcmp (argv[0], "cfg") == 0) - add_entry (-1, "-lmu_cfg"); - else if (strcmp (argv[0], "argp") == 0) - add_entry (-2, "-lmu_argp"); - else if (strcmp (argv[0], "all") == 0) - { - struct lib_descr *p; - - for (p = lib_descr; p->name; p++) - { - if (p->flags & NOTALL) - continue; - asprintf (&ptr, "-l%s", p->libname); - add_entry (0, ptr); - if (p->flags & NEEDAUTH) - add_entry (2, "-lmu_auth " AUTHLIBS); - } - } - else - { - struct lib_descr *p; - - for (p = lib_descr; p->name; p++) - if (mu_c_strcasecmp (p->name, argv[0]) == 0) - break; - - if (p->name) - { - asprintf (&ptr, "-l%s", p->libname); - add_entry (0, ptr); - if (p->flags & NEEDAUTH) - add_entry (2, "-lmu_auth " AUTHLIBS); - } - else - { - argp_help (&argp, stdout, ARGP_HELP_USAGE, - program_invocation_short_name); - return 1; - } - } - } - - sort_entries (); - - /* At least one entry is always present */ - printf ("%s", lib_entry[0].ptr); - - /* Print the rest of them separated by a space */ - for (j = 1; j < nentry; j++) - { - printf (" %s", lib_entry[j].ptr); - } - printf ("\n"); - return 0; - } - - case MODE_COMPILE: - if (argc != 0) - break; - printf ("%s\n", COMPILE_FLAGS); - return 0; - - case MODE_INFO: - if (argc == 0) - mu_fprint_options (stdout, verbose); - else - { - int i, found = 0; - - for (i = 0; i < argc; i++) - { - const struct mu_conf_option *opt = mu_check_option (argv[i]); - if (opt) - { - found++; - mu_fprint_conf_option (stdout, opt, verbose); - } - } - return found == argc ? 0 : 1; - } - return 0; - - case MODE_QUERY: - if (argc == 0) - { - mu_error (_("not enough arguments")); - return 1; - } - - if (query_config_file) - { - mu_load_site_rcfile = 0; - mu_load_user_rcfile = 0; - mu_load_rcfile = query_config_file; - } - - if (mu_libcfg_parse_config (&tree)) - exit (1); - if (!tree) - exit (0); - rc = mu_stdio_stream_create (&stream, MU_STDOUT_FD, 0); - if (rc) - { - mu_error ("mu_stdio_stream_create: %s", mu_strerror (rc)); - exit (1); - } - if (verbose) - fmtflags = MU_CFG_FMT_LOCUS; - for ( ; argc > 0; argc--, argv++) - { - char *path = *argv; - mu_cfg_node_t *node; - - if (mu_cfg_find_node (tree, path, &node) == 0) - { - mu_cfg_format_node (stream, node, fmtflags); - } - } - exit (0); - } - - argp_help (&argp, stdout, ARGP_HELP_USAGE, program_invocation_short_name); - return 0; -} - diff --git a/config/maint.mk b/config/maint.mk deleted file mode 100644 index 69049bf72..000000000 --- a/config/maint.mk +++ /dev/null @@ -1,29 +0,0 @@ -# This file is part of GNU Mailutils. -# Copyright (C) 2009, 2010 Free Software Foundation, Inc. -# -# Written by Sergey Poznyakoff -# -# GNU Mailutils is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Mailutils is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. - -include Makefile -mailutils_config_CFLOW_INPUT=$(mailutils_config_SOURCES) -mailutils-config.cflow: $(mailutils_config_CFLOW_INPUT) Makefile - cflow -o$@ $(CFLOW_FLAGS) $(DEFS) \ - $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \ - $(CPPFLAGS) \ - $(mailutils_config_CFLOW_INPUT) - -flowgraph: mailutils-config.cflow -maintclean: - rm -f mailutils-config.cflow diff --git a/configure.ac b/configure.ac index c7a627d0f..27ff3f64a 100644 --- a/configure.ac +++ b/configure.ac @@ -1337,7 +1337,6 @@ AC_CONFIG_FILES([ Makefile sql/Makefile comsat/Makefile - config/Makefile doc/Makefile doc/man/Makefile doc/texinfo/Makefile diff --git a/libmailutils/cfg/.gitignore b/libmailutils/cfg/.gitignore index 473803d29..8993e6040 100644 --- a/libmailutils/cfg/.gitignore +++ b/libmailutils/cfg/.gitignore @@ -1,3 +1,3 @@ -cfg_lexer.c -cfg_parser.c -cfg_parser.h +lexer.c +parser.c +parser.h diff --git a/mu-aux/Makefile.am b/mu-aux/Makefile.am index 7273a9fbf..ec4158907 100644 --- a/mu-aux/Makefile.am +++ b/mu-aux/Makefile.am @@ -24,3 +24,5 @@ EXTRA_DIST = \ sqlmod.sh\ generr.awk +m4datadir = $(datadir)/aclocal +dist_m4data_DATA = mailutils.m4 diff --git a/config/mailutils.m4 b/mu-aux/mailutils.m4 index 4e8bb479c..4e8bb479c 100644 --- a/config/mailutils.m4 +++ b/mu-aux/mailutils.m4 diff --git a/mu/Makefile.am b/mu/Makefile.am index e5793569b..6fe40d907 100644 --- a/mu/Makefile.am +++ b/mu/Makefile.am @@ -16,6 +16,7 @@ ## along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. bin_PROGRAMS = mu +dist_bin_SCRIPTS = mailutils-config if MU_COND_SUPPORT_POP POP_C=pop.c @@ -25,11 +26,13 @@ EXTRA_DIST=pop.c mu_SOURCES = \ acl.c\ + cflags.c\ info.c\ mu.h\ mu.c\ filter.c\ flt2047.c\ + ldflags.c\ $(POP_C)\ query.c\ shell.c\ @@ -50,3 +53,11 @@ mu_LDADD = \ @READLINE_LIBS@ @MU_COMMON_LIBRARIES@ INCLUDES = @MU_APP_COMMON_INCLUDES@ @MU_AUTHINCS@ +AM_CPPFLAGS = \ + -DCOMPILE_FLAGS="\"-I$(includedir)\"" \ + -DLINK_FLAGS="\"-L$(libdir)\"" \ + -DLINK_POSTFLAGS="\"$(MU_LINK_POSTFLAGS)\"" \ + -DAUTHLIBS="\"$(MU_AUTHLIBS)\"" \ + -DGUILE_LIBS="\"$(GUILE_LIBS)\"" \ + -DPYTHON_LIBS="\"$(PYTHON_LIBS)\"" \ + -DI18NLIBS="\"$(LIBINTL)\"" diff --git a/mu/cflags.c b/mu/cflags.c new file mode 100644 index 000000000..9d177d065 --- /dev/null +++ b/mu/cflags.c @@ -0,0 +1,46 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2010 Free Software Foundation, Inc. + + GNU Mailutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Mailutils is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ + +#if defined(HAVE_CONFIG_H) +# include <config.h> +#endif +#include <stdlib.h> +#include <mailutils/mailutils.h> +#include <mailutils/libcfg.h> +#include <argp.h> + +static char cflags_doc[] = N_("mu cflags - show compiler options"); + +static struct argp cflags_argp = { + NULL, + NULL, + NULL, + cflags_doc, + NULL, + NULL, + NULL +}; + +int +mutool_cflags (int argc, char **argv) +{ + if (argp_parse (&cflags_argp, argc, argv, ARGP_IN_ORDER, NULL, NULL)) + return 1; + printf ("%s\n", COMPILE_FLAGS); + return 0; +} + + diff --git a/mu/ldflags.c b/mu/ldflags.c new file mode 100644 index 000000000..ba00bf814 --- /dev/null +++ b/mu/ldflags.c @@ -0,0 +1,193 @@ +/* GNU Mailutils -- a suite of utilities for electronic mail + Copyright (C) 2010 Free Software Foundation, Inc. + + GNU Mailutils is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GNU Mailutils is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. */ + +#if defined(HAVE_CONFIG_H) +# include <config.h> +#endif +#include <stdlib.h> +#include <mailutils/mailutils.h> +#include <mailutils/libcfg.h> +#include <argp.h> + +static char ldflags_doc[] = N_("mu ldflags - list libraries required to link"); +static char ldflags_args_doc[] = N_("KEYWORD [KEYWORD...]"); + +static struct argp ldflags_argp = { + NULL, + NULL, + ldflags_args_doc, + ldflags_doc, + NULL, + NULL, + NULL +}; + + +#ifdef WITH_TLS +# define NEEDAUTH 1 +#else +# define NEEDAUTH 0 +#endif +#define NOTALL 2 + +struct lib_descr { + char *name; + char *libname; + int flags; +} lib_descr[] = { + { "mbox", "mu_mbox", 0 }, + { "mh", "mu_mh", 0 }, + { "maildir","mu_maildir", 0 }, + { "imap", "mu_imap", NEEDAUTH }, + { "pop", "mu_pop", NEEDAUTH }, + { "nntp", "mu_nntp", 0 }, + { "mailer", "mu_mailer", 0 }, + { "sieve", "mu_sieve", NOTALL }, + { NULL } +}; + +struct lib_entry { + int level; + char *ptr; +} lib_entry[16]; + +int nentry; + +void +add_entry (int level, char *ptr) +{ + int i; + if (nentry >= sizeof(lib_entry)/sizeof(lib_entry[0])) + { + mu_error (_("too many arguments")); + exit (1); + } + + for (i = 0; i < nentry; i++) + if (strcmp (lib_entry[i].ptr, ptr) == 0) + return; + lib_entry[nentry].level = level; + lib_entry[nentry].ptr = ptr; + nentry++; +} + +/* Sort the entries by their level. */ +void +sort_entries () +{ + int j; + + for (j = 0; j < nentry; j++) + { + int i; + + for (i = j; i < nentry; i++) + if (lib_entry[j].level > lib_entry[i].level) + { + struct lib_entry tmp; + tmp = lib_entry[i]; + lib_entry[i] = lib_entry[j]; + lib_entry[j] = tmp; + } + } +} + + +int +mutool_ldflags (int argc, char **argv) +{ + int i, j; + char *ptr; + + if (argp_parse (&ldflags_argp, argc, argv, ARGP_IN_ORDER, &i, NULL)) + return 1; + + argc -= i; + argv += i; + + add_entry (-100, LINK_FLAGS); + add_entry (100, LINK_POSTFLAGS); + add_entry (1, "-lmailutils"); +#ifdef ENABLE_NLS + if (sizeof (I18NLIBS) > 1) + add_entry (10, I18NLIBS); +#endif + + for ( ; argc > 0; argc--, argv++) + { + if (strcmp (argv[0], "auth") == 0) + add_entry (2, "-lmu_auth " AUTHLIBS); +#ifdef WITH_GUILE + else if (strcmp (argv[0], "guile") == 0) + add_entry (-1, "-lmu_scm " GUILE_LIBS); +#endif +#ifdef WITH_PYTHON + else if (strcmp (argv[0], "python") == 0) + add_entry (-1, "-lmu_py " PYTHON_LIBS); +#endif + else if (strcmp (argv[0], "cfg") == 0) + add_entry (-1, "-lmu_cfg"); + else if (strcmp (argv[0], "argp") == 0) + add_entry (-2, "-lmu_argp"); + else if (strcmp (argv[0], "all") == 0) + { + struct lib_descr *p; + + for (p = lib_descr; p->name; p++) + { + if (p->flags & NOTALL) + continue; + asprintf (&ptr, "-l%s", p->libname); + add_entry (0, ptr); + if (p->flags & NEEDAUTH) + add_entry (2, "-lmu_auth " AUTHLIBS); + } + } + else + { + struct lib_descr *p; + + for (p = lib_descr; p->name; p++) + if (mu_c_strcasecmp (p->name, argv[0]) == 0) + break; + + if (p->name) + { + asprintf (&ptr, "-l%s", p->libname); + add_entry (0, ptr); + if (p->flags & NEEDAUTH) + add_entry (2, "-lmu_auth " AUTHLIBS); + } + else + { + mu_error (_("unknown keyword: %s"), argv[0]); + return 1; + } + } + } + + sort_entries (); + + /* At least one entry is always present */ + printf ("%s", lib_entry[0].ptr); + + /* Print the rest of them separated by a space */ + for (j = 1; j < nentry; j++) + printf (" %s", lib_entry[j].ptr); + putchar ('\n'); + return 0; +} + diff --git a/mu/mailutils-config b/mu/mailutils-config new file mode 100755 index 000000000..2545265dd --- /dev/null +++ b/mu/mailutils-config @@ -0,0 +1,109 @@ +#! /bin/sh +# A deprecated interface to GNU Mailutils configuration facilities. +# Copyright (C) 2010 Free Software Foundation, Inc. +# +# GNU Mailutils is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2, or (at +# your option) any later version. +# +# GNU Mailutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with GNU Mailutils. If not, see <http://www.gnu.org/licenses/>. + +mode= +file= +dir=`expr "$0" : '\(.*\)/.*'` + +test -n "$dir" && PATH=$PATH:$dir + +usage() { + cat <<EOT +This is a deprecated interface to GNU Mailutils configuration facilities. +It will be removed in future versions. Please, consider using these +alternatives instead: + + Traditional usage | Use instead + ------------------------------+------------------- + mailutils-config --compile | mu cflags + mailutils-config --link | mu ldflags + mailutils-config --info | mu info + mailutils-config --query | mu query + mailutils-config --query=FILE | mu query -f FILE + +For more information, try \`mu --help'. + +EOT + exit 0 +} + +while test $# -ne 0 +do + arg=$1 + shift + case $arg in + -c|--c|--co|--com|--comp|--compil|--compile) + mode=cflags + break + ;; + -i|--i|--in|--inf|--info) + mode=info + break + ;; + -l|--l|--li|--lin|--link) + mode=ldflags + break + ;; + --) + break + ;; + -q*=*|--q*=*) + opt=`expr "$arg" : '\(.*\)='` + arg=`expr "$arg" : '.*=\(.*\)'` + case $opt in + -q|--q|--qu|--que|--quer|--query) + mode=query + file=arg + break + ;; + *) + echo >&2 "$0: invalid option: $1" + exit 1 + esac + ;; + -q|--q|--qu|--que|--quer|--query) + mode=query + break + ;; + -q*) + mode=query + file=`expr "$arg" : '-q\(.*\)'` + break + ;; + --usage|--u|--us|--usa|--usag|--help|--hel|--he|--h) + usage + ;; + -V|--version|--versio|--versi|--vers|--ver|--ve|--v) + mu --version | sed -n '1{s/^mu/mailutils-config/;s/(\(GNU Mailutils\)) \([0-9][0-9.]*\).*/(\1 \2)/;p}' + exit 0 + ;; + *) + echo >&2 "$0: unexpected argument; try \`$0 --usage' for help" + exit 1 + ;; + esac +done + +if test -z "$mode"; then + usage +fi + +if test -n "$file"; then + set -- -f"$file" $* +fi + +mu $mode $* @@ -34,6 +34,8 @@ Commands are:\n\ mu 2047 - decode/encode message headers as per RFC 2047\n\ mu acl - test access control lists\n\ mu wicket - find matching URL in wicket\n\ + mu ldflags- list libraries required to link\n\ + mu cflags - list compiler flags\n\ \n\ Try `mu COMMAND --help' to get help on a particular COMMAND.\n\ \n\ @@ -108,6 +110,8 @@ struct mutool_action_tab mutool_action_tab[] = { { "query", mutool_query }, { "acl", mutool_acl }, { "wicket", mutool_wicket }, + { "ldflags", mutool_ldflags }, + { "cflags", mutool_cflags }, { NULL } }; @@ -36,7 +36,9 @@ int mutool_info (int argc, char **argv); int mutool_query (int argc, char **argv); int mutool_acl (int argc, char **argv); int mutool_wicket (int argc, char **argv); - +int mutool_ldflags (int argc, char **argv); +int mutool_cflags (int argc, char **argv); + extern char *mutool_shell_prompt; extern mu_vartab_t mutool_prompt_vartab; extern int mutool_shell_interactive; diff --git a/po/POTFILES.in b/po/POTFILES.in index f07b4c5bd..fc1e8b14b 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -7,8 +7,6 @@ comsat/action.c comsat/comsat.c -config/mailutils-config.c - dotlock/dotlock.c frm/common.c @@ -213,6 +211,9 @@ mu/mu.c mu/pop.c mu/query.c mu/shell.c +mu/cflags.c +mu/ldflags.c +mu/wicket.c # EOF |