]> git.notmuchmail.org Git - notmuch/blob - lib/Makefile.local
5233ea6abe908a34647a4a0613c72395fc4a8fa7
[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 # (and when it is incremented, the release version of the library should
19 #  be reset to 0).
20 LIBNOTMUCH_VERSION_MINOR = 3
21
22 # The release version the library interface. This should be incremented at
23 # the time of release if there have been no changes to the interface, (but
24 # simply compatible changes to the implementation).
25 LIBNOTMUCH_VERSION_RELEASE = 0
26
27 ifeq ($(PLATFORM),MACOSX)
28 LIBRARY_SUFFIX = dylib
29 # On OS X, library version numbers go before suffix.
30 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
31 SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
32 LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
33 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)
34 else
35 LIBRARY_SUFFIX = so
36 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
37 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
38 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
39 LIBRARY_LINK_FLAG = -shared -Wl,-soname=$(SONAME)
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$(dir) -fPIC
49
50 libnotmuch_c_srcs =             \
51         $(notmuch_compat_srcs)  \
52         $(dir)/filenames.c      \
53         $(dir)/libsha1.c        \
54         $(dir)/message-file.c   \
55         $(dir)/messages.c       \
56         $(dir)/sha1.c           \
57         $(dir)/tags.c           \
58         $(dir)/xutil.c
59
60 libnotmuch_cxx_srcs =           \
61         $(dir)/database.cc      \
62         $(dir)/directory.cc     \
63         $(dir)/index.cc         \
64         $(dir)/message.cc       \
65         $(dir)/query.cc         \
66         $(dir)/thread.cc
67
68 libnotmuch_modules = $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
69
70 $(dir)/libnotmuch.a: $(libnotmuch_modules)
71         $(call quiet,AR) rcs $@ $^
72
73 $(dir)/$(LIBNAME): $(libnotmuch_modules)
74         $(call quiet,CXX $(CXXFLAGS)) $^ $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
75
76 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
77         ln -sf $(LIBNAME) $@
78
79 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
80         ln -sf $(LIBNAME) $@
81
82 install: install-$(dir)
83
84 # The (often-reused) $dir works fine within targets/pre-requisites,
85 # but cannot be used reliably within commands, so copy its value to a
86 # variable that is not reused.
87 lib := $(dir)
88 install-$(dir):
89         mkdir -p $(DESTDIR)$(libdir)/
90         install -m0644 $(lib)/$(LIBNAME) $(DESTDIR)$(libdir)/
91         ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(SONAME)
92         ln -sf $(LIBNAME) $(DESTDIR)$(libdir)/$(LINKER_NAME)
93         mkdir -p $(DESTDIR)$(includedir)
94         install -m0644 $(lib)/notmuch.h $(DESTDIR)$(includedir)/
95         $(LIBRARY_INSTALL_POST_COMMAND)
96
97 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
98 CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/$(SONAME) $(dir)/$(LINKER_NAME) $(dir)$(LIBNAME) libnotmuch.a