Skip to content

Commit

Permalink
Merge pull request #310 from osch/version-define
Browse files Browse the repository at this point in the history
Version number parts as numeric defines
  • Loading branch information
garyscavone committed Jun 15, 2023
2 parents 611a715 + 15a219b commit fd7c12a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
19 changes: 18 additions & 1 deletion RtMidi.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,24 @@
#endif
#endif

#define RTMIDI_VERSION "5.0.0"
#define RTMIDI_VERSION_MAJOR 5
#define RTMIDI_VERSION_MINOR 0
#define RTMIDI_VERSION_PATCH 0
#define RTMIDI_VERSION_BETA 0

#define RTMIDI_TOSTRING2(n) #n
#define RTMIDI_TOSTRING(n) RTMIDI_TOSTRING2(n)

#if RTMIDI_VERSION_BETA > 0
#define RTMIDI_VERSION RTMIDI_TOSTRING(RTMIDI_VERSION_MAJOR) \
"." RTMIDI_TOSTRING(RTMIDI_VERSION_MINOR) \
"." RTMIDI_TOSTRING(RTMIDI_VERSION_PATCH) \
"beta" RTMIDI_TOSTRING(RTMIDI_VERSION_BETA)
#else
#define RTMIDI_VERSION RTMIDI_TOSTRING(RTMIDI_VERSION_MAJOR) \
"." RTMIDI_TOSTRING(RTMIDI_VERSION_MINOR) \
"." RTMIDI_TOSTRING(RTMIDI_VERSION_PATCH)
#endif

#include <exception>
#include <iostream>
Expand Down
10 changes: 8 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,15 @@ AS_IF([test "x$CFLAGS" = "x" ], [override_c=yes], [override_c=no])

# Check version number coherency between RtMidi.h and configure.ac
AC_MSG_CHECKING([that version numbers are coherent])
RTMIDI_VERSION=`sed -n 's/#define RTMIDI_VERSION "\(.*\)"/\1/p' $srcdir/RtMidi.h`
RTMIDI_VERSION_MAJOR=`sed -n 's/#define RTMIDI_VERSION_MAJOR *\([0-9]*\)/\1/p' $srcdir/RtMidi.h`
RTMIDI_VERSION_MINOR=`sed -n 's/#define RTMIDI_VERSION_MINOR *\([0-9]*\)/\1/p' $srcdir/RtMidi.h`
RTMIDI_VERSION_PATCH=`sed -n 's/#define RTMIDI_VERSION_PATCH *\([0-9]*\)/\1/p' $srcdir/RtMidi.h`
RTMIDI_VERSION_BETA=`sed -n 's/#define RTMIDI_VERSION_BETA *\([0-9]*\)/\1/p' $srcdir/RtMidi.h`
AS_IF(
[test "x$RTMIDI_VERSION" != "x$PACKAGE_VERSION"],
[test '(' "0$RTMIDI_VERSION_BETA" -le 0 \
-o "x$RTMIDI_VERSION_MAJOR.$RTMIDI_VERSION_MINOR.${RTMIDI_VERSION_PATCH}beta${RTMIDI_VERSION_BETA}" != "x$PACKAGE_VERSION" ')' \
-a '(' "0$RTMIDI_VERSION_BETA" -ne 0\
-o "x$RTMIDI_VERSION_MAJOR.$RTMIDI_VERSION_MINOR.${RTMIDI_VERSION_PATCH}" != "x$PACKAGE_VERSION" ')' ],
[AC_MSG_FAILURE([testing RTMIDI_VERSION==PACKAGE_VERSION failed, check that RtMidi.h defines RTMIDI_VERSION as "$PACKAGE_VERSION" or that the first line of configure.ac has been updated.])])

# Enable some nice automake features if they are available
Expand Down

0 comments on commit fd7c12a

Please sign in to comment.