+def automakeRules(config):
+ r = RulesFile()
+ r.dh += ["--buildsystem=autoconf"]
+ r.rules['auto_configure'] = [
+ 'BUILD_TYPE=$$(dpkg-architecture -qDEB_BUILD_GNU_TYPE) && ' + # doing the expansion beforehand ensures that we cancel if it fails
+ 'MULTIARCH=$$(dpkg-architecture -qDEB_BUILD_MULTIARCH) && '+
+ './configure --build=$$BUILD_TYPE ' +
+ '--prefix=/usr --includedir=/usr/include --mandir=/usr/share/man --infodir=/usr/share/info ' +
+ '--libdir=/usr/lib/$$MULTIARCH --libexecdir=/usr/lib/$$MULTIARCH '+
+ '--sysconfdir=/etc --localstatedir=/var ' +
+ ' '.join(config.get('automakeParameters', []))
+ ]
+ r.rules['auto_clean'] = ['rm -f config.status'] # do not re-use old configuration
+ return r
+
+# utility functions
+def commandInBuildEnv(config, command):
+ schroot = config.get('schroot')
+ if schroot is not None: command = ['schroot', '-c', schroot, '--'] + command
+ return command
+
+def getArchitecture(config):
+ cmd = commandInBuildEnv(config, ['dpkg-architecture', '-qDEB_BUILD_ARCH'])
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+ res = p.communicate()[0] # get only stdout
+ if p.returncode != 0: raise Exception("Querying dpkg for the architecture failed")
+ return res[0:len(res)-1] # chop of the \n at the end
+