]> git.notmuchmail.org Git - notmuch/blob - lib/Makefile.local
fix sum moar typos [build scripts, Makefiles]
[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,--version-script=notmuch.sym,-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$(srcdir)/$(dir) -fPIC
49
50 libnotmuch_c_srcs =             \
51         $(notmuch_compat_srcs)  \
52         $(dir)/filenames.c      \
53         $(dir)/string-list.c    \
54         $(dir)/libsha1.c        \
55         $(dir)/message-file.c   \
56         $(dir)/messages.c       \
57         $(dir)/sha1.c           \
58         $(dir)/tags.c           \
59         $(dir)/xutil.c
60
61 libnotmuch_cxx_srcs =           \
62         $(dir)/database.cc      \
63         $(dir)/directory.cc     \
64         $(dir)/index.cc         \
65         $(dir)/message.cc       \
66         $(dir)/query.cc         \
67         $(dir)/thread.cc
68
69 libnotmuch_modules := $(libnotmuch_c_srcs:.c=.o) $(libnotmuch_cxx_srcs:.cc=.o)
70
71 $(dir)/libnotmuch.a: $(libnotmuch_modules)
72         $(call quiet,AR) rcs $@ $^
73
74 $(dir)/$(LIBNAME): $(libnotmuch_modules) notmuch.sym
75         echo $(libnotmuch_modules)
76         $(call quiet,CXX $(CXXFLAGS)) $(libnotmuch_modules) $(FINAL_LIBNOTMUCH_LDFLAGS) $(LIBRARY_LINK_FLAG) -o $@
77
78 notmuch.sym: lib/notmuch.h
79         gcc -aux-info notmuch.aux $<
80         printf "{\nglobal:\n" > notmuch.sym
81         sed  -n 's/.*\(notmuch_[a-z_]*\) (.*/\t\1;/p' notmuch.aux >> notmuch.sym
82         printf "local: *;\n};\n" >> notmuch.sym
83
84 $(dir)/$(SONAME): $(dir)/$(LIBNAME)
85         ln -sf $(LIBNAME) $@
86
87 $(dir)/$(LINKER_NAME): $(dir)/$(SONAME)
88         ln -sf $(LIBNAME) $@
89
90 install: install-$(dir)
91
92 # The (often-reused) $dir works fine within targets/prerequisites,
93 # but cannot be used reliably within commands, so copy its value to a
94 # variable that is not reused.
95 lib := $(dir)
96 install-$(dir): $(dir)/$(LIBNAME)
97         mkdir -p "$(DESTDIR)$(libdir)/"
98         install -m0644 "$(lib)/$(LIBNAME)" "$(DESTDIR)$(libdir)/"
99         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(SONAME)"
100         ln -sf $(LIBNAME) "$(DESTDIR)$(libdir)/$(LINKER_NAME)"
101         mkdir -p "$(DESTDIR)$(includedir)"
102         install -m0644 "$(srcdir)/$(lib)/notmuch.h" "$(DESTDIR)$(includedir)/"
103         $(LIBRARY_INSTALL_POST_COMMAND)
104
105 SRCS  := $(SRCS) $(libnotmuch_c_srcs) $(libnotmuch_cxx_srcs)
106 CLEAN := $(CLEAN) $(libnotmuch_modules) $(dir)/$(SONAME) $(dir)/$(LINKER_NAME) $(dir)$(LIBNAME) libnotmuch.a notmuch.aux notmuch.sym