Skip to contentSkip to conversation

Patch Description

PATCH Superseded Yang Gu 2 participants 3 messages Nov 3, 2010 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Yang Gu

author
#0 lore raw

cover Patch Description

Sometimes we need to know the version of phonesim via a command. This patch is to add this support.

By the way, oFono introduces a file named version.h.in for the macro OFONO_VERSION. Can we use VERSION directly so that this file can be removed?

Yang Gu (1):
Add option to support version

 Makefile.am  |    2 +-
 bootstrap    |    2 +-
 configure.ac |    1 +
 src/main.cpp |   11 +++++++++--
 4 files changed, 12 insertions(+), 4 deletions(-)
Signature · 1 line
1.7.2.3
author
#1 lore raw

PATCH 1/1 Add option to support version

---
 Makefile.am  |    2 +-
 bootstrap    |    2 +-
 configure.ac |    1 +
 src/main.cpp |   11 +++++++++--
 4 files changed, 12 insertions(+), 4 deletions(-)
Makefile.am +1 -1
index f124b08..dd54c42 100644
@@ -50,7 +50,7 @@ dist_pkgdata_DATA = src/default.xml
 EXTRA_DIST = src/controlbase.ui src/GSMSpecification.xml
 
 MAINTAINERCLEANFILES = Makefile.in \
-	aclocal.m4 configure depcomp missing install-sh
+	aclocal.m4 configure config.h.in depcomp missing install-sh
 
 
 $(src_phonesim_OBJECTS): src/ui_controlbase.h
bootstrap +1 -1
index 562c115..05eee20 100755
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-aclocal && automake --add-missing --copy && autoconf
+aclocal && autoheader && automake --add-missing --copy && autoconf
configure.ac +1 -0
index 725ae7e..445a11c 100644
@@ -2,6 +2,7 @@ AC_PREREQ(2.60)
 AC_INIT(phonesim, 1.8)
 
 AM_INIT_AUTOMAKE([foreign subdir-objects])
+AM_CONFIG_HEADER(config.h)
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
src/main.cpp +9 -2
index d7de416..6a00cb5 100644
@@ -17,6 +17,10 @@
 **
 ****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <server.h>
 #include "control.h"
 #include <qapplication.h>
@@ -28,7 +32,7 @@ static void usage()
 {
     qWarning() << "Usage:"
                << QFileInfo(QCoreApplication::instance()->applicationFilePath()).fileName().toLocal8Bit().constData()
-               << "[-p port] [-gui] filename";
+               << "[-v] [-p port] [-gui] filename";
     exit(-1);
 }
 
@@ -43,7 +47,10 @@ int main(int argc, char **argv)
     // Parse the command-line.
     index = 1;
     for (index = 1; index < argc; index++) {
-        if (strcmp(argv[index],"-p") == 0) {
+        if (strcmp(argv[index],"-v") == 0) {
+            qWarning() << VERSION;
+            exit(0);
+        } else if (strcmp(argv[index],"-p") == 0) {
             index++;
             if (index >= argc) {
                 qWarning() << "ERROR: Got -p but missing port number";
Signature · 1 line
1.7.2.3
#2 lore raw

Re: [PATCH 1/1] Add option to support version

Hi Yang,

Quoted 45 lines
 Makefile.am  |    2 +-
 bootstrap    |    2 +-
 configure.ac |    1 +
 src/main.cpp |   11 +++++++++--
 4 files changed, 12 insertions(+), 4 deletions(-)
Makefile.am +1 -1
index f124b08..dd54c42 100644
@@ -50,7 +50,7 @@ dist_pkgdata_DATA = src/default.xml
 EXTRA_DIST = src/controlbase.ui src/GSMSpecification.xml
 
 MAINTAINERCLEANFILES = Makefile.in \
-	aclocal.m4 configure depcomp missing install-sh
+	aclocal.m4 configure config.h.in depcomp missing install-sh
 
 
 $(src_phonesim_OBJECTS): src/ui_controlbase.h
bootstrap +1 -1
index 562c115..05eee20 100755
@@ -1,3 +1,3 @@
 #!/bin/sh
 
-aclocal && automake --add-missing --copy && autoconf
+aclocal && autoheader && automake --add-missing --copy && autoconf
configure.ac +1 -0
index 725ae7e..445a11c 100644
@@ -2,6 +2,7 @@ AC_PREREQ(2.60)
 AC_INIT(phonesim, 1.8)
 
 AM_INIT_AUTOMAKE([foreign subdir-objects])
+AM_CONFIG_HEADER(config.h)
 
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
 
src/main.cpp +0 -0
index d7de416..6a00cb5 100644

src/main.cpp line 23

Quoted 7 lines
src/main.cpp +4 -0
@@ -17,6 +17,10 @@
 **
 ****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+

this is not how this works actually. Either you do that in every single file or you better don't do it at all.

Run "make V=1" and you see what are the actual parameters.

depbase=echo src/main.o | sed 's|[^/]*$|.deps/&|;s|\.o$||';\
g++ -DPACKAGE_NAME=\"phonesim\" -DPACKAGE_TARNAME=\"phonesim\" -DPACKAGE_VERSION=\"1.8\" -DPACKAGE_STRING=\"phonesim\ 1.8\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DPACKAGE=\"phonesim\" -DVERSION=\"1.8\" -I. -I./src -I./src -Wall -DQT_SHARED -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include/QtXml -I/usr/include/QtNetwork -I/usr/include/QtScript -I/usr/include/QtDBus -g -O2 -MT src/main.o -MD -MP -MF $depbase.Tpo -c -o src/main.o src/main.cpp &&\
mv -f $depbase.Tpo $depbase.Po

As you can see that it nicely does -DVERSION=\"1.8\" actually.

Quoted 14 lines
src/main.cpp +1 -1
 #include <server.h>
 #include "control.h"
 #include <qapplication.h>
@@ -28,7 +32,7 @@ static void usage()
 {
     qWarning() << "Usage:"
                << QFileInfo(QCoreApplication::instance()->applicationFilePath()).fileName().toLocal8Bit().constData()
-               << "[-p port] [-gui] filename";
+               << "[-v] [-p port] [-gui] filename";
     exit(-1);
 }
 
@@ -43,7 +47,10 @@ int main(int argc, char **argv)
     // Parse the command-line.

src/main.cpp int main(int argc, char **argv) · line 56

Quoted 10 lines
src/main.cpp +4 -1
     index = 1;
     for (index = 1; index < argc; index++) {
-        if (strcmp(argv[index],"-p") == 0) {
+        if (strcmp(argv[index],"-v") == 0) {
+            qWarning() << VERSION;
+            exit(0);
+        } else if (strcmp(argv[index],"-p") == 0) {
             index++;
             if (index >= argc) {
                 qWarning() << "ERROR: Got -p but missing port number";

So this is all you need. And nothing more.

Regards

Marcel