From 042ea93ddd018980e940d9c11cdb0846791a33a9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Albert=20Gr=C3=A4f?= <aggraef@gmail.com>
Date: Tue, 24 Jan 2017 14:31:20 +0100
Subject: [PATCH] Add a proper Pd-l2ork version number, which serves to
 identify official releases and the particular Pd-l2ork flavor (1.x for
 classic Pd-l2ork and 2.x for the nw.js a.k.a. Purr Data version).

---
 packages/Makefile.buildlayout | 10 ++++++++--
 pd/src/import.c               |  3 ++-
 pd/src/m_pd.h.in              |  1 +
 pd/src/s_main.c               |  3 ++-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/packages/Makefile.buildlayout b/packages/Makefile.buildlayout
index 1124e3e80..c50317299 100644
--- a/packages/Makefile.buildlayout
+++ b/packages/Makefile.buildlayout
@@ -188,6 +188,12 @@ PD_BUGFIX_VERSION := $(shell grep PD_BUGFIX_VERSION $(pd_src)/src/m_pd.h.in | \
 #	PD_VERSION := $(PD_VERSION)-$(PD_TEST_VERSION)
 #endif
 
+# AG: Pd-l2ork version number. This becomes part of the PD_VERSION.
+# It comes from the m_pd.h.in file and will be something like 1.x for
+# "classic" Pd-l2ork and 2.x for the new nw.js version.
+PD_L2ORK_VERSION := $(shell grep PD_L2ORK_VERSION $(pd_src)/src/m_pd.h.in | \
+	sed 's|^.define *PD_L2ORK_VERSION *"\(.*\)".*|\1|' )
+
 # AG: version number based on the actual git revision and date. We use this
 # both for the PD_TEST_VERSION and for the package name and accompanying
 # materials (ReadMe files and such). Note that this will only work when
@@ -206,8 +212,8 @@ PD_TEST_VERSION := $(GIT_VERSION)
 # Pd-l2ork the vanilla Pd version numbers are rather meaningless (they are
 # mainly kept around so that 3rd party externals and abstractions know what
 # iteration of the vanilla API they have available). Instead, we use a version
-# number derived from PD_TEST_VERSION.
-PD_VERSION := $(PD_TEST_VERSION)
+# number derived from PD_L2ORK_VERSION and PD_TEST_VERSION.
+PD_VERSION := $(PD_L2ORK_VERSION)-$(PD_TEST_VERSION)
 
 VERSION_DATE := $(shell date +%Y%m%d)
 
diff --git a/pd/src/import.c b/pd/src/import.c
index 9a1566f18..886a80922 100644
--- a/pd/src/import.c
+++ b/pd/src/import.c
@@ -173,5 +173,6 @@ void import_setup(void)
     post("\t[import] is still in development, the interface could change!");
     //post("\tcompiled against Pd version %d.%d.%d", PD_MAJOR_VERSION, 
     //     PD_MINOR_VERSION, PD_BUGFIX_VERSION);
-    post("\tcompiled against Pd-l2ork version %s", PD_TEST_VERSION);
+    post("\tcompiled against Pd-l2ork version %s (%s)", PD_L2ORK_VERSION,
+	 PD_TEST_VERSION);
 }
diff --git a/pd/src/m_pd.h.in b/pd/src/m_pd.h.in
index c5d6a417a..58861f5a9 100644
--- a/pd/src/m_pd.h.in
+++ b/pd/src/m_pd.h.in
@@ -14,6 +14,7 @@ extern "C" {
 #define PD_MINOR_VERSION 43
 #define PD_BUGFIX_VERSION 10
 #define PD_TEST_VERSION "date/revision goes here"
+#define PD_L2ORK_VERSION "1.99"
 #define PDL2ORK
 extern int pd_compatibilitylevel;   /* e.g., 43 for pd 0.43 compatibility */
 
diff --git a/pd/src/s_main.c b/pd/src/s_main.c
index fb2114595..b17e30cdb 100644
--- a/pd/src/s_main.c
+++ b/pd/src/s_main.c
@@ -254,7 +254,8 @@ static void pd_makeversion(void)
     //    PD_MAJOR_VERSION, PD_MINOR_VERSION,
     //    PD_BUGFIX_VERSION, PD_TEST_VERSION);    
 
-    snprintf(foo, sizeof(foo), "Pd-L2Ork version %s\n", PD_TEST_VERSION);
+    snprintf(foo, sizeof(foo), "Pd-L2Ork version %s (%s)\n", PD_L2ORK_VERSION,
+	     PD_TEST_VERSION);
 
     pd_version = strdup(foo);
 }
-- 
GitLab