Commit 8068df0b authored by Simon McVittie's avatar Simon McVittie

Conform to https://github.com/cgwalters/build-api

This resembles Autoconf, but is an independent implementation.
parent 87b64e94
/build/
/build-stamp
/config.status
/configure.mk
/configure-stamp
/debian/files
......
bindir := /usr/bin
libdir := /usr/lib
datadir := /usr/share
gamedatadir := ${datadir}
PYTHON := python3
-include configure.mk
pkgdatadir := ${gamedatadir}/game-data-packager
......@@ -70,8 +63,8 @@ default: $(png) $(svgz) $(json_from_data) $(launcher_json) \
out/bash_completion out/changelog.gz \
out/game-data-packager out/vfs.zip out/memento-mori-2.svg
configure.mk: tools/configure.py $(wildcard game_data_packager/*.py game_data_packager/*/*.py)
PYTHONPATH=. ${PYTHON} tools/configure.py > $@
configure.mk: configure game_data_packager/version.py
./config.status
out/CACHEDIR.TAG:
@mkdir -p out
......@@ -349,8 +342,7 @@ install:
mkdir -p $(DESTDIR)$(pkgdatadir)
cp -ar game_data_packager/ $(DESTDIR)$(pkgdatadir)/
python3 -m game_data_packager.version $(RELEASE) > out/installed-version.py
install -m0644 out/installed-version.py $(DESTDIR)$(pkgdatadir)/game_data_packager/version.py
install -m0644 out/version.py $(DESTDIR)$(pkgdatadir)/game_data_packager/
install -m0644 out/*.copyright $(DESTDIR)$(pkgdatadir)/
install -m0644 out/*.png $(DESTDIR)$(pkgdatadir)/
install -m0644 data/*.png $(DESTDIR)$(pkgdatadir)/
......@@ -363,7 +355,7 @@ install:
install -d $(DESTDIR)$(runtimedir)/
install runtime/gdp_launcher_base.py $(DESTDIR)$(runtimedir)/
install -m0644 out/installed-version.py $(DESTDIR)$(runtimedir)/gdp_launcher_version.py
install -m0644 out/version.py $(DESTDIR)$(runtimedir)/gdp_launcher_version.py
install runtime/gdp-launcher.py $(DESTDIR)$(runtimedir)/gdp-launcher
install runtime/openurl.py $(DESTDIR)$(runtimedir)/gdp-openurl
install -m0644 $(launcher_desktops) $(DESTDIR)$(runtimedir)/
......@@ -371,19 +363,19 @@ install:
install -m0644 runtime/missing-data.txt $(DESTDIR)$(runtimedir)/
install -m0644 $(launcher_json) $(DESTDIR)$(runtimedir)/
install -d $(DESTDIR)${gamedatadir}/quake/
install -m644 out/installed-version.py $(DESTDIR)${gamedatadir}/quake/gdp_launcher_version.py
install -m644 out/version.py $(DESTDIR)${gamedatadir}/quake/gdp_launcher_version.py
install -m755 runtime/gdp_launcher_base.py $(DESTDIR)${gamedatadir}/quake/quake-server
install -d $(DESTDIR)${gamedatadir}/quake2/
install -m644 out/installed-version.py $(DESTDIR)${gamedatadir}/quake2/gdp_launcher_version.py
install -m644 out/version.py $(DESTDIR)${gamedatadir}/quake2/gdp_launcher_version.py
install -m755 runtime/gdp_launcher_base.py $(DESTDIR)${gamedatadir}/quake2/quake2-server
install -d $(DESTDIR)${gamedatadir}/quake3/
install -m644 out/installed-version.py $(DESTDIR)${gamedatadir}/quake3/gdp_launcher_version.py
install -m644 out/version.py $(DESTDIR)${gamedatadir}/quake3/gdp_launcher_version.py
install -m755 runtime/gdp_launcher_base.py $(DESTDIR)${gamedatadir}/quake3/quake3-server
install -d $(DESTDIR)${gamedatadir}/quake4/
install -m644 out/installed-version.py $(DESTDIR)${gamedatadir}/quake4/gdp_launcher_version.py
install -m644 out/version.py $(DESTDIR)${gamedatadir}/quake4/gdp_launcher_version.py
install -m755 runtime/gdp_launcher_base.py $(DESTDIR)${gamedatadir}/quake4/quake4-dedicated
install -d $(DESTDIR)${libdir}/etqw/
install -m644 out/installed-version.py $(DESTDIR)${libdir}/etqw/gdp_launcher_version.py
install -m644 out/version.py $(DESTDIR)${libdir}/etqw/gdp_launcher_version.py
install -m755 runtime/gdp_launcher_base.py $(DESTDIR)${libdir}/etqw/etqw-dedicated
install -d $(DESTDIR)/etc/apparmor.d/
install -m0644 etc/apparmor.d/* $(DESTDIR)/etc/apparmor.d/
......
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2016 Simon McVittie <smcv@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# You can find the GPL license text on a Debian system under
# /usr/share/common-licenses/GPL-2.
'''
A broadly GNU-compatible configure script.
'''
# Magic tokens for <https://github.com/cgwalters/build-api>:
## buildapi-variable-no-builddir
import argparse
import os
import shlex
import sys
from game_data_packager.version import (
DISTRO,
FORMAT,
GAME_PACKAGE_VERSION,
)
class Configure:
def __init__(self):
self.consts = dict(
PACKAGE='game-data-packager',
VERSION=GAME_PACKAGE_VERSION,
)
self.vars = dict(
CFLAGS='',
CXXFLAGS='',
PYTHON=sys.executable,
RELEASE='',
)
for k in self.vars:
if k in os.environ:
self.vars[k] = os.environ[k]
self.dirs = dict(
bindir='${exec_prefix}/bin',
datadir='${datarootdir}',
datarootdir='${prefix}/share',
docdir='${datarootdir}/doc/${PACKAGE}',
dvidir='${docdir}',
exec_prefix='${prefix}',
htmldir='${docdir}',
includedir='${prefix}/include',
infodir='${datarootdir}/info',
libdir='${exec_prefix}/lib',
libexecdir='${exec_prefix}/libexec',
localedir='${datarootdir}/locale',
localstatedir='${prefix}/var',
mandir='${datarootdir}/man',
oldincludedir='/usr/include',
pdfdir='${docdir}',
prefix='/usr/local',
psdir='${docdir}',
runstatedir='${localstatedir}/run',
sbindir='${exec_prefix}/sbin',
sharedstatedir='${prefix}/com',
srcdir=os.path.dirname(sys.argv[0]) or '.',
sysconfdir='${prefix}/etc',
)
self.with_ = dict(
distro=DISTRO,
format=FORMAT,
gamedatadir='${datadir}',
)
self.parser = argparse.ArgumentParser(
allow_abbrev=False,
description='Configure game-data-packager',
)
for k, v in self.dirs.items():
self.parser.add_argument('--' + k, default=v)
for k, v in self.with_.items():
self.parser.add_argument('--with-' + k, default=v, dest=k)
self.parser.add_argument('--build', help='Ignored')
self.parser.add_argument('--host', help='Ignored')
self.parser.add_argument('--target', help='Ignored')
def warn(self, message):
sys.stderr.write('%s: warning: %s\n' % (sys.argv[0], message))
def run(self):
args, rest = self.parser.parse_known_args()
for k, v in vars(args).items():
if k in self.dirs:
self.dirs[k] = v
elif k in self.with_:
self.with_[k] = v
elif k in ('build', 'host', 'target'):
pass
else:
raise AssertionError('Unexpected: %r' % k)
for arg in rest:
if (arg.startswith('--with-') or arg.startswith('--without-') or
arg.startswith('--enable-') or
arg.startswith('--disable-')):
self.warn('Unknown with/without/enable/disable option %r' %
arg)
elif arg.startswith('-'):
self.parser.error('Unknown option %r' % arg)
elif '=' in arg:
k, v = arg.split('=', 1)
if k in self.vars:
self.vars[k] = v
else:
self.warn('Unknown variable %r' % arg)
else:
self.parser.error('Unknown argument %r' % arg)
command_line = ' '.join((shlex.quote(a) for a in sys.argv))
with open('config.status', 'w') as writer:
writer.write('#!/bin/sh\n')
writer.write('# Generated by the command below, do not edit\n')
writer.write(command_line)
writer.write('\n')
os.chmod('config.status', 0o755)
os.makedirs('out', exist_ok=True)
with open(os.path.join('out', 'version.py'), 'w') as writer:
writer.write('# Generated by %r, do not edit\n' % command_line)
writer.write('DISTRO = %r\n' % self.with_['distro'])
writer.write('FORMAT = %r\n' % self.with_['format'])
writer.write('GAME_PACKAGE_VERSION = %r\n' %
self.consts['VERSION'])
writer.write('GAME_PACKAGE_RELEASE = %r\n' %
self.vars['RELEASE'])
with open('configure.mk', 'w') as writer:
writer.write('# Generated by %r, do not edit' % command_line)
for k, v in sorted(self.consts.items()):
writer.write('%s = %s\n' % (k, v))
writer.write('\n')
for k, v in sorted(self.vars.items()):
writer.write('%s = %s\n' % (k, v))
writer.write('\n')
for k, v in sorted(self.dirs.items()):
writer.write('%s = %s\n' % (k, v))
writer.write('\n')
for k, v in sorted(self.with_.items()):
writer.write('%s = %s\n' % (k, v))
if __name__ == '__main__':
Configure().run()
......@@ -19,6 +19,8 @@ game-data-packager (47) UNRELEASED; urgency=medium
- Restructure doom2-masterlevels data [adetiste]
- Simplify creation of DEBIAN/control [smcv]
- Sort license files if there are multiple [smcv]
- Conform to https://github.com/cgwalters/build-api (vaguely imitating
Autoconf, but differently-implemented) [smcv]
-- Simon McVittie <smcv@debian.org> Sun, 30 Oct 2016 22:19:21 +0000
......
......@@ -11,10 +11,16 @@ include /usr/share/dpkg/pkg-info.mk
options := \
BUILD_DATE="$$(dpkg-parsechangelog --show-field=Date)" \
bindir='/usr/games' \
gamedatadir='/usr/share/games' \
$(NULL)
override_dh_auto_configure:
dh_auto_configure \
-- \
--bindir='$${exec_prefix}/games' \
--libdir='$${exec_prefix}/lib' \
--with-gamedatadir='$${datadir}/games' \
$(NULL)
override_dh_auto_build:
dh_auto_build \
-- \
......
#!/usr/bin/python3
# encoding=utf-8
#
# Copyright © 2016 Simon McVittie <smcv@debian.org>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# You can find the GPL license text on a Debian system under
# /usr/share/common-licenses/GPL-2.
import textwrap
from game_data_packager.packaging import (get_native_packaging_system)
def main():
print(get_native_packaging_system().substitute(textwrap.dedent('''
bindir := ${bindir}
datadir := ${datadir}
gamedatadir := ${assets}
'''), 'unknown-package-name'))
if __name__ == '__main__':
main()
......@@ -87,6 +87,7 @@ The following games currently require this package:
%autosetup
%build
%configure
make %{?_smp_mflags}
%check
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment