1###############################################################################
2# substitutions by autosetup
3
4PACKAGE=	@PACKAGE@
5PACKAGE_VERSION=@PACKAGE_VERSION@
6PACKAGE_DATE=	@PACKAGE_DATE@
7
8# Build-time compiler and flags. These are used for building executables that
9# are only used at build-time, e.g., docs/makedoc. These are different from CC /
10# CFLAGS / LDFLAGS because the host and target systems might be different.
11CC_FOR_BUILD=		@CC_FOR_BUILD@
12CFLAGS_FOR_BUILD=	@CFLAGS_FOR_BUILD@ $(EXTRA_CFLAGS_FOR_BUILD)
13LDFLAGS_FOR_BUILD=	@LDFLAGS_FOR_BUILD@ $(EXTRA_LDFLAGS_FOR_BUILD)
14
15PWD=		@PWD@
16AR=		@AR@
17CC=		@CC@
18CPP=		@CPP@
19CFLAGS=		@CPPFLAGS@ @CFLAGS@ -I. -I@srcdir@ -Wall $(EXTRA_CFLAGS)
20LDFLAGS=	@LDFLAGS@ $(EXTRA_LDFLAGS)
21EXEEXT=		@EXEEXT@
22LIBS=		@LIBS@
23@if ENABLE_NLS
24INTLLIBS=	@INTLLIBS@
25@endif
26RANLIB=		@RANLIB@
27SRCDIR=		@srcdir@
28INSTALL=	@INSTALL@ -c
29INSTALL_DATA=	@INSTALL@ -m 644
30MKDIR_P=	mkdir -p
31RM=		rm -fr
32DEPFILES=	$(ALLOBJS:.o=.Po)
33BINFILES=	$(NEOMUTT)
34@if HAVE_PGP
35LIBBINFILES+=	$(PGPEWRAP)
36@endif
37@if HAVE_SMIME
38LIBBINFILES+=	$(SRCDIR)/contrib/smime_keys
39@endif
40
41# paths
42bindir=		@BINDIR@
43datadir=	@PKGDATADIR@
44docdir=		@PKGDOCDIR@
45mandir=		@mandir@
46libexecdir=	@libexecdir@
47sysconfdir=	@SYSCONFDIR@
48textdomaindir=	@MUTTLOCALEDIR@
49
50# targets for specific subdirectories
51ALL_TARGETS=		@ALL_TARGETS@
52CLEAN_TARGETS=		@CLEAN_TARGETS@
53INSTALL_TARGETS=	@INSTALL_TARGETS@
54UNINSTALL_TARGETS=	@UNINSTALL_TARGETS@
55
56VPATH=		@VPATH@
57
58ALL_FILES!=	(cd $(SRCDIR) && git ls-files 2>/dev/null) || true
59
60default:	all
61
62###############################################################################
63# neomutt
64NEOMUTT=	neomutt$(EXEEXT)
65NEOMUTTOBJS=	alternates.o browser.o commands.o command_parse.o \
66		complete.o conststrings.o context.o copy.o dlg_postpone.o \
67		editmsg.o enriched.o enter.o flags.o functions.o git_ver.o \
68		handler.o hdrline.o help.o hook.o icommands.o init.o \
69		keymap.o mailcap.o maillist.o main.o muttlib.o mutt_account.o \
70		mutt_body.o mutt_commands.o mutt_config.o \
71		mutt_header.o mutt_history.o mutt_logging.o mutt_mailbox.o \
72		mutt_signal.o mutt_socket.o mutt_thread.o mx.o \
73		myvar.o opcodes.o postpone.o \
74		recvcmd.o resize.o rfc3676.o score.o \
75		sort.o status.o subjectrx.o system.o version.o
76
77@if !HAVE_WCSCASECMP
78NEOMUTTOBJS+=	wcscasecmp.o
79@endif
80@if MIXMASTER
81NEOMUTTOBJS+=	remailer.o
82@endif
83@if USE_LUA
84NEOMUTTOBJS+=	mutt_lua.o
85@endif
86@if USE_INOTIFY
87NEOMUTTOBJS+=	monitor.o
88@endif
89
90CLEANFILES+=	$(NEOMUTT) $(NEOMUTTOBJS)
91ALLOBJS+=	$(NEOMUTTOBJS)
92
93###############################################################################
94# libaddress
95LIBADDRESS=	libaddress.a
96LIBADDRESSOBJS=	address/address.o address/group.o address/idna.o
97CLEANFILES+=	$(LIBADDRESS) $(LIBADDRESSOBJS)
98ALLOBJS+=	$(LIBADDRESSOBJS)
99
100$(LIBADDRESS): $(PWD)/address $(LIBADDRESSOBJS)
101	$(AR) cr $@ $(LIBADDRESSOBJS)
102	$(RANLIB) $@
103$(PWD)/address:
104	$(MKDIR_P) $(PWD)/address
105
106###############################################################################
107# libalias
108LIBALIAS=	libalias.a
109LIBALIASOBJS=	alias/alias.o alias/array.o alias/commands.o alias/config.o \
110		alias/dlgalias.o alias/dlgquery.o alias/gui.o alias/reverse.o \
111		alias/sort.o
112CLEANFILES+=	$(LIBALIAS) $(LIBALIASOBJS)
113ALLOBJS+=	$(LIBALIASOBJS)
114
115$(LIBALIAS): $(PWD)/alias $(LIBALIASOBJS)
116	$(AR) cr $@ $(LIBALIASOBJS)
117	$(RANLIB) $@
118$(PWD)/alias:
119	$(MKDIR_P) $(PWD)/alias
120
121###############################################################################
122# libattach
123LIBATTACH=	libattach.a
124LIBATTACHOBJS=	attach/attachments.o attach/dlg_attach.o attach/mutt_attach.o \
125		attach/recvattach.o
126CLEANFILES+=	$(LIBATTACH) $(LIBATTACHOBJS)
127ALLOBJS+=	$(LIBATTACHOBJS)
128
129$(LIBATTACH): $(PWD)/attach $(LIBATTACHOBJS)
130	$(AR) cr $@ $(LIBATTACHOBJS)
131	$(RANLIB) $@
132$(PWD)/attach:
133	$(MKDIR_P) $(PWD)/attach
134
135###############################################################################
136# libautocrypt
137@if USE_AUTOCRYPT
138LIBAUTOCRYPT=	libautocrypt.a
139LIBAUTOCRYPTOBJS=autocrypt/autocrypt.o autocrypt/dlgautocrypt.o \
140		 autocrypt/config.o autocrypt/db.o autocrypt/gpgme.o \
141		 autocrypt/schema.o
142CLEANFILES+=	$(LIBAUTOCRYPT) $(LIBAUTOCRYPTOBJS)
143ALLOBJS+=	$(LIBAUTOCRYPTOBJS)
144
145$(LIBAUTOCRYPT): $(PWD)/autocrypt $(LIBAUTOCRYPTOBJS)
146	$(AR) cr $@ $(LIBAUTOCRYPTOBJS)
147	$(RANLIB) $@
148$(PWD)/autocrypt:
149	$(MKDIR_P) $(PWD)/autocrypt
150@endif
151
152###############################################################################
153# libbcache
154LIBBCACHE=	libbcache.a
155LIBBCACHEOBJS=	bcache/bcache.o
156CLEANFILES+=	$(LIBBCACHE) $(LIBBCACHEOBJS)
157ALLOBJS+=	$(LIBBCACHEOBJS)
158
159$(LIBBCACHE): $(PWD)/bcache $(LIBBCACHEOBJS)
160	$(AR) cr $@ $(LIBBCACHEOBJS)
161	$(RANLIB) $@
162$(PWD)/bcache:
163	$(MKDIR_P) $(PWD)/bcache
164
165###############################################################################
166# libcolor
167LIBCOLOR=	libcolor.a
168LIBCOLOROBJS=	color/color.o color/command.o color/notify.o color/quoted.o \
169		color/regex.o color/simple.o
170CLEANFILES+=	$(LIBCOLOR) $(LIBCOLOROBJS)
171ALLOBJS+=	$(LIBCOLOROBJS)
172
173$(LIBCOLOR):	$(PWD)/color $(LIBCOLOROBJS)
174	$(AR) cr $@ $(LIBCOLOROBJS)
175	$(RANLIB) $@
176$(PWD)/color:
177	$(MKDIR_P) $(PWD)/color
178
179###############################################################################
180# libcompmbox
181LIBCOMPMBOX=	libcompmbox.a
182LIBCOMPMBOXOBJS=compmbox/compress.o
183CLEANFILES+=	$(LIBCOMPMBOX) $(LIBCOMPMBOXOBJS)
184ALLOBJS+=	$(LIBCOMPMBOXOBJS)
185
186$(LIBCOMPMBOX): $(PWD)/compmbox $(LIBCOMPMBOXOBJS)
187	$(AR) cr $@ $(LIBCOMPMBOXOBJS)
188	$(RANLIB) $@
189$(PWD)/compmbox:
190	$(MKDIR_P) $(PWD)/compmbox
191
192###############################################################################
193# libcompose
194LIBCOMPOSE=	libcompose.a
195LIBCOMPOSEOBJS=	compose/attach.o compose/attach_data.o compose/cbar.o \
196		compose/cbar_data.o compose/compose.o compose/config.o \
197		compose/env_data.o compose/envelope.o compose/functions.o \
198		compose/shared_data.o
199
200CLEANFILES+=	$(LIBCOMPOSE) $(LIBCOMPOSEOBJS)
201ALLOBJS+=	$(LIBCOMPOSEOBJS)
202
203$(LIBCOMPOSE): $(PWD)/compose $(LIBCOMPOSEOBJS)
204	$(AR) cr $@ $(LIBCOMPOSEOBJS)
205	$(RANLIB) $@
206$(PWD)/compose:
207	$(MKDIR_P) $(PWD)/compose
208
209###############################################################################
210# libcompress
211@if USE_LZ4
212LIBCOMPRESSOBJS+=compress/lz4.o
213@endif
214@if USE_ZLIB
215LIBCOMPRESSOBJS+=compress/zlib.o
216@endif
217@if USE_ZSTD
218LIBCOMPRESSOBJS+=compress/zstd.o
219@endif
220@if USE_LZ4 || USE_ZLIB || USE_ZSTD
221LIBCOMPRESSOBJS+=compress/compress.o
222LIBCOMPRESS=	libcompress.a
223CLEANFILES+=	$(LIBCOMPRESS) $(LIBCOMPRESSOBJS)
224ALLOBJS+=	$(LIBCOMPRESSOBJS)
225
226$(LIBCOMPRESS): $(PWD)/compress $(LIBCOMPRESSOBJS)
227	$(AR) cr $@ $(LIBCOMPRESSOBJS)
228	$(RANLIB) $@
229$(PWD)/compress:
230	$(MKDIR_P) $(PWD)/compress
231@endif
232
233###############################################################################
234# libconfig
235LIBCONFIG=	libconfig.a
236LIBCONFIGOBJS=	config/address.o config/bool.o config/charset.o config/dump.o \
237		config/enum.o config/helpers.o \
238		config/long.o config/mbtable.o config/number.o config/path.o config/quad.o \
239		config/regex.o config/set.o config/slist.o config/sort.o \
240		config/string.o config/subset.o
241CLEANFILES+=	$(LIBCONFIG) $(LIBCONFIGOBJS)
242ALLOBJS+=	$(LIBCONFIGOBJS)
243
244$(LIBCONFIG): $(PWD)/config $(LIBCONFIGOBJS)
245	$(AR) cr $@ $(LIBCONFIGOBJS)
246	$(RANLIB) $@
247$(PWD)/config:
248	$(MKDIR_P) $(PWD)/config
249
250###############################################################################
251# libconn
252LIBCONN=	libconn.a
253LIBCONNOBJS=	conn/config.o conn/connaccount.o conn/getdomain.o conn/raw.o \
254		conn/sasl_plain.o conn/socket.o conn/tunnel.o
255@if HAVE_SASL
256LIBCONNOBJS+=	conn/sasl.o
257@endif
258@if USE_SSL
259LIBCONNOBJS+=	conn/dlgverifycert.o
260@endif
261@if USE_SSL_GNUTLS
262LIBCONNOBJS+=	conn/gnutls.o
263@endif
264@if USE_SSL_OPENSSL
265LIBCONNOBJS+=	conn/openssl.o
266@endif
267@if USE_ZLIB
268LIBCONNOBJS+=	conn/zstrm.o
269@endif
270CLEANFILES+=	$(LIBCONN) $(LIBCONNOBJS)
271ALLOBJS+=	$(LIBCONNOBJS)
272
273$(LIBCONN): $(PWD)/conn $(LIBCONNOBJS)
274	$(AR) cr $@ $(LIBCONNOBJS)
275	$(RANLIB) $@
276$(PWD)/conn:
277	$(MKDIR_P) $(PWD)/conn
278
279###############################################################################
280# libcore
281LIBCORE=	libcore.a
282LIBCOREOBJS=	core/account.o core/mailbox.o core/neomutt.o
283CLEANFILES+=	$(LIBCORE) $(LIBCOREOBJS)
284ALLOBJS+=	$(LIBCOREOBJS)
285
286$(LIBCORE): $(PWD)/core $(LIBCOREOBJS)
287	$(AR) cr $@ $(LIBCOREOBJS)
288	$(RANLIB) $@
289$(PWD)/core:
290	$(MKDIR_P) $(PWD)/core
291
292###############################################################################
293# libdebug
294@if HAVE_LIBUNWIND
295LIBDEBUGOBJS+=	debug/backtrace.o
296@endif
297@if USE_DEBUG_EMAIL
298LIBDEBUGOBJS+=	debug/email.o
299@endif
300@if USE_DEBUG_GRAPHVIZ
301LIBDEBUGOBJS+=	debug/graphviz.o
302@endif
303@if USE_DEBUG_NOTIFY
304LIBDEBUGOBJS+=	debug/notify.o
305@endif
306@if USE_DEBUG_PARSE_TEST
307LIBDEBUGOBJS+=	debug/parse_test.o
308@endif
309@if USE_DEBUG_WINDOW
310LIBDEBUGOBJS+=	debug/window.o
311@endif
312@if HAVE_LIBUNWIND || USE_DEBUG_GRAPHVIZ || USE_DEBUG_NOTIFY || USE_DEBUG_PARSE_TEST || USE_DEBUG_WINDOW
313LIBDEBUG=	libdebug.a
314CLEANFILES+=	$(LIBDEBUG) $(LIBDEBUGOBJS)
315ALLOBJS+=	$(LIBDEBUGOBJS)
316
317$(LIBDEBUG): $(PWD)/debug $(LIBDEBUGOBJS)
318	$(AR) cr $@ $(LIBDEBUGOBJS)
319	$(RANLIB) $@
320$(PWD)/debug:
321	$(MKDIR_P) $(PWD)/debug
322@endif
323
324###############################################################################
325# libemail
326LIBEMAIL=	libemail.a
327LIBEMAILOBJS=	email/attach.o email/body.o email/email.o email/envelope.o \
328		email/from.o email/globals.o email/mime.o email/parameter.o \
329		email/parse.o email/rfc2047.o email/rfc2231.o email/tags.o \
330		email/thread.o email/url.o
331CLEANFILES+=	$(LIBEMAIL) $(LIBEMAILOBJS)
332ALLOBJS+=	$(LIBEMAILOBJS)
333
334$(LIBEMAIL): $(PWD)/email $(LIBEMAILOBJS)
335	$(AR) cr $@ $(LIBEMAILOBJS)
336	$(RANLIB) $@
337$(PWD)/email:
338	$(MKDIR_P) $(PWD)/email
339
340###############################################################################
341# libgui
342LIBGUI=		libgui.a
343LIBGUIOBJS=	gui/curs_lib.o gui/dialog.o gui/msgwin.o gui/mutt_curses.o \
344		gui/mutt_window.o gui/reflow.o gui/rootwin.o gui/sbar.o \
345		gui/simple.o gui/terminal.o
346CLEANFILES+=	$(LIBGUI) $(LIBGUIOBJS)
347ALLOBJS+=	$(LIBGUIOBJS)
348
349$(LIBGUI): $(PWD)/gui $(LIBGUIOBJS)
350	$(AR) cr $@ $(LIBGUIOBJS)
351	$(RANLIB) $@
352$(PWD)/gui:
353	$(MKDIR_P) $(PWD)/gui
354
355###############################################################################
356# libhcache
357@if USE_HCACHE
358LIBHCACHE=	libhcache.a
359LIBHCACHEOBJS=	hcache/config.o hcache/hcache.o hcache/serialize.o
360CLEANFILES+=	$(LIBHCACHE) $(LIBHCACHEOBJS)
361ALLOBJS+=	$(LIBHCACHEOBJS)
362
363hcache/hcache.o:	hcache/hcversion.h
364$(LIBHCACHE): $(PWD)/hcache $(LIBHCACHEOBJS)
365	$(AR) cr $@ $(LIBHCACHEOBJS)
366	$(RANLIB) $@
367$(PWD)/hcache:
368	$(MKDIR_P) $(PWD)/hcache
369@endif
370
371###############################################################################
372# libhelpbar
373LIBHELPBAR=	libhelpbar.a
374LIBHELPBAROBJS=	helpbar/config.o helpbar/helpbar.o helpbar/wdata.o
375CLEANFILES+=	$(LIBHELPBAR) $(LIBHELPBAROBJS)
376ALLOBJS+=	$(LIBHELPBAROBJS)
377
378$(LIBHELPBAR): $(PWD)/helpbar $(LIBHELPBAROBJS)
379	$(AR) cr $@ $(LIBHELPBAROBJS)
380	$(RANLIB) $@
381$(PWD)/helpbar:
382	$(MKDIR_P) $(PWD)/helpbar
383
384###############################################################################
385# libhistory
386LIBHISTORY=	libhistory.a
387LIBHISTORYOBJS=	history/config.o history/dlghistory.o history/history.o
388CLEANFILES+=	$(LIBHISTORY) $(LIBHISTORYOBJS)
389ALLOBJS+=	$(LIBHISTORYOBJS)
390
391$(LIBHISTORY): $(PWD)/history $(LIBHISTORYOBJS)
392	$(AR) cr $@ $(LIBHISTORYOBJS)
393	$(RANLIB) $@
394$(PWD)/history:
395	$(MKDIR_P) $(PWD)/history
396
397###############################################################################
398# libimap
399LIBIMAP=	libimap.a
400LIBIMAPOBJS=	imap/auth.o imap/auth_login.o imap/auth_oauth.o \
401		imap/auth_plain.o imap/browse.o imap/command.o imap/config.o \
402		imap/imap.o imap/message.o imap/msn.o imap/search.o \
403		imap/adata.o imap/edata.o imap/mdata.o imap/utf7.o imap/util.o
404@if USE_GSS
405LIBIMAPOBJS+=	imap/auth_gss.o
406@endif
407@if HAVE_SASL
408LIBIMAPOBJS+=	imap/auth_sasl.o
409@else
410LIBIMAPOBJS+=	imap/auth_anon.o imap/auth_cram.o
411@endif
412CLEANFILES+=	$(LIBIMAP) $(LIBIMAPOBJS)
413ALLOBJS+=	$(LIBIMAPOBJS)
414
415$(LIBIMAP): $(PWD)/imap $(LIBIMAPOBJS)
416	$(AR) cr $@ $(LIBIMAPOBJS)
417	$(RANLIB) $@
418$(PWD)/imap:
419	$(MKDIR_P) $(PWD)/imap
420
421###############################################################################
422# libindex
423LIBINDEX=	libindex.a
424LIBINDEXOBJS=	index/config.o index/dlg_index.o index/functions.o \
425		index/ibar.o index/index.o index/ipanel.o index/private_data.o \
426		index/shared_data.o
427CLEANFILES+=	$(LIBINDEX) $(LIBINDEXOBJS)
428ALLOBJS+=	$(LIBINDEXOBJS)
429
430$(LIBINDEX): $(PWD)/index $(LIBINDEXOBJS)
431	$(AR) cr $@ $(LIBINDEXOBJS)
432	$(RANLIB) $@
433$(PWD)/index:
434	$(MKDIR_P) $(PWD)/index
435
436###############################################################################
437# libmaildir
438LIBMAILDIR=	libmaildir.a
439LIBMAILDIROBJS=	maildir/config.o maildir/edata.o maildir/maildir.o \
440		maildir/mdata.o maildir/mdemail.o maildir/mh.o \
441		maildir/sequence.o maildir/shared.o
442CLEANFILES+=	$(LIBMAILDIR) $(LIBMAILDIROBJS)
443ALLOBJS+=	$(LIBMAILDIROBJS)
444
445$(LIBMAILDIR): $(PWD)/maildir $(LIBMAILDIROBJS)
446	$(AR) cr $@ $(LIBMAILDIROBJS)
447	$(RANLIB) $@
448$(PWD)/maildir:
449	$(MKDIR_P) $(PWD)/maildir
450
451###############################################################################
452# libmbox
453LIBMBOX=	libmbox.a
454LIBMBOXOBJS=	mbox/config.o mbox/mbox.o
455CLEANFILES+=	$(LIBMBOX) $(LIBMBOXOBJS)
456ALLOBJS+=	$(LIBMBOXOBJS)
457
458$(LIBMBOX): $(PWD)/mbox $(LIBMBOXOBJS)
459	$(AR) cr $@ $(LIBMBOXOBJS)
460	$(RANLIB) $@
461$(PWD)/mbox:
462	$(MKDIR_P) $(PWD)/mbox
463
464###############################################################################
465# libmenu
466LIBMENU=	libmenu.a
467LIBMENUOBJS=	menu/config.o menu/draw.o menu/menu.o menu/move.o \
468		menu/observer.o menu/type.o menu/window.o
469CLEANFILES+=	$(LIBMENU) $(LIBMENUOBJS)
470ALLOBJS+=	$(LIBMENUOBJS)
471
472$(LIBMENU): $(PWD)/menu $(LIBMENUOBJS)
473	$(AR) cr $@ $(LIBMENUOBJS)
474	$(RANLIB) $@
475$(PWD)/menu:
476	$(MKDIR_P) $(PWD)/menu
477
478###############################################################################
479# libmutt
480LIBMUTT=	libmutt.a
481LIBMUTTOBJS=	mutt/base64.o mutt/buffer.o mutt/charset.o mutt/date.o \
482		mutt/envlist.o mutt/exit.o mutt/file.o mutt/filter.o \
483		mutt/hash.o mutt/list.o mutt/logging.o mutt/mapping.o \
484		mutt/mbyte.o mutt/md5.o mutt/memory.o mutt/notify.o \
485		mutt/path.o mutt/pool.o mutt/prex.o mutt/qsort_r.o mutt/random.o \
486		mutt/regex.o mutt/signal.o mutt/slist.o mutt/state.o mutt/string.o
487CLEANFILES+=	$(LIBMUTT) $(LIBMUTTOBJS)
488ALLOBJS+=	$(LIBMUTTOBJS)
489
490$(LIBMUTT): $(PWD)/mutt $(LIBMUTTOBJS)
491	$(AR) cr $@ $(LIBMUTTOBJS)
492	$(RANLIB) $@
493$(PWD)/mutt:
494	$(MKDIR_P) $(PWD)/mutt
495
496###############################################################################
497# libncrypt
498LIBNCRYPT=	libncrypt.a
499LIBNCRYPTOBJS=	ncrypt/config.o ncrypt/crypt.o ncrypt/cryptglue.o \
500		ncrypt/crypt_mod.o
501@if HAVE_GPGME
502LIBNCRYPTOBJS+=	ncrypt/crypt_gpgme.o ncrypt/dlggpgme.o ncrypt/crypt_mod_pgp_gpgme.o \
503		ncrypt/crypt_mod_smime_gpgme.o
504@endif
505@if HAVE_PGP
506LIBNCRYPTOBJS+=	ncrypt/crypt_mod_pgp_classic.o ncrypt/dlgpgp.o ncrypt/gnupgparse.o \
507		ncrypt/pgp.o ncrypt/pgpinvoke.o ncrypt/pgpkey.o ncrypt/pgplib.o \
508		ncrypt/pgpmicalg.o ncrypt/pgppacket.o
509@endif
510@if HAVE_SMIME
511LIBNCRYPTOBJS+=	ncrypt/crypt_mod_smime_classic.o ncrypt/dlgsmime.o ncrypt/smime.o
512@endif
513CLEANFILES+=	$(LIBNCRYPT) $(LIBNCRYPTOBJS)
514ALLOBJS+=	$(LIBNCRYPTOBJS)
515
516$(LIBNCRYPT): $(PWD)/ncrypt $(LIBNCRYPTOBJS)
517	$(AR) cr $@ $(LIBNCRYPTOBJS)
518	$(RANLIB) $@
519$(PWD)/ncrypt:
520	$(MKDIR_P) $(PWD)/ncrypt
521
522###############################################################################
523# libnntp
524LIBNNTP=	libnntp.a
525LIBNNTPOBJS=	nntp/browse.o nntp/config.o nntp/complete.o nntp/newsrc.o \
526		nntp/nntp.o nntp/adata.o nntp/edata.o nntp/mdata.o
527CLEANFILES+=	$(LIBNNTP) $(LIBNNTPOBJS)
528ALLOBJS+=	$(LIBNNTPOBJS)
529
530$(LIBNNTP): $(PWD)/nntp $(LIBNNTPOBJS)
531	$(AR) cr $@ $(LIBNNTPOBJS)
532	$(RANLIB) $@
533$(PWD)/nntp:
534	$(MKDIR_P) $(PWD)/nntp
535
536###############################################################################
537# libnotmuch
538@if USE_NOTMUCH
539LIBNOTMUCH=	libnotmuch.a
540LIBNOTMUCHOBJS=	notmuch/config.o notmuch/db.o notmuch/notmuch.o \
541		notmuch/adata.o notmuch/edata.o notmuch/mdata.o \
542		notmuch/query.o notmuch/tag.o
543CLEANFILES+=	$(LIBNOTMUCH) $(LIBNOTMUCHOBJS)
544ALLOBJS+=	$(LIBNOTMUCHOBJS)
545
546$(LIBNOTMUCH): $(PWD)/notmuch $(LIBNOTMUCHOBJS)
547	$(AR) cr $@ $(LIBNOTMUCHOBJS)
548	$(RANLIB) $@
549$(PWD)/notmuch:
550	$(MKDIR_P) $(PWD)/notmuch
551@endif
552
553###############################################################################
554# libpager
555LIBPAGER=	libpager.a
556LIBPAGEROBJS=	pager/config.o pager/display.o pager/dlg_pager.o pager/do_pager.o \
557		pager/functions.o pager/message.o pager/pager.o pager/pbar.o pager/ppanel.o \
558		pager/private_data.o
559CLEANFILES+=	$(LIBPAGER) $(LIBPAGEROBJS)
560ALLOBJS+=	$(LIBPAGEROBJS)
561
562$(LIBPAGER): $(PWD)/pager $(LIBPAGEROBJS)
563	$(AR) cr $@ $(LIBPAGEROBJS)
564	$(RANLIB) $@
565$(PWD)/pager:
566	$(MKDIR_P) $(PWD)/pager
567
568###############################################################################
569# libpattern
570LIBPATTERN=	libpattern.a
571LIBPATTERNOBJS=	pattern/compile.o pattern/config.o pattern/dlgpattern.o \
572		pattern/exec.o pattern/flags.o pattern/pattern.o
573CLEANFILES+=	$(LIBPATTERN) $(LIBPATTERNOBJS)
574ALLOBJS+=	$(LIBPATTERNOBJS)
575
576$(LIBPATTERN): $(PWD)/pattern $(LIBPATTERNOBJS)
577	$(AR) cr $@ $(LIBPATTERNOBJS)
578	$(RANLIB) $@
579$(PWD)/pattern:
580	$(MKDIR_P) $(PWD)/pattern
581
582###############################################################################
583# libpop
584LIBPOP=		libpop.a
585LIBPOPOBJS=	pop/auth.o pop/config.o pop/lib.o pop/pop.o \
586		pop/adata.o pop/edata.o
587CLEANFILES+=	$(LIBPOP) $(LIBPOPOBJS)
588ALLOBJS+=	$(LIBPOPOBJS)
589
590$(LIBPOP): $(PWD)/pop $(LIBPOPOBJS)
591	$(AR) cr $@ $(LIBPOPOBJS)
592	$(RANLIB) $@
593$(PWD)/pop:
594	$(MKDIR_P) $(PWD)/pop
595
596###############################################################################
597# libprogress
598LIBPROGRESS=	libprogress.a
599LIBPROGRESSOBJS=progress/progress.o
600CLEANFILES+=	$(LIBPROGRESS) $(LIBPROGRESSOBJS)
601ALLOBJS+=	$(LIBPROGRESSOBJS)
602
603$(LIBPROGRESS): $(PWD)/progress $(LIBPROGRESSOBJS)
604	$(AR) cr $@ $(LIBPROGRESSOBJS)
605	$(RANLIB) $@
606$(PWD)/progress:
607	$(MKDIR_P) $(PWD)/progress
608
609###############################################################################
610# libquestion
611LIBQUESTION=	libquestion.a
612LIBQUESTIONOBJS=question/question.o
613CLEANFILES+=	$(LIBQUESTION) $(LIBQUESTIONOBJS)
614ALLOBJS+=	$(LIBQUESTIONOBJS)
615
616$(LIBQUESTION): $(PWD)/question $(LIBQUESTIONOBJS)
617	$(AR) cr $@ $(LIBQUESTIONOBJS)
618	$(RANLIB) $@
619$(PWD)/question:
620	$(MKDIR_P) $(PWD)/question
621
622###############################################################################
623# libsend
624LIBSEND=	libsend.a
625LIBSENDOBJS=	send/body.o send/config.o send/header.o send/multipart.o send/send.o send/sendlib.o send/sendmail.o send/smtp.o
626CLEANFILES+=	$(LIBSEND) $(LIBSENDOBJS)
627ALLOBJS+=	$(LIBSENDOBJS)
628
629$(LIBSEND): $(PWD)/send $(LIBSENDOBJS)
630	$(AR) cr $@ $(LIBSENDOBJS)
631	$(RANLIB) $@
632$(PWD)/send:
633	$(MKDIR_P) $(PWD)/send
634
635###############################################################################
636# libsidebar
637@if USE_SIDEBAR
638LIBSIDEBAR=	libsidebar.a
639LIBSIDEBAROBJS=	sidebar/config.o sidebar/sidebar.o sidebar/commands.o \
640		sidebar/functions.o sidebar/observer.o sidebar/sort.o \
641		sidebar/wdata.o sidebar/window.o
642CLEANFILES+=	$(LIBSIDEBAR) $(LIBSIDEBAROBJS)
643ALLOBJS+=	$(LIBSIDEBAROBJS)
644
645$(LIBSIDEBAR): $(PWD)/sidebar $(LIBSIDEBAROBJS)
646	$(AR) cr $@ $(LIBSIDEBAROBJS)
647	$(RANLIB) $@
648$(PWD)/sidebar:
649	$(MKDIR_P) $(PWD)/sidebar
650@endif
651
652###############################################################################
653# libstore
654@if HAVE_BDB
655LIBSTOREOBJS+=	store/bdb.o
656@endif
657@if HAVE_GDBM
658LIBSTOREOBJS+=	store/gdbm.o
659@endif
660@if HAVE_KC
661LIBSTOREOBJS+=	store/kc.o
662@endif
663@if HAVE_LMDB
664LIBSTOREOBJS+=	store/lmdb.o
665@endif
666@if HAVE_QDBM
667LIBSTOREOBJS+=	store/qdbm.o
668@endif
669@if HAVE_ROCKSDB
670LIBSTOREOBJS+=	store/rocksdb.o
671@endif
672@if HAVE_TDB
673LIBSTOREOBJS+=	store/tdb.o
674@endif
675@if HAVE_TC
676LIBSTOREOBJS+=	store/tc.o
677@endif
678@if HAVE_BDB || HAVE_GDBM || HAVE_KC || HAVE_LMDB || HAVE_QDBM || HAVE_ROCKSDB || HAVE_TDB || HAVE_TC
679LIBSTORE=	libstore.a
680LIBSTOREOBJS+=	store/store.o
681CLEANFILES+=	$(LIBSTORE) $(LIBSTOREOBJS)
682ALLOBJS+=	$(LIBSTOREOBJS)
683
684$(LIBSTORE): $(PWD)/store $(LIBSTOREOBJS)
685	$(AR) cr $@ $(LIBSTOREOBJS)
686	$(RANLIB) $@
687$(PWD)/store:
688	$(MKDIR_P) $(PWD)/store
689@endif
690
691###############################################################################
692# pgpewrap
693PGPEWRAP=	pgpewrap$(EXEEXT)
694PGPEWRAPOBJS=	pgpewrap.o
695CLEANFILES+=	$(PGPEWRAP) $(PGPEWRAPOBJS)
696ALLOBJS+=	$(PGPEWRAPOBJS)
697
698$(PGPEWRAP): $(PGPEWRAPOBJS)
699	$(CC) $(LDFLAGS) -o $@ $(PGPEWRAPOBJS)
700
701##############################################################################
702# targets
703all: $(BINFILES) $(LIBBINFILES) $(ALL_TARGETS)
704
705# compile + dependencies
706.c.o:
707	$(CC) $(CFLAGS) -MT $@ -MD -MP -MF $(@:.o=.Tpo) -c -o $@ $<
708	@mv $(@:.o=.Tpo) $(@:.o=.Po)
709
710$(ALLOBJS):
711
712# The order of these libraries depends on their dependencies.
713# The libraries with the most dependencies will come first.
714MUTTLIBS+=	$(LIBINDEX) $(LIBPAGER) $(LIBAUTOCRYPT) $(LIBPOP) $(LIBNNTP) \
715		$(LIBCOMPMBOX) $(LIBSTORE) $(LIBPATTERN) $(LIBPROGRESS) \
716		$(LIBQUESTION) $(LIBMENU) $(LIBCOLOR) $(LIBGUI) $(LIBHELPBAR) \
717		$(LIBMBOX) $(LIBNOTMUCH) $(LIBATTACH) $(LIBMAILDIR) \
718		$(LIBNCRYPT) $(LIBIMAP) $(LIBCONN) $(LIBHCACHE) $(LIBCOMPRESS) \
719		$(LIBSIDEBAR) $(LIBBCACHE) $(LIBHISTORY) $(LIBALIAS) \
720		$(LIBSEND) $(LIBCOMPOSE) $(LIBCORE) $(LIBCONFIG) $(LIBEMAIL) \
721		$(LIBADDRESS) $(LIBDEBUG) $(LIBMUTT)
722
723# neomutt
724$(NEOMUTT): $(GENERATED) $(NEOMUTTOBJS) $(MUTTLIBS)
725	$(CC) -o $@ $(NEOMUTTOBJS) $(MUTTLIBS) $(LDFLAGS) $(LIBS)
726
727# clean
728clean: $(CLEAN_TARGETS)
729	rm -f $(CLEANFILES)
730
731# install
732install: all $(INSTALL_TARGETS)
733	# Install binaries
734	$(MKDIR_P) $(DESTDIR)$(bindir)
735	for f in $(BINFILES); do \
736		$(INSTALL) $$f $(DESTDIR)$(bindir)/`basename $$f` || exit 1; \
737	done
738	$(MKDIR_P) $(DESTDIR)$(libexecdir)/$(PACKAGE)
739	for f in $(LIBBINFILES); do \
740		$(INSTALL) $$f $(DESTDIR)$(libexecdir)/$(PACKAGE)/`basename $$f` || exit 1; \
741	done
742
743# uninstall
744uninstall: $(UNINSTALL_TARGETS)
745	# Uninstall binaries
746	for f in $(BINFILES); do \
747		$(RM) $(DESTDIR)$(bindir)/`basename $$f`; \
748	done
749	for f in $(LIBBINFILES); do \
750		$(RM) $(DESTDIR)$(libexecdir)/$(PACKAGE)/`basename $$f`; \
751	done
752
753# distclean
754distclean: clean
755	$(RM) $(DEPFILES) autosetup/jimsh0 config.h config.log conststrings.c \
756		contrib/Makefile docs/Makefile docs/neomutt.1 html Makefile po/Makefile \
757		test/Makefile .clang_complete
758	$(RM) *.gc?? */*.gc?? test/*/*.gc??
759	$(RM) *.expand */*.expand test/*/*.expand
760	$(RM) compile_commands.*
761	$(RM) coverage.info coverage
762
763###############################################################################
764# generated
765GENERATED=	git_ver.c hcache/hcversion.h
766CLEANFILES+=	$(GENERATED)
767
768git_ver.c: $(ALL_FILES)
769	version=`git describe --dirty --abbrev=6 --match "20[0-9][0-9][0-9][0-9][0-9][0-9]" 2> /dev/null | \
770		sed -e 's/^[0-9]\{8\}//; s/-g\([a-z0-9]\{6\}\)/-\1/'`; \
771	echo 'const char *GitVer = "'$$version'";' > $@.tmp; \
772	cmp -s $@.tmp $@ || mv $@.tmp $@; \
773	rm -f $@.tmp
774
775hcache/hcversion.h:	$(SRCDIR)/address/address.h $(SRCDIR)/email/body.h \
776			$(SRCDIR)/email/email.h $(SRCDIR)/email/envelope.h \
777			$(SRCDIR)/email/parameter.h $(SRCDIR)/hcache/hcachever.sh \
778			$(SRCDIR)/mutt/buffer.h $(SRCDIR)/mutt/list.h
779	$(MKDIR_P) $(PWD)/hcache
780	( echo '#include "config.h"'; \
781	echo '#include "address/address.h"'; \
782	echo '#include "email/body.h"'; \
783	echo '#include "email/email.h"'; \
784	echo '#include "email/envelope.h"'; \
785	echo '#include "email/parameter.h"'; \
786	echo '#include "mutt/buffer.h"'; \
787	echo '#include "mutt/list.h"';) | $(CPP) $(CFLAGS) - | \
788	sh $(SRCDIR)/hcache/hcachever.sh hcache/hcversion.h
789
790###############################################################################
791# coverage
792@if ENABLE_COVERAGE
793coverage: all test
794	$(RM) coverage
795	$(RM) mutt/exit.gc??
796	lcov --test-name "test" --output-file coverage.info --capture \
797	  --directory address \
798	  --directory compress \
799	  --directory config \
800	  --directory core \
801	  --directory email \
802	  --directory mutt \
803	  --directory notmuch \
804	  --directory store
805	-genhtml --output-directory coverage --frames coverage.info
806	lcov --list coverage.info
807@endif
808
809##############################################################################
810# include generated dependency files
811-include $(DEPFILES)
812
813##############################################################################
814# include special-purpose makefiles, each one of which MUST define the
815# dedicated all-, clean-, install-, and uninstall- targets.
816@include @srcdir@/po/Makefile.autosetup
817@include @srcdir@/contrib/Makefile.autosetup
818@include @srcdir@/docs/Makefile.autosetup
819@if ENABLE_UNIT_TESTS
820@include @srcdir@/test/Makefile.autosetup
821@endif
822
823# vim: set ts=8 noexpandtab:
824