29 |
static struct argp_option options[] = { |
static struct argp_option options[] = { |
30 |
{"compile", 'c', NULL, 0, N_("print C compiler flags to compile with"), 0}, |
{"compile", 'c', NULL, 0, N_("print C compiler flags to compile with"), 0}, |
31 |
{"link", 'l', NULL, 0, |
{"link", 'l', NULL, 0, |
32 |
N_("print libraries to link with. Up to two args can be given. Arguments are: " |
N_("print libraries to link with. Possible arguments are: auth, guile, all," |
33 |
"auth, to display libraries needed for linking against libmuauth, and " |
"mbox, mh, maildir, imap, pop"), 0}, |
|
"guile, to display libraries needed for linking against libmu_scm. " |
|
|
"Both can be given simultaneously"), 0}, |
|
34 |
{"info", 'i', NULL, 0, |
{"info", 'i', NULL, 0, |
35 |
N_("print a list of configuration options used to build mailutils. If arguments " |
N_("print a list of configuration options used to build mailutils. If arguments " |
36 |
"are given, they are interpreted as a list of configuration options to check " |
"are given, they are interpreted as a list of configuration options to check " |
87 |
NULL |
NULL |
88 |
}; |
}; |
89 |
|
|
90 |
|
#ifdef WITH_TLS |
91 |
|
# define TLSAUTH 1 |
92 |
|
#else |
93 |
|
# define TLSAUTH 0 |
94 |
|
#endif |
95 |
|
|
96 |
|
struct lib_descr { |
97 |
|
char *name; |
98 |
|
char *libname; |
99 |
|
int needauth; |
100 |
|
} lib_descr[] = { |
101 |
|
{ "mbox", "mu_mbox", 0 }, |
102 |
|
{ "mh", "mu_mh", 0 }, |
103 |
|
{ "maildir","mu_maildir", 0 }, |
104 |
|
{ "imap", "mu_imap", TLSAUTH }, |
105 |
|
{ "pop", "mu_pop", TLSAUTH }, |
106 |
|
{ NULL } |
107 |
|
}; |
108 |
|
|
109 |
|
struct lib_entry { |
110 |
|
int level; |
111 |
|
char *ptr; |
112 |
|
} lib_entry[10]; |
113 |
|
|
114 |
|
int nentry; |
115 |
|
|
116 |
|
void |
117 |
|
add_entry (int level, char *ptr) |
118 |
|
{ |
119 |
|
int i; |
120 |
|
if (nentry >= sizeof(lib_entry)/sizeof(lib_entry[0])) |
121 |
|
{ |
122 |
|
mu_error (_("Too many arguments")); |
123 |
|
exit (1); |
124 |
|
} |
125 |
|
|
126 |
|
for (i = 0; i < nentry; i++) |
127 |
|
if (strcmp (lib_entry[i].ptr, ptr) == 0) |
128 |
|
return; |
129 |
|
lib_entry[nentry].level = level; |
130 |
|
lib_entry[nentry].ptr = ptr; |
131 |
|
nentry++; |
132 |
|
} |
133 |
|
|
134 |
|
/* Sort the entires by their level. */ |
135 |
|
void |
136 |
|
sort_entries () |
137 |
|
{ |
138 |
|
int j; |
139 |
|
|
140 |
|
for (j = 0; j < nentry; j++) |
141 |
|
{ |
142 |
|
int i; |
143 |
|
|
144 |
|
for (i = j; i < nentry; i++) |
145 |
|
if (lib_entry[j].level > lib_entry[i].level) |
146 |
|
{ |
147 |
|
struct lib_entry tmp; |
148 |
|
tmp = lib_entry[i]; |
149 |
|
lib_entry[i] = lib_entry[j]; |
150 |
|
lib_entry[j] = tmp; |
151 |
|
} |
152 |
|
|
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
int |
int |
157 |
main (int argc, char **argv) |
main (int argc, char **argv) |
158 |
{ |
{ |
175 |
|
|
176 |
case MODE_LINK: |
case MODE_LINK: |
177 |
{ |
{ |
178 |
int n = 0, j; |
int j; |
179 |
struct entry { |
char *ptr; |
180 |
int level; |
|
181 |
char *ptr; |
add_entry (-1, LINK_FLAGS); |
182 |
} entry[4]; |
add_entry (1, "-lmailbox"); |
|
|
|
|
entry[n].level = 1; |
|
|
asprintf (&entry[n].ptr, "%s -lmailbox", LINK_FLAGS); |
|
|
n++; |
|
183 |
#ifdef ENABLE_NLS |
#ifdef ENABLE_NLS |
184 |
if (sizeof (I18NLIBS) > 1) |
if (sizeof (I18NLIBS) > 1) |
185 |
{ |
add_entry (10, I18NLIBS); |
|
entry[n].level = 10; |
|
|
asprintf (&entry[n].ptr, I18NLIBS); |
|
|
n++; |
|
|
} |
|
186 |
#endif |
#endif |
187 |
for (; n < sizeof(entry)/sizeof(entry[0]) && argc > 0; |
|
188 |
argc--, argv++, n++) |
for ( ; argc > 0; argc--, argv++) |
189 |
{ |
{ |
190 |
if (strcmp (argv[0], "auth") == 0) |
if (strcmp (argv[0], "auth") == 0) |
191 |
{ |
{ |
192 |
entry[n].level = 2; |
add_entry (2, "-lmuauth " AUTHLIBS); |
|
asprintf (&entry[n].ptr, "-lmuauth %s", AUTHLIBS); |
|
193 |
} |
} |
194 |
#ifdef WITH_GUILE |
#ifdef WITH_GUILE |
195 |
else if (strcmp (argv[0], "guile") == 0) |
else if (strcmp (argv[0], "guile") == 0) |
196 |
{ |
{ |
197 |
entry[n].level = -1; |
add_entry (-1, "-lmu_scm " GUILE_LIBS); |
|
asprintf (&entry[n].ptr, "-lmu_scm %s", GUILE_LIBS); |
|
198 |
} |
} |
199 |
#endif |
#endif |
200 |
|
else if (strcmp (argv[0], "all") == 0) |
201 |
|
{ |
202 |
|
struct lib_descr *p; |
203 |
|
|
204 |
|
for (p = lib_descr; p->name; p++) |
205 |
|
{ |
206 |
|
asprintf (&ptr, "-l%s", p->libname); |
207 |
|
add_entry (0, ptr); |
208 |
|
if (p->needauth) |
209 |
|
add_entry (2, "-lmuauth " AUTHLIBS); |
210 |
|
} |
211 |
|
} |
212 |
else |
else |
213 |
{ |
{ |
214 |
argp_help (&argp, stdout, ARGP_HELP_USAGE, |
struct lib_descr *p; |
215 |
program_invocation_short_name); |
|
216 |
return 1; |
for (p = lib_descr; p->name; p++) |
217 |
|
if (strcasecmp (p->name, argv[0]) == 0) |
218 |
|
break; |
219 |
|
|
220 |
|
if (p->name) |
221 |
|
{ |
222 |
|
asprintf (&ptr, "-l%s", p->libname); |
223 |
|
add_entry (0, ptr); |
224 |
|
if (p->needauth) |
225 |
|
add_entry (2, "-lmuauth " AUTHLIBS); |
226 |
|
} |
227 |
|
else |
228 |
|
{ |
229 |
|
argp_help (&argp, stdout, ARGP_HELP_USAGE, |
230 |
|
program_invocation_short_name); |
231 |
|
return 1; |
232 |
|
} |
233 |
} |
} |
234 |
} |
} |
235 |
|
|
236 |
/* Sort the entires by their level. */ |
sort_entries (); |
237 |
for (j = 0; j < n; j++) |
|
|
{ |
|
|
int i; |
|
|
|
|
|
for (i = j; i < n; i++) |
|
|
if (entry[j].level > entry[i].level) |
|
|
{ |
|
|
struct entry tmp; |
|
|
tmp = entry[i]; |
|
|
entry[i] = entry[j]; |
|
|
entry[j] = tmp; |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
238 |
/* At least one entry is always present */ |
/* At least one entry is always present */ |
239 |
printf ("%s", entry[0].ptr); |
printf ("%s", lib_entry[0].ptr); |
240 |
|
|
241 |
/* Print the rest of them separated by a space */ |
/* Print the rest of them separated by a space */ |
242 |
for (j = 1; j < n; j++) |
for (j = 1; j < nentry; j++) |
243 |
{ |
{ |
244 |
if (entry[j].level == entry[j-1].level) |
printf (" %s", lib_entry[j].ptr); |
|
continue; |
|
|
printf (" %s", entry[j].ptr); |
|
245 |
} |
} |
246 |
printf ("\n"); |
printf ("\n"); |
247 |
return 0; |
return 0; |