Support "install" and "uninstall" targets, and support --prefix configure option.
authorStephen Sinclair <radarsat1@gmail.com>
Fri, 11 Oct 2013 15:48:29 +0000 (17:48 +0200)
committerStephen Sinclair <radarsat1@gmail.com>
Fri, 11 Oct 2013 16:57:30 +0000 (18:57 +0200)
Makefile.in
librtaudio.pc.in

index 41685e5ffab731118a1851244f25d5b961e19644..5f41cc5c6cd0879894b53e4ba9e3f462d290181d 100644 (file)
@@ -6,7 +6,8 @@ LN = /bin/ln
 
 OBJECTS        = RtAudio.o @objects@
 
-STATIC = librtaudio.a
+LIBNAME = librtaudio
+STATIC = $(LIBNAME).a
 SHARED = @sharedlib@
 RELEASE = 4.0.12
 MAJOR = 4
@@ -19,6 +20,8 @@ RANLIB   = @RANLIB@
 DEFS     = @CPPFLAGS@
 CFLAGS   = @CXXFLAGS@ -Iinclude -fPIC
 
+PREFIX   = @prefix@
+
 all : $(LIBRARIES)
 
 tests:
@@ -37,6 +40,18 @@ $(LIBRARIES): $(OBJECTS)
 %.o : include/%.cpp
        $(CC) $(CFLAGS) $(DEFS) -c $(<) -o $@
 
+install:
+       install --mode=755 $(STATIC) $(PREFIX)/lib/
+       install --mode=755 @sharedname@ $(PREFIX)/lib/
+       $(LN) -sf @sharedname@ $(PREFIX)/lib/$(SHARED)
+       $(LN) -sf @sharedname@ $(PREFIX)/lib/$(SHARED).$(MAJOR)
+       install --mode=644 $(LIBNAME).pc $(PREFIX)/lib/pkgconfig
+       install --mode=644 RtAudio.h RtError.h $(PREFIX)/include/
+
+uninstall:
+       -@rm -vf $(patsubst %,$(PREFIX)/lib/%, $(LIBRARIES) $(SHARED).$(MAJOR) $(SHARED).$(RELEASE))
+       -@rm -vf $(PREFIX)/lib/pkgconfig/$(LIBNAME).pc
+
 clean : 
        $(RM) -f $(LIBRARIES) @sharedname@ $(SHARED)*
        $(RM) -f $(OBJECTS)
@@ -47,10 +62,12 @@ distclean:
        $(RM) -f $(LIBRARIES) @sharedname@ $(SHARED)*
        $(RM) -f $(OBJECTS)
        $(RM) -f *~
-       $(RM) -rf config.log config.status autom4te.cache Makefile rtaudio-config librtaudio.pc
+       $(RM) -rf config.log config.status autom4te.cache Makefile rtaudio-config $(LIBNAME).pc
        cd tests && $(MAKE) distclean
 
 strip : 
        strip $(LIBRARIES)
        ranlib $(LIBRARIES)
        cd tests && $(MAKE) strip
+
+.PHONY: clean distclean strip install uninstall
index d7591a78890b6dd2bee0a3432e9d6e03674b497e..b4f3985bb78beadbd968335130c86b4de05e6d4a 100644 (file)
@@ -1,4 +1,4 @@
-prefix=/usr/local
+prefix=@prefix@
 exec_prefix=${prefix}
 libdir=${exec_prefix}/lib
 includedir=${prefix}/include