Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix rtmidi-config, add install/uninstall targets, support --prefix. #1

Merged
merged 6 commits into from
Oct 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@ LN = /bin/ln

OBJECTS = RtMidi.o

STATIC = librtmidi.a
LIBNAME = librtmidi
STATIC = $(LIBNAME).a
SHARED = @sharedlib@
RELEASE = 2.0.0
MAJOR = 1
RELEASE = 2.0.1
MAJOR = 2
LIBRARIES = $(STATIC) $(SHARED)

CC = @CXX@
Expand All @@ -19,6 +20,8 @@ RANLIB = @RANLIB@
DEFS = @CPPFLAGS@
CFLAGS = @CXXFLAGS@ -Iinclude -fPIC

PREFIX = @prefix@

all : $(LIBRARIES)

tests:
Expand All @@ -29,6 +32,7 @@ $(LIBRARIES): $(OBJECTS)
ranlib $(STATIC)
$(CC) -fPIC @libflags@ $(OBJECTS) @LIBS@
$(LN) -sf @sharedname@ $(SHARED)
$(LN) -sf @sharedname@ $(SHARED).$(MAJOR)

# $(CC) -shared $(OBJECTS) -o $(SHARED) @LIBS@

Expand All @@ -38,6 +42,20 @@ $(LIBRARIES): $(OBJECTS)
%.o : include/%.cpp
$(CC) $(CFLAGS) $(DEFS) -c $(<) -o $@

install: all
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=755 rtmidi-config $(PREFIX)/bin/
install --mode=644 RtMidi.h RtError.h $(PREFIX)/include

uninstall:
-@rm -vf $(patsubst %,$(PREFIX)/lib/%, $(LIBRARIES) $(SHARED).$(MAJOR) $(SHARED).$(RELEASE))
-@rm -vf $(PREFIX)/lib/pkgconfig/$(LIBNAME).pc
-@rm -vf $(PREFIX)/bin/rtmidi-config

clean :
$(RM) -f $(LIBRARIES) @sharedname@ $(SHARED)*
$(RM) -f $(OBJECTS)
Expand All @@ -55,3 +73,5 @@ strip :
strip $(LIBRARIES)
ranlib $(LIBRARIES)
cd tests && $(MAKE) strip

.PHONY: strip distclean clean uninstall
15 changes: 12 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Process this file with autoconf to produce a configure script.
AC_INIT(RtMidi, 2.0, gary@music.mcgill.ca, rtmidi)
AC_INIT(RtMidi, 2.0.1, gary@music.mcgill.ca, rtmidi)
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_SRCDIR(RtMidi.cpp)
AC_CONFIG_FILES(rtmidi-config Makefile tests/Makefile)
AC_CONFIG_FILES([rtmidi-config librtmidi.pc Makefile tests/Makefile])

# Fill GXX with something before test.
AC_SUBST( GXX, ["no"] )
Expand All @@ -26,6 +26,12 @@ AC_ARG_ENABLE(debug,
[AC_SUBST( cppflag, [-D__RTMIDI_DEBUG__] ) AC_SUBST( cxxflag, [-g] ) AC_SUBST( object_path, [Debug] ) AC_MSG_RESULT(yes)],
[AC_SUBST( cppflag, [] ) AC_SUBST( cxxflag, [-O3] ) AC_SUBST( object_path, [Release] ) AC_MSG_RESULT(no)])

# 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"

Expand Down Expand Up @@ -54,6 +60,7 @@ case $host in
esac

AC_SUBST( api, [""] )
AC_SUBST( req, [""] )
AC_MSG_CHECKING(for MIDI API)
case $host in
*-*-linux*)
Expand All @@ -65,12 +72,14 @@ case $host in
# Look for ALSA flag
AC_ARG_WITH(alsa, [ --with-alsa = choose native ALSA sequencer API support (linux only)], [
api="$api -D__LINUX_ALSA__"
req="$req alsa"
AC_MSG_RESULT(using ALSA)
AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA support requires the asound library!))], )

if [test "$api" == "";] then
AC_MSG_RESULT(using ALSA)
AC_SUBST( api, [-D__LINUX_ALSA__] )
req="$req alsa"
AC_CHECK_LIB(asound, snd_seq_open, , AC_MSG_ERROR(ALSA sequencer support requires the asound library!))
fi

Expand Down Expand Up @@ -136,4 +145,4 @@ CPPFLAGS="$CPPFLAGS $api"

AC_OUTPUT

chmod oug+x rtmidi-config
chmod oug+x rtmidi-config
12 changes: 12 additions & 0 deletions librtmidi.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
prefix=@prefix@
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

Name: librtmidi
Description: RtMidi - a set of C++ classes that provide a common API for realtime MIDI input/output
Version: 2.0.1
Requires: @req@
Libs: -L${libdir} -lrtmidi
Libs.private: -lpthread
Cflags: -pthread -I${includedir} @CPPFLAGS@
8 changes: 4 additions & 4 deletions rtmidi-config.in
Original file line number Diff line number Diff line change
Expand Up @@ -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 -lrtmidi"
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"
Expand Down