]> git.notmuchmail.org Git - notmuch/blob - lib/Makefile.local
3d7de5caffa6516332ded9f46203e354c67371cf
[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 # Note: We don't currently have plans to increment this at this time.
9 # If we *do* want to make an incompatible change to the library
10 # interface, we'll have to decide whether to increment this (creating
11 # a new soname) or to introduce symbol versioning to be able to
12 # provide support for both old and new interfaces without having to
13 # increment this.
14 LIBNOTMUCH_VERSION_MAJOR = 1
15
16 # The minor version of the library interface. This should be incremented at
17 # the time of release for any additions to the library interface.
18 LIBNOTMUCH_VERSION_MINOR = 2
19
20 # The release version the library interface. This should be incremented at
21 # the time of release if there have been no changes to the interface, (but
22 # simply compatible changes to the implementation).
23 LIBNOTMUCH_VERSION_RELEASE = 0
24
25 ifeq ($(PLATFORM),MACOSX)
26 LIBRARY_SUFFIX = dylib
27 # On OS X, library version numbers go before suffix.
28 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
29 SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
30 LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
31 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)
32 else
33 LIBRARY_SUFFIX = so
34 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
35 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
36 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
37 LIBRARY_LINK_FLAG = -shared -Wl,-soname=$(SONAME)
38 ifeq ($(LIBDIR_IN_LDCONFIG),1)
39 ifeq ($(DESTDIR),)
40 LIBRARY_INSTALL_POST_COMMAND=ldconfig
41 endif
42 endif
43 endif
44
45 dir := lib
46 extra_cflags += -I$(dir) -fPIC
47
48 libnotmuch_c_srcs =             \
49         $(notmuch_compat_srcs)  \
50         $(dir)/libsha1.c        \
51         $(dir)/message-file.c   \
52         $(dir)/messages.c       \
53         $(dir)/sha1.c           \
54         $(dir)/tags.c           \
55         $(dir)/xutil.c
56
57 libnotmuch_cxx_srcs =           \
58         $(dir)/database.cc      \
59         $(dir)/directory.cc     \
60         $(dir)/index.cc         \
61         $(dir)/message.cc       \
62         $(dir)/query.cc         \
63         $(dir)/thread.cc
64
65 libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
66
67 $(dir)/libnotmuch.a: $(libnotmuch_modules)
68         $(call quiet,AR) rcs $@ $^
69
70 $(dir)/$(LIBNAME): $(libnotmuch_modules)
71         $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
72
73 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
74         ln -sf $(LIBNAME) $@
75
76 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
77         ln -sf $(LIBNAME) $@
78
79 install: install-$(dir)
80
81 # The (often-reused) $dir works fine within targets/pre-requisites,
82 # but cannot be used reliably within commands, so copy its value to a
83 # variable that is not reused.
84 lib := $(dir)
85 install-$(dir):
86         mkdir -p $(DESTDIR)$(libdir)/
87         install -m0644 $(lib)/$(LIBNAME) $(DESTDIR)$(libdir)/
88         ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(SONAME)
89         ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(LINKER_NAME)
90         mkdir -p $(DESTDIR)$(includedir)
91         install -m0644 $(lib)/notmuch.h $(DESTDIR)$(includedir)/
92         $(LIBRARY_INSTALL_POST_COMMAND)
93
94 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
95 CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/$(SONAME) $(dir)/$(LINKER_NAME) $(dir)$(LIBNAME) libnotmuch.a