Merge pull request #2 from radarsat1/master
authorgaryscavone <garyscavone@users.noreply.github.com>
Tue, 15 Oct 2013 15:44:20 +0000 (08:44 -0700)
committergaryscavone <garyscavone@users.noreply.github.com>
Tue, 15 Oct 2013 15:44:20 +0000 (08:44 -0700)
Add install/uninstall targets, fix rtaudio-config, support --prefix option.  (2nd try)

Makefile.in
configure.ac
librtaudio.pc.in
rtaudio-config.in

index 41685e5ffab731118a1851244f25d5b961e19644..a2ab13c8670758624d1b28a3ea87e17d18ac6256 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,20 @@ $(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/
+       install --mode=755 rtaudio-config $(PREFIX)/bin/
+
+uninstall:
+       -@rm -vf $(patsubst %,$(PREFIX)/lib/%, $(LIBRARIES) $(SHARED).$(MAJOR) $(SHARED).$(RELEASE))
+       -@rm -vf $(PREFIX)/lib/pkgconfig/$(LIBNAME).pc
+       -@rm -vf $(PREFIX)/bin/rtaudio-config
+
 clean : 
        $(RM) -f $(LIBRARIES) @sharedname@ $(SHARED)*
        $(RM) -f $(OBJECTS)
@@ -47,10 +64,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 6586116d1aa51fa2190fbbd7af710d0607b5bbef..b89fdb0086ecebb5cdc5a9fcbab972ab96b1f077 100644 (file)
@@ -44,6 +44,12 @@ AC_ARG_ENABLE(debug,
 # Checks for functions
 AC_CHECK_FUNC(gettimeofday, [cppflag="$cppflag -DHAVE_GETTIMEOFDAY"], )
 
+# Set paths if prefix is defined
+if test x"$prefix" != x; then
+  LIBS="$LIBS -L$prefix/lib"
+  CPPFLAGS="$CPPFLAGS -I$prefix/include"
+fi
+
 # For -I and -D flags
 CPPFLAGS="$CPPFLAGS $cppflag"
 
index d7591a78890b6dd2bee0a3432e9d6e03674b497e..b4f3985bb78beadbd968335130c86b4de05e6d4a 100644 (file)
@@ -1,4 +1,4 @@
-prefix=/usr/local
+prefix=@prefix@
 exec_prefix=${prefix}
 libdir=${exec_prefix}/lib
 includedir=${prefix}/include        
index 2422b60416b42cfd0fadc842bdbb5df7d4ec11e9..5f83d512f830da4614e59e0969047b9d05888399 100644 (file)
@@ -8,11 +8,11 @@ LIBRARY="@LIBS@"
 CXXFLAGS="@CXXFLAGS@"
 CPPFLAGS="@CPPFLAGS@"
 
-if (test "x$1" == "x--libs") ; then
-  echo "$LIBRARY"
-elif (test "x$1" == "x--cxxflags") ; then
+if (test "x$1" = "x--libs") ; then
+  echo "$LIBRARY -lrtaudio"
+elif (test "x$1" = "x--cxxflags") ; then
   echo "$CXXFLAGS"
-elif (test "x$1" == "x--cppflags") ; then
+elif (test "x$1" = "x--cppflags") ; then
   echo "$CPPFLAGS"
 else
   echo "Unknown option: $1"