]> git.notmuchmail.org Git - notmuch/blob - lib/Makefile.local
Merge branch 'release'
[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 = 2
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 = 0
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 ifeq ($(PLATFORM),MACOSX)
22 LIBRARY_SUFFIX = dylib
23 # On OS X, library version numbers go before suffix.
24 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
25 SONAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBRARY_SUFFIX)
26 LIBNAME = libnotmuch.$(LIBNOTMUCH_VERSION_MAJOR).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE).$(LIBRARY_SUFFIX)
27 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)
28 else
29 LIBRARY_SUFFIX = so
30 LINKER_NAME = libnotmuch.$(LIBRARY_SUFFIX)
31 SONAME = $(LINKER_NAME).$(LIBNOTMUCH_VERSION_MAJOR)
32 LIBNAME = $(SONAME).$(LIBNOTMUCH_VERSION_MINOR).$(LIBNOTMUCH_VERSION_RELEASE)
33 LIBRARY_LINK_FLAG = -shared -Wl,--version-script=notmuch.sym,-soname=$(SONAME) -Wl,--no-undefined
34 ifeq ($(LIBDIR_IN_LDCONFIG),1)
35 ifeq ($(DESTDIR),)
36 LIBRARY_INSTALL_POST_COMMAND=ldconfig
37 endif
38 endif
39 endif
40
41 dir := lib
42 extra_cflags += -I$(srcdir)/$(dir) -fPIC
43
44 # The (often-reused) $dir works fine within targets/prerequisites,
45 # but cannot be used reliably within commands, so copy its value to a
46 # variable that is not reused.
47 lib := $(dir)
48
49 libnotmuch_c_srcs =             \
50         $(notmuch_compat_srcs)  \
51         $(dir)/filenames.c      \
52         $(dir)/string-list.c    \
53         $(dir)/libsha1.c        \
54         $(dir)/message-file.c   \
55         $(dir)/messages.c       \
56         $(dir)/sha1.c           \
57         $(dir)/tags.c
58
59 libnotmuch_cxx_srcs =           \
60         $(dir)/database.cc      \
61         $(dir)/directory.cc     \
62         $(dir)/index.cc         \
63         $(dir)/message.cc       \
64         $(dir)/query.cc         \
65         $(dir)/thread.cc
66
67 libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
68
69 $(dir)/libnotmuch.a: $(libnotmuch_modules)
70         $(call quiet,AR) rcs $@ $^
71
72 $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym
73         $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@ util/libutil.a
74
75 notmuch.sym: $(srcdir)/$(dir)/notmuch.h $(libnotmuch_modules)
76         sh $(srcdir)/$(lib)/gen-version-script.sh $< $(libnotmuch_modules) > $@
77
78 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
79         ln -sf $(LIBNAME) $@
80
81 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
82         ln -sf $(LIBNAME) $@
83
84 install: install-$(dir)
85
86 install-$(dir): $(dir)/$(LIBNAME)
87         mkdir -p "$(DESTDIR)$(libdir)/"
88         install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
89         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
90         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
91         mkdir -p "$(DESTDIR)$(includedir)"
92         install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
93         $(LIBRARY_INSTALL_POST_COMMAND)
94
95 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
96 CLEAN += $(libnotmuch_modules) $(dir)/$(SONAME) $(dir)/$(LINKER_NAME)
97 CLEAN += $(dir)/$(LIBNAME) $(dir)/libnotmuch.a notmuch.sym
98 CLEAN += $(dir)/notmuch.h.gch