annotate Makefile @ 230:5ee166dccfff distinct-libraries

* Add include guards; make code compile!
author cannam
date Fri, 07 Nov 2008 14:11:39 +0000
parents 5ee5f0100adb
children 90e3acb4a728
rev   line source
cannam@0 1
cannam@10 2 # Makefile for the Vamp plugin SDK. This builds the SDK objects,
cannam@51 3 # libraries, example plugins, and the test host. Please adjust to
cannam@51 4 # suit your operating system requirements.
cannam@0 5
cannam@64 6 APIDIR = vamp
cannam@230 7
cannam@10 8 SDKDIR = vamp-sdk
cannam@230 9 HOSTSDKDIR = vamp-hostsdk
cannam@230 10 HOSTEXTDIR = vamp-hostsdk/hostext
cannam@230 11
cannam@230 12 SRCDIR = src
cannam@230 13 SDKSRCDIR = src/vamp-sdk
cannam@230 14 HOSTSDKSRCDIR = src/vamp-hostsdk
cannam@230 15 HOSTEXTSRCDIR = src/vamp-hostsdk/hostext
cannam@230 16
cannam@10 17 EXAMPLEDIR = examples
cannam@10 18 HOSTDIR = host
cannam@1 19
cannam@64 20 ###
cannam@64 21 ### Start of user-serviceable parts
cannam@64 22 ###
cannam@0 23
cannam@64 24 # Default build target (or use "make <target>" to select one).
cannam@64 25 # Targets are:
cannam@64 26 # all -- build everything
cannam@64 27 # sdk -- build all the Vamp SDK libraries for plugins and hosts
cannam@82 28 # sdkstatic -- build only the static versions of the SDK libraries
cannam@64 29 # plugins -- build the example plugins (and the SDK if required)
cannam@64 30 # host -- build the simple Vamp plugin host (and the SDK if required)
cannam@64 31 # test -- build the host and example plugins, and run a quick test
cannam@64 32 # clean -- remove binary targets
cannam@64 33 # distclean -- remove all targets
cannam@64 34 #
cannam@64 35 default: all
cannam@64 36
cannam@64 37 # Compile flags
cannam@64 38 #
cannam@168 39 CXXFLAGS := $(CXXFLAGS) -g -Wall -I. -fPIC
cannam@64 40
cannam@89 41 # ar, ranlib
cannam@89 42 #
cannam@89 43 AR := ar
cannam@89 44 RANLIB := ranlib
cannam@89 45
cannam@64 46 # Libraries required for the plugins.
cannam@64 47 #
cannam@230 48 PLUGIN_LIBS = $(SRCDIR)/libvamp-sdk.a
cannam@64 49
cannam@64 50 # File extension for a dynamically loadable object
cannam@64 51 #
cannam@64 52 PLUGIN_EXT = .so
cannam@89 53 #PLUGIN_EXT = .dll
cannam@64 54 #PLUGIN_EXT = .dylib
cannam@64 55
cannam@64 56 # Libraries required for the host.
cannam@64 57 #
cannam@230 58 HOST_LIBS = $(SRCDIR)/libvamp-hostsdk.a -lsndfile -ldl
cannam@1 59
cannam@32 60 # Locations for "make install". This will need quite a bit of
cannam@32 61 # editing for non-Linux platforms. Of course you don't necessarily
cannam@32 62 # have to use "make install".
cannam@32 63 #
cannam@162 64 INSTALL_PREFIX := /usr/local
cannam@51 65 INSTALL_API_HEADERS := $(INSTALL_PREFIX)/include/vamp
cannam@51 66 INSTALL_SDK_HEADERS := $(INSTALL_PREFIX)/include/vamp-sdk
cannam@64 67 INSTALL_HOSTEXT_HEADERS := $(INSTALL_PREFIX)/include/vamp-sdk/hostext
cannam@51 68 INSTALL_SDK_LIBS := $(INSTALL_PREFIX)/lib
cannam@51 69
cannam@168 70 INSTALL_SDK_LIBNAME := libvamp-sdk.so.2.0.0
cannam@168 71 INSTALL_SDK_LINK_ABI := libvamp-sdk.so.2
cannam@51 72 INSTALL_SDK_LINK_DEV := libvamp-sdk.so
cannam@51 73 INSTALL_SDK_STATIC := libvamp-sdk.a
cannam@51 74 INSTALL_SDK_LA := libvamp-sdk.la
cannam@51 75
cannam@168 76 INSTALL_HOSTSDK_LIBNAME := libvamp-hostsdk.so.3.0.0
cannam@168 77 INSTALL_HOSTSDK_LINK_ABI := libvamp-hostsdk.so.3
cannam@51 78 INSTALL_HOSTSDK_LINK_DEV := libvamp-hostsdk.so
cannam@51 79 INSTALL_HOSTSDK_STATIC := libvamp-hostsdk.a
cannam@51 80 INSTALL_HOSTSDK_LA := libvamp-hostsdk.la
cannam@51 81
cannam@51 82 INSTALL_PKGCONFIG := $(INSTALL_PREFIX)/lib/pkgconfig
cannam@32 83
cannam@81 84 # Flags required to tell the compiler to create a dynamically loadable object
cannam@81 85 #
cannam@160 86 DYNAMIC_LDFLAGS = -static-libgcc -shared -Wl,-Bsymbolic
cannam@107 87 SDK_DYNAMIC_LDFLAGS = $(DYNAMIC_LDFLAGS) -Wl,-soname=$(INSTALL_SDK_LINK_ABI)
cannam@107 88 HOSTSDK_DYNAMIC_LDFLAGS = $(DYNAMIC_LDFLAGS) -Wl,-soname=$(INSTALL_HOSTSDK_LINK_ABI)
cannam@81 89
cannam@162 90 # Additional flags for making a plugin. This version script tells the
cannam@162 91 # GNU linker to make all symbols in the library hidden except for the
cannam@162 92 # public entry point. It's not essential, but makes a tidier library.
cannam@230 93 PLUGIN_LDFLAGS = $(DYNAMIC_LDFLAGS) -Wl,--version-script=build/vamp-plugin.map
cannam@162 94
cannam@162 95
cannam@81 96 ## For OS/X with g++:
cannam@94 97 #DYNAMIC_LDFLAGS = -dynamiclib
cannam@94 98 #PLUGIN_LDFLAGS = $(DYNAMIC_LDFLAGS)
cannam@94 99 #SDK_DYNAMIC_LDFLAGS = $(DYNAMIC_LDFLAGS)
cannam@94 100 #HOSTSDK_DYNAMIC_LDFLAGS = $(DYNAMIC_LDFLAGS)
cannam@81 101
cannam@81 102
cannam@10 103 ### End of user-serviceable parts
cannam@10 104
cannam@32 105
cannam@20 106 API_HEADERS = \
cannam@20 107 $(APIDIR)/vamp.h
cannam@20 108
cannam@20 109 SDK_HEADERS = \
cannam@20 110 $(SDKDIR)/Plugin.h \
cannam@20 111 $(SDKDIR)/PluginAdapter.h \
cannam@20 112 $(SDKDIR)/PluginBase.h \
cannam@51 113 $(SDKDIR)/RealTime.h
cannam@51 114
cannam@51 115 HOSTSDK_HEADERS = \
cannam@230 116 $(HOSTSDKDIR)/Plugin.h \
cannam@230 117 $(HOSTSDKDIR)/PluginBase.h \
cannam@230 118 $(HOSTSDKDIR)/PluginHostAdapter.h \
cannam@230 119 $(HOSTSDKDIR)/RealTime.h
cannam@20 120
cannam@64 121 HOSTEXT_HEADERS = \
cannam@92 122 $(HOSTEXTDIR)/PluginBufferingAdapter.h \
cannam@64 123 $(HOSTEXTDIR)/PluginChannelAdapter.h \
cannam@64 124 $(HOSTEXTDIR)/PluginInputDomainAdapter.h \
cannam@64 125 $(HOSTEXTDIR)/PluginLoader.h \
cannam@174 126 $(HOSTEXTDIR)/PluginSummarisingAdapter.h \
cannam@64 127 $(HOSTEXTDIR)/PluginWrapper.h
cannam@64 128
cannam@11 129 SDK_OBJECTS = \
cannam@230 130 $(SDKSRCDIR)/PluginAdapter.o \
cannam@230 131 $(SDKSRCDIR)/RealTime.o
cannam@51 132
cannam@51 133 HOSTSDK_OBJECTS = \
cannam@230 134 $(HOSTSDKSRCDIR)/PluginHostAdapter.o \
cannam@230 135 $(HOSTSDKSRCDIR)/RealTime.o \
cannam@230 136 $(HOSTEXTSRCDIR)/PluginBufferingAdapter.o \
cannam@230 137 $(HOSTEXTSRCDIR)/PluginChannelAdapter.o \
cannam@230 138 $(HOSTEXTSRCDIR)/PluginInputDomainAdapter.o \
cannam@230 139 $(HOSTEXTSRCDIR)/PluginLoader.o \
cannam@230 140 $(HOSTEXTSRCDIR)/PluginSummarisingAdapter.o \
cannam@230 141 $(HOSTEXTSRCDIR)/PluginWrapper.o
cannam@11 142
cannam@32 143 SDK_STATIC = \
cannam@230 144 $(SRCDIR)/libvamp-sdk.a
cannam@10 145
cannam@51 146 HOSTSDK_STATIC = \
cannam@230 147 $(SRCDIR)/libvamp-hostsdk.a
cannam@51 148
cannam@32 149 SDK_DYNAMIC = \
cannam@230 150 $(SRCDIR)/libvamp-sdk$(PLUGIN_EXT)
cannam@32 151
cannam@51 152 HOSTSDK_DYNAMIC = \
cannam@230 153 $(SRCDIR)/libvamp-hostsdk$(PLUGIN_EXT)
cannam@51 154
cannam@33 155 SDK_LA = \
cannam@230 156 $(SRCDIR)/libvamp-sdk.la
cannam@33 157
cannam@86 158 HOSTSDK_LA = \
cannam@230 159 $(SRCDIR)/libvamp-hostsdk.la
cannam@86 160
cannam@20 161 PLUGIN_HEADERS = \
cannam@20 162 $(EXAMPLEDIR)/SpectralCentroid.h \
cannam@35 163 $(EXAMPLEDIR)/PercussionOnsetDetector.h \
cannam@198 164 $(EXAMPLEDIR)/FixedTempoEstimator.h \
cannam@41 165 $(EXAMPLEDIR)/AmplitudeFollower.h \
cannam@20 166 $(EXAMPLEDIR)/ZeroCrossing.h
cannam@20 167
cannam@10 168 PLUGIN_OBJECTS = \
cannam@20 169 $(EXAMPLEDIR)/SpectralCentroid.o \
cannam@35 170 $(EXAMPLEDIR)/PercussionOnsetDetector.o \
cannam@198 171 $(EXAMPLEDIR)/FixedTempoEstimator.o \
cannam@41 172 $(EXAMPLEDIR)/AmplitudeFollower.o \
cannam@10 173 $(EXAMPLEDIR)/ZeroCrossing.o \
cannam@10 174 $(EXAMPLEDIR)/plugins.o
cannam@10 175
cannam@10 176 PLUGIN_TARGET = \
cannam@21 177 $(EXAMPLEDIR)/vamp-example-plugins$(PLUGIN_EXT)
cannam@10 178
cannam@20 179 HOST_HEADERS = \
cannam@20 180 $(HOSTDIR)/system.h
cannam@20 181
cannam@10 182 HOST_OBJECTS = \
cannam@22 183 $(HOSTDIR)/vamp-simple-host.o
cannam@10 184
cannam@10 185 HOST_TARGET = \
cannam@22 186 $(HOSTDIR)/vamp-simple-host
cannam@10 187
cannam@89 188 sdk: sdkstatic $(SDK_DYNAMIC) $(HOSTSDK_DYNAMIC)
cannam@64 189
cannam@82 190 sdkstatic: $(SDK_STATIC) $(HOSTSDK_STATIC)
cannam@89 191 $(RANLIB) $(SDK_STATIC)
cannam@89 192 $(RANLIB) $(HOSTSDK_STATIC)
cannam@82 193
cannam@64 194 plugins: $(PLUGIN_TARGET)
cannam@64 195
cannam@64 196 host: $(HOST_TARGET)
cannam@64 197
cannam@64 198 all: sdk plugins host test
cannam@11 199
cannam@32 200 $(SDK_STATIC): $(SDK_OBJECTS) $(API_HEADERS) $(SDK_HEADERS)
cannam@20 201 $(AR) r $@ $(SDK_OBJECTS)
cannam@10 202
cannam@64 203 $(HOSTSDK_STATIC): $(HOSTSDK_OBJECTS) $(API_HEADERS) $(HOSTSDK_HEADERS) $(HOSTEXT_HEADERS)
cannam@51 204 $(AR) r $@ $(HOSTSDK_OBJECTS)
cannam@51 205
cannam@32 206 $(SDK_DYNAMIC): $(SDK_OBJECTS) $(API_HEADERS) $(SDK_HEADERS)
cannam@81 207 $(CXX) $(LDFLAGS) $(SDK_DYNAMIC_LDFLAGS) -o $@ $(SDK_OBJECTS)
cannam@32 208
cannam@64 209 $(HOSTSDK_DYNAMIC): $(HOSTSDK_OBJECTS) $(API_HEADERS) $(HOSTSDK_HEADERS) $(HOSTEXT_HEADERS)
cannam@81 210 $(CXX) $(LDFLAGS) $(HOSTSDK_DYNAMIC_LDFLAGS) -o $@ $(HOSTSDK_OBJECTS)
cannam@51 211
cannam@64 212 $(PLUGIN_TARGET): $(PLUGIN_OBJECTS) $(SDK_STATIC) $(PLUGIN_HEADERS)
cannam@20 213 $(CXX) $(LDFLAGS) $(PLUGIN_LDFLAGS) -o $@ $(PLUGIN_OBJECTS) $(PLUGIN_LIBS)
cannam@10 214
cannam@64 215 $(HOST_TARGET): $(HOST_OBJECTS) $(HOSTSDK_STATIC) $(HOST_HEADERS)
cannam@20 216 $(CXX) $(LDFLAGS) $(HOST_LDFLAGS) -o $@ $(HOST_OBJECTS) $(HOST_LIBS)
cannam@10 217
cannam@64 218 test: plugins host
cannam@64 219 VAMP_PATH=$(EXAMPLEDIR) $(HOST_TARGET) -l
cannam@10 220
cannam@10 221 clean:
cannam@51 222 rm -f $(SDK_OBJECTS) $(HOSTSDK_OBJECTS) $(PLUGIN_OBJECTS) $(HOST_OBJECTS)
cannam@10 223
cannam@33 224 distclean: clean
cannam@51 225 rm -f $(SDK_STATIC) $(SDK_DYNAMIC) $(HOSTSDK_STATIC) $(HOSTSDK_DYNAMIC) $(PLUGIN_TARGET) $(HOST_TARGET) *~ */*~
cannam@33 226
cannam@51 227 install: $(SDK_STATIC) $(SDK_DYNAMIC) $(HOSTSDK_STATIC) $(HOSTSDK_DYNAMIC) $(PLUGIN_TARGET) $(HOST_TARGET)
cannam@96 228 mkdir -p $(DESTDIR)$(INSTALL_API_HEADERS)
cannam@96 229 mkdir -p $(DESTDIR)$(INSTALL_SDK_HEADERS)
cannam@96 230 mkdir -p $(DESTDIR)$(INSTALL_HOSTEXT_HEADERS)
cannam@96 231 mkdir -p $(DESTDIR)$(INSTALL_SDK_LIBS)
cannam@96 232 mkdir -p $(DESTDIR)$(INSTALL_PKGCONFIG)
cannam@96 233 cp $(API_HEADERS) $(DESTDIR)$(INSTALL_API_HEADERS)
cannam@96 234 cp $(SDK_HEADERS) $(DESTDIR)$(INSTALL_SDK_HEADERS)
cannam@96 235 cp $(HOSTSDK_HEADERS) $(DESTDIR)$(INSTALL_SDK_HEADERS)
cannam@96 236 cp $(HOSTEXT_HEADERS) $(DESTDIR)$(INSTALL_HOSTEXT_HEADERS)
cannam@96 237 cp $(SDK_STATIC) $(DESTDIR)$(INSTALL_SDK_LIBS)
cannam@96 238 cp $(HOSTSDK_STATIC) $(DESTDIR)$(INSTALL_SDK_LIBS)
cannam@96 239 cp $(SDK_DYNAMIC) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LIBNAME)
cannam@96 240 cp $(HOSTSDK_DYNAMIC) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LIBNAME)
cannam@96 241 rm -f $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_ABI)
cannam@96 242 ln -s $(INSTALL_SDK_LIBNAME) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_ABI)
cannam@96 243 rm -f $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LINK_ABI)
cannam@96 244 ln -s $(INSTALL_HOSTSDK_LIBNAME) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LINK_ABI)
cannam@96 245 rm -f $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_DEV)
cannam@96 246 ln -s $(INSTALL_SDK_LIBNAME) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LINK_DEV)
cannam@96 247 rm -f $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LINK_DEV)
cannam@96 248 ln -s $(INSTALL_HOSTSDK_LIBNAME) $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LINK_DEV)
cannam@33 249 sed "s,%PREFIX%,$(INSTALL_PREFIX)," $(APIDIR)/vamp.pc.in \
cannam@96 250 > $(DESTDIR)$(INSTALL_PKGCONFIG)/vamp.pc
cannam@33 251 sed "s,%PREFIX%,$(INSTALL_PREFIX)," $(SDKDIR)/vamp-sdk.pc.in \
cannam@96 252 > $(DESTDIR)$(INSTALL_PKGCONFIG)/vamp-sdk.pc
cannam@51 253 sed "s,%PREFIX%,$(INSTALL_PREFIX)," $(SDKDIR)/vamp-hostsdk.pc.in \
cannam@96 254 > $(DESTDIR)$(INSTALL_PKGCONFIG)/vamp-hostsdk.pc
cannam@33 255 sed -e "s,%LIBNAME%,$(INSTALL_SDK_LIBNAME),g" \
cannam@33 256 -e "s,%LINK_ABI%,$(INSTALL_SDK_LINK_ABI),g" \
cannam@33 257 -e "s,%LINK_DEV%,$(INSTALL_SDK_LINK_DEV),g" \
cannam@33 258 -e "s,%STATIC%,$(INSTALL_SDK_STATIC),g" \
cannam@34 259 -e "s,%LIBS%,$(INSTALL_SDK_LIBS),g" $(SDK_LA).in \
cannam@96 260 > $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_SDK_LA)
cannam@51 261 sed -e "s,%LIBNAME%,$(INSTALL_HOSTSDK_LIBNAME),g" \
cannam@51 262 -e "s,%LINK_ABI%,$(INSTALL_HOSTSDK_LINK_ABI),g" \
cannam@51 263 -e "s,%LINK_DEV%,$(INSTALL_HOSTSDK_LINK_DEV),g" \
cannam@51 264 -e "s,%STATIC%,$(INSTALL_HOSTSDK_STATIC),g" \
cannam@86 265 -e "s,%LIBS%,$(INSTALL_SDK_LIBS),g" $(HOSTSDK_LA).in \
cannam@96 266 > $(DESTDIR)$(INSTALL_SDK_LIBS)/$(INSTALL_HOSTSDK_LA)
cannam@51 267