]> git.notmuchmail.org Git - notmuch/blob - lib/Makefile.local
Merge tag '0.18.2'
[notmuch] / lib / Makefile.local
1 # -*- makefile -*-
2
3 # The major version of the library interface. This will control the soname.
4 # As such, this number must be incremented for any incompatible change to
5 # the library interface, (such as the deletion of an API or a major
6 # semantic change that breaks formerly functioning code).
7 #
8 LIBNOTMUCH_VERSION_MAJOR = 4
9
10 # The minor version of the library interface. This should be incremented at
11 # the time of release for any additions to the library interface,
12 # (and when it is incremented, the release version of the library should
13 #  be reset to 0).
14 LIBNOTMUCH_VERSION_MINOR = 1
15
16 # The release version the library interface. This should be incremented at
17 # the time of release if there have been no changes to the interface, (but
18 # simply compatible changes to the implementation).
19 LIBNOTMUCH_VERSION_RELEASE = 0
20
21 # Note: Don't forget to change the VERSION macros in notmuch.h when
22 # any of the above change.
23
24 ifeq ($(PLATFORM),MACOSX)
25 LIBRARY_SUFFIX = dylib
26 # On OS X, library version numbers go before suffix.
27 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
28 SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
29 LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
30 LIBRARY_LINK_FLAG = -dynamiclib -install_name $(SONAME) -compatibility_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR) -current_version $(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
31 else
32 LIBRARY_SUFFIX = so
33 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
34 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
35 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
36 LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) -Wl,--no-undefined
37 ifeq ($(PLATFORM),OPENBSD)
38 LIBRARY_LINK_FLAG += -lc
39 endif
40 ifeq ($(LIBDIR_IN_LDCONFIG),1)
41 ifeq ($(DESTDIR),)
42 LIBRARY_INSTALL_POST_COMMAND=ldconfig
43 endif
44 endif
45 endif
46
47 dir := lib
48 extra_cflags += -I$(srcdir)/$(dir) -fPIC
49
50 # The (often-reused) $dir works fine within targets/prerequisites,
51 # but cannot be used reliably within commands, so copy its value to a
52 # variable that is not reused.
53 lib := $(dir)
54
55 libnotmuch_c_srcs =             \
56         $(notmuch_compat_srcs)  \
57         $(dir)/filenames.c      \
58         $(dir)/string-list.c    \
59         $(dir)/libsha1.c        \
60         $(dir)/message-file.c   \
61         $(dir)/messages.c       \
62         $(dir)/sha1.c           \
63         $(dir)/tags.c
64
65 libnotmuch_cxx_srcs =           \
66         $(dir)/database.cc      \
67         $(dir)/parse-time-vrp.cc        \
68         $(dir)/directory.cc     \
69         $(dir)/index.cc         \
70         $(dir)/message.cc       \
71         $(dir)/query.cc         \
72         $(dir)/thread.cc
73
74 libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
75
76 $(dir)/libnotmuch.a: $(libnotmuch_modules)
77         $(call quiet,AR) rcs $@ $^
78
79 $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym util/libutil.a parse-time-string/libparse-time-string.a
80         $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ util/libutil.a parse-time-string/libparse-time-string.a
81
82 notmuch.sym: $(srcdir)/$(dir)/notmuch.h $(libnotmuch_modules)
83         sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
84
85 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
86         ln -sf $(LIBNAME) $@
87
88 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
89         ln -sf $(LIBNAME) $@
90
91 install: install-$(dir)
92
93 install-$(dir): $(dir)/$(LIBNAME)
94         mkdir -p "$(DESTDIR)$(libdir)/"
95         install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
96         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
97         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
98         mkdir -p "$(DESTDIR)$(includedir)"
99         install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
100         $(LIBRARY_INSTALL_POST_COMMAND)
101
102 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
103 CLEAN += $(libnotmuch_modules) $(dir)/$(SONAME) $(dir)/$(LINKER_NAME)
104 CLEAN += $(dir)/$(LIBNAME) $(dir)/libnotmuch.a notmuch.sym
105 CLEAN += $(dir)/notmuch.h.gch