Bug 67746 - Changing version in project options does not affect configure.in.in
Summary: Changing version in project options does not affect configure.in.in
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Build tools: Automake (show other bugs)
Version: 3.0.0b1
Platform: unspecified Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 71561 132436 (view as bug list)
Depends on:
Blocks:
 
Reported: 2003-11-10 10:09 UTC by Alexander Reinholdt
Modified: 2006-11-02 20:40 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Reinholdt 2003-11-10 10:09:14 UTC
Version:           3.0.0b1 (using KDE 3.1.4)
Installed from:     (testing/unstable)
Compiler:          gcc version 3.3.2 (Debian)
OS:          Linux (i686) release 2.4.22

Changing the version of a project in Project->Project Options->General does not affect the Makefiles, i.e. they are not regenerated (like in version 2.x). 

I wasn't able to find any other way or option to make it happen, so I think this is a bug.

Cheers,
Alexander
Comment 1 Jens Dagerbo 2003-11-13 18:17:43 UTC
Confirmed. It appears someone forgot to implement it... :)
Comment 2 Jens Dagerbo 2004-01-02 14:48:30 UTC
*** Bug 71561 has been marked as a duplicate of this bug. ***
Comment 3 Amilcar do Carmo Lucas 2004-03-25 15:03:03 UTC
This is a regression from KDevelop 2.x
Comment 4 Tyler Montbriand 2004-06-18 19:04:18 UTC
This still happens in kdevelop 3.0.3 under linux 2.6.4 gentoo amd64.  It
doesn't just affect config.h either, it also effects the output file name
and output file contents of 'make dist'.
Comment 5 Sebastien 2004-06-20 14:42:12 UTC
Even in KDevelop 3.0.4 it still here.

I'm obligated to find/replace (thank you KFindReplace) all version number by hand.

So, start a new project, and give it an unprobable version number (like "FooX452..bar;G" :-) ) and use KFindReplace to find all occurences, and be asured KDevelop update all those files when version number is changed.
With this process we could be sure the version will be REALLY changed.

My 1 cent.
Comment 6 Amilcar do Carmo Lucas 2004-07-19 22:59:23 UTC
Basicaly it only needs to change configure.in.in (In autotools based projects)
In other project types I'm not sure :(
Comment 7 grueffelokatze 2006-08-03 16:44:23 UTC
Bug stil in kdevelop version 3.3.3.
Comment 8 Amilcar do Carmo Lucas 2006-08-15 10:52:34 UTC
*** Bug 132436 has been marked as a duplicate of this bug. ***
Comment 9 Megan Webb 2006-10-29 00:33:59 UTC
r599871 /branches/kdevelop/3.4/src/ (generalinfowidget.cpp generalinfowidget.h)
 
When project/options/version is changed, update the configure.in file with the new version. 
Uses regex to update AC_INIT, AM_INIT_AUTOMAKE, and AC_DEFINE macros.
Build tools detect that configure.in is newer and rebuilds config.h with correct version.



Index: src/generalinfowidget.h
===================================================================
--- src/generalinfowidget.h	(revision 599866)
+++ src/generalinfowidget.h	(working copy)
@@ -47,6 +47,7 @@
     QString projectDirectory();
     void setProjectDirectoryError( const QString& error );
     void setProjectDirectorySuccess();
+    void configureinUpdateVersion( QString configureinpath, QString newVersion );
 };
 
 #endif
Index: src/generalinfowidget.cpp
===================================================================
--- src/generalinfowidget.cpp	(revision 599866)
+++ src/generalinfowidget.cpp	(working copy)
@@ -19,6 +19,8 @@
 #include <klocale.h>
 #include <kiconloader.h>
 #include <kcharsets.h>
+#include <qregexp.h>
+#include <kmessagebox.h>
 
 #include "generalinfowidget.h"
 #include "generalinfowidget.moc"
@@ -75,13 +77,103 @@
 	}
 
 }
+/**
+ * Update the configure.in file with the version value from project options.
+ * Very basic updating - uses regex to update the field in
+ * AC_INIT, AM_INIT_AUTOMAKE, and AC_DEFINE macros.
+ * On next make, the build system re-runs configure to update config.h
+ * version info.
+ *
+ * @param configureinpath Full path to configure.in file
+ * @param newVersion The new version number or string
+*/
+void GeneralInfoWidget::configureinUpdateVersion( QString configureinpath, QString newVersion )
+{
+    QFile configurein(configureinpath);
 
+    if ( !configurein.open( IO_ReadOnly ) ){
+        KMessageBox::error(this, i18n("Could not open %1 for reading.").arg(configureinpath));
+        return;
+    }
+
+    QTextStream stream( &configurein);
+    QStringList list;
+
+    // Options for version:
+
+    // we ignore old AC_INIT that had no version..
+    // only match the if there is a comma and at least two args..
+    // AC_INIT (package, version, [bug-report], [tarname])
+    QRegExp ac_init("^AC_INIT\\s*\\(\\s*([^,]+),([^,\\)]+)(.*)");
+
+    // AM_INIT_AUTOMAKE([OPTIONS])
+    // example: AM_INIT_AUTOMAKE([gnits 1.5 no-define dist-bzip2])
+    QRegExp am_autoSpace("^AM_INIT_AUTOMAKE\\s{0,}\\(\\s{0,}([\\[\\s]{0,}[^\\s]+)\\s+([^\\s\\)\\]]+)(.*)");
+
+    // AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+    QRegExp am_autoComma("^AM_INIT_AUTOMAKE\\s*\\(\\s*([^,]+),([^,\\)]+)(.*)");
+
+    // look for version in a define.
+    // AC_DEFINE(VERSION, "5.6")
+    QRegExp ac_define("^AC_DEFINE\\s*\\(");
+    QRegExp version("(\\bversion\\b)");
+    version.setCaseSensitive(FALSE);
+
+    while ( !stream.eof() ) {
+        QString line = stream.readLine();
+        if ( ac_init.search(line) >= 0){
+            line = "AC_INIT(" + ac_init.cap(1).stripWhiteSpace();
+            line += ", ";
+            line += newVersion;
+            line += ac_init.cap(3).stripWhiteSpace();
+        }
+        else if ( am_autoComma.search(line) >= 0 ){
+            line="AM_INIT_AUTOMAKE(";
+            line += am_autoComma.cap(1).stripWhiteSpace();
+            line += ", ";
+            line += newVersion;
+            line += am_autoComma.cap(3).stripWhiteSpace();
+        }
+        else if ( am_autoSpace.search(line) >= 0 ){
+            line = "AM_INIT_AUTOMAKE(" + am_autoSpace.cap(1).stripWhiteSpace();
+            line += " ";
+            line += newVersion;
+            line += " ";
+            line += am_autoSpace.cap(3).stripWhiteSpace();
+        }
+        else if ( ac_define.search(line) >=0 && version.search(line) >=0) {
+            // replace version in: AC_DEFINE(VERSION,"0.1")
+            line="AC_DEFINE(" + version.cap(1).stripWhiteSpace()+", \"" + newVersion +"\")";
+        }
+        list.push_back(line);
+    }
+    configurein.close();
+
+    // write our changes..
+    QFile configureout(configureinpath);
+    if ( !configureout.open( IO_WriteOnly ) ){
+        KMessageBox::error(this, i18n("Could not open %1 for writing.").arg(configureinpath));
+        return ;
+    }
+    QTextStream output( &configureout);
+    for(QStringList::iterator iter = list.begin();iter!=list.end();iter++){
+        output << (*iter) <<"\n";
+    }
+    configureout.close();
+
+}
+
+
 void GeneralInfoWidget::writeConfig() {
     DomUtil::writeEntry(m_projectDom,"/general/projectdirectory",project_directory_edit->text());
     DomUtil::writeBoolEntry(m_projectDom,"/general/absoluteprojectpath",isProjectDirectoryAbsolute());
     DomUtil::writeEntry(m_projectDom,"/general/email",email_edit->text());
     DomUtil::writeEntry(m_projectDom,"/general/author",author_edit->text());
     DomUtil::writeEntry(m_projectDom,"/general/email",email_edit->text());
+    if ( DomUtil::readEntry(m_projectDom,"/general/version") != version_edit->text() ){
+        // update the configure.in file.
+        configureinUpdateVersion( projectDirectory() + "/configure.in", version_edit->text() );
+    }
     DomUtil::writeEntry(m_projectDom,"/general/version",version_edit->text());
     DomUtil::writeEntry(m_projectDom,"/general/description",description_edit->text());
 
Comment 10 Matt Rogers 2006-10-29 02:25:17 UTC
Fixed in KDevelop 3.4 by revision 599871
Comment 11 Megan Webb 2006-11-02 20:40:04 UTC
Actually fixed in KDevelop 3.4 by revision 601133. 
I didn't notice this bug talking about configure.in.in. KDE use this to make the configure.in file. We now check for configure.in.in, configure.in and configure.ac and change the version.