[mw-devel] MW3 r1141 - in trunk: . debian-template po src
welshbyte at sucs.org
welshbyte at sucs.org
Fri Dec 18 22:04:24 GMT 2009
Author: welshbyte
Date: 2009-12-18 22:04:24 +0000 (Fri, 18 Dec 2009)
New Revision: 1141
Added:
trunk/Makefile.common
Modified:
trunk/Makefile
trunk/debian-template/control
trunk/debian-template/postinst
trunk/debian-template/rules
trunk/mw.spec
trunk/po/
trunk/po/Makefile
trunk/src/Makefile
Log:
Build system rejig and packaging tweaks
- The build system is generally more aware of whether it's in an svn checkout
or a non-svn tree.
- Makefile.common was added to provide version numbers and path
variables, including working out what the VERSION_TWEAK should be.
- The export rule saves the svn rev to mw.rev so that the spec file and
makefiles can use it from a non-svn tree/tarball. This means the
specfile never needs to be changed with a sed command.
- Spec file and debian packaging have been updated, slightly simplified
and now install the .mo translation files.
- Now installs using DESTDIR as the root which is recommended in Debian
and Fedora.
- Now accepts a 'prefix' variable (to choose between /usr and
/usr/local, for example). /usr/local remains the default.
- Warns when you build in an svn checkout and svnversion isn't present.
- Top level makefile now has 'build' and 'clean' rules which just
propagate into the src/ and po/ directories ('build' is the default
rule for all makefiles now).
Modified: trunk/Makefile
===================================================================
--- trunk/Makefile 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/Makefile 2009-12-18 22:04:24 UTC (rev 1141)
@@ -1,38 +1,60 @@
-# this is duplicated here to get the filenames right
-VERSION_MAJOR= 2
-VERSION_MINOR= 16
-VERSION_TWEAK:= $(shell svnversion -c .|cut -d : -f 2)
-VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
+SRCROOT = $(CURDIR)
+include Makefile.common
-# the non source files that should get installed
-INSTALLFILES = colour help login.banner scripthelp talkhelp wizhelp COPYING INSTALL LICENSE README
+build:
+ $(MAKE) -C src $@
+ $(MAKE) -C po $@
-ifndef TMPDIR
-rpm deb:
- make TMPDIR=`mktemp -d` $@
-else
+ifeq ($(SVNVER),exported)
+# These rules can only be called from inside an exported tree
+install:
+ install -d $(DESTDIR)$(libdir)/mw
+ cp -a $(INSTALLFILES) $(DESTDIR)$(libdir)/mw/
+ $(MAKE) -C src $@
+ $(MAKE) -C po $@
+
+deb:
+ cp -a debian-template debian
+ dch --create --package mw3 -v $(VERSION) -c debian/changelog "Build mw3 $(VERSION) package"
+ debuild -e VERSION_TWEAK=$(VERSION_TWEAK) -us -uc -b
+
+tarball:
+ tar zchvf ../$(MWVERSION).tar.gz -C .. $(MWVERSION)
+
rpm: tarball
- rpmbuild -ta $(TMPDIR)/mw3-$(VERSION).tar.gz
+ rpmbuild -ta ../$(MWVERSION).tar.gz
+else
+# These rules can only be called from an svn working directory
+ifdef TMPDIR
+# A temp dir exists so svn export and palm off the invocation to the exported makefile
+export:
+ rm -rf $(TMPDIR)/$(MWVERSION)
+ svn export . $(TMPDIR)/$(MWVERSION)
+ # Store the svn rev so we don't need to use svnversion or sed any more
+ echo $(VERSION_TWEAK) > $(TMPDIR)/$(MWVERSION)/mw.rev
+
+install tarball rpm: export
+ $(MAKE) -C $(TMPDIR)/$(MWVERSION) $@
+ rm -rf $(TMPDIR)/$(MWVERSION)
+
deb: export
- cp -a $(TMPDIR)/mw3-$(VERSION)/debian-template $(TMPDIR)/mw3-$(VERSION)/debian
- dch --create --package mw3 -v $(VERSION) -c $(TMPDIR)/mw3-$(VERSION)/debian/changelog "Build mw3 $(VERSION) package"
- cd $(TMPDIR)/mw3-$(VERSION) && debuild -e VERSION_TWEAK=$(VERSION_TWEAK) -us -uc -b
- mv $(TMPDIR)/mw3_$(VERSION)*.deb .
- rm -rf $(TMPDIR)/mw3-$(VERSION)
+ $(MAKE) -C $(TMPDIR)/$(MWVERSION) $@
+ mv $(TMPDIR)/mw3_$(VERSION)*.deb $(CURDIR)/
+ rm -rf $(TMPDIR)/$(MWVERSION)
+else
+# A temp dir doesn't exist so create it and invoke this makefile again
+install deb export tarball rpm:
+ $(MAKE) TMPDIR=`mktemp -d` $@
+
endif
+endif
-install:
- install -d $(libdir)/mw
- cp -a $(INSTALLFILES) $(libdir)/mw/
- make -C src install
+clean:
+ $(MAKE) -C src $@
+ $(MAKE) -C po $@
-export:
- rm -rf $(TMPDIR)/mw3-$(VERSION)
- svn export . $(TMPDIR)/mw3-$(VERSION)
+version:
+ @echo $(VERSION)
-tarball: export
- mv $(TMPDIR)/mw3-$(VERSION)/mw.spec $(TMPDIR)/mw.spec
- sed -e 's/^.*%define changeset.*$$/%define changeset $(VERSION_TWEAK)/' < $(TMPDIR)/mw.spec > $(TMPDIR)/mw3-$(VERSION)/mw.spec
- tar zchvf $(TMPDIR)/mw3-$(VERSION).tar.gz -C $(TMPDIR) mw3-$(VERSION)
- rm -fr $(TMPDIR)/mw3-$(VERSION)
+.PHONY: build clean rpm deb tarball export install version
Added: trunk/Makefile.common
===================================================================
--- trunk/Makefile.common (rev 0)
+++ trunk/Makefile.common 2009-12-18 22:04:24 UTC (rev 1141)
@@ -0,0 +1,27 @@
+SVNVER = $(shell ( svnversion -c . 2>/dev/null || echo 0:0 ) | cut -d : -f 2)
+
+VERSION_MAJOR = 2
+VERSION_MINOR = 16
+
+ifeq ($(SVNVER),exported)
+# mw.rev is created after an export so we can rely on it to provide the svn rev here
+VERSION_TWEAK = $(shell cat $(SRCROOT)/mw.rev)
+else
+ifeq ($(SVNVER),0)
+$(warning failed to run svnversion, is it installed? VERSION_TWEAK will be set to 0)
+endif
+VERSION_TWEAK = $(SVNVER)
+endif
+
+VERSION = $(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
+
+MWVERSION = mw3-$(VERSION)
+
+prefix ?= /usr/local
+libdir ?= $(prefix)/lib
+bindir ?= $(prefix)/bin
+datadir ?= $(prefix)/share
+localstatedir ?= /var
+
+# The non source files that should get installed
+INSTALLFILES = colour help login.banner scripthelp talkhelp wizhelp COPYING INSTALL LICENSE README
Modified: trunk/debian-template/control
===================================================================
--- trunk/debian-template/control 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/debian-template/control 2009-12-18 22:04:24 UTC (rev 1141)
@@ -2,7 +2,7 @@
Section: misc
Priority: extra
Maintainer: Milliways Developers <mw-devel at lists.sucs.org>
-Build-Depends: cdbs, debhelper (>= 5), libreadline5-dev, libcurl4-dev | libcurl-dev, libmozjs-dev, libsqlite3-dev, subversion
+Build-Depends: cdbs, debhelper (>= 5), libreadline5-dev, libcurl4-dev | libcurl-dev, libmozjs-dev, libsqlite3-dev
Standards-Version: 3.7.2
Package: mw3
Modified: trunk/debian-template/postinst
===================================================================
--- trunk/debian-template/postinst 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/debian-template/postinst 2009-12-18 22:04:24 UTC (rev 1141)
@@ -26,7 +26,6 @@
chown mw:mw /var/lib/mw
chown mw:mw /var/run/mw
chmod 6711 /usr/bin/mw
-chmod 751 /usr/lib/mw/rooms
chmod 640 /usr/lib/mw/login.banner
chmod 644 /usr/lib/mw/colour/*
chmod 755 /var/log/mw
Modified: trunk/debian-template/rules
===================================================================
--- trunk/debian-template/rules 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/debian-template/rules 2009-12-18 22:04:24 UTC (rev 1141)
@@ -8,14 +8,14 @@
build: build-stamp
build-stamp: configure-stamp
dh_testdir
- $(MAKE) libdir=/usr/lib bindir=/usr/bin -C src
+ dh_auto_build -- prefix=/usr
touch $@
clean:
dh_testdir
dh_testroot
rm -f build-stamp configure-stamp
- $(MAKE) -C src clean
+ $(MAKE) clean
dh_clean
install: build
@@ -23,9 +23,7 @@
dh_testroot
dh_clean -k
dh_installdirs
- $(MAKE) libdir=$(CURDIR)/debian/mw3/usr/lib \
- bindir=$(CURDIR)/debian/mw3/usr/bin \
- localstatedir=$(CURDIR)/debian/mw3/var install
+ dh_auto_install -- prefix=/usr
rm $(CURDIR)/debian/mw3/usr/lib/mw/COPYING
rm $(CURDIR)/debian/mw3/usr/lib/mw/LICENSE
rm $(CURDIR)/debian/mw3/usr/lib/mw/README
Modified: trunk/mw.spec
===================================================================
--- trunk/mw.spec 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/mw.spec 2009-12-18 22:04:24 UTC (rev 1141)
@@ -1,4 +1,4 @@
-%{expand: %%define changeset %(svnversion -c .|cut -d : -f 2)}
+%{expand: %%global changeset %(cat mw.rev)}
Summary: Milliways III talker and BBS
Name: mw3
Version: 2.16.%{changeset}
@@ -20,12 +20,11 @@
%setup -q
%build
-cd src
-make libdir="%{_libdir}" bindir="%{_bindir}" VERSION_TWEAK=%{changeset}
-cd ..
+make libdir="%{_libdir}" bindir="%{_bindir}"
%install
-%makeinstall
+make DESTDIR=$RPM_BUILD_ROOT prefix=/usr libdir="%{_libdir}" install
+%find_lang mw
%clean
rm -fr $RPM_BUILD_ROOT
@@ -33,19 +32,17 @@
%pre
# Add the user "mw"
/usr/sbin/useradd -c "mw system" \
- -s /bin/nologin -r -d %{_libdir}/mw mw 2> /dev/null || :
+ -s /sbin/nologin -r -d %{_libdir}/mw mw 2> /dev/null || :
-%files
+%files -f mw.lang
%defattr (755,mw,mw)
%dir %{_libdir}/mw
%{_libdir}/mw/colour
-%attr(751,mw,mw) %{_libdir}/mw/rooms
%attr(755,mw,mw) %dir /var/log/mw
%attr(711,mw,mw) %dir /var/lib/mw
%attr(755,mw,mw) %dir /var/run/mw
%config %attr(640,mw,mw) %{_libdir}/mw/login.banner
%{_libdir}/mw/help
-%{_libdir}/mw/mudhelp
%{_libdir}/mw/scripthelp
%{_libdir}/mw/talkhelp
%{_libdir}/mw/wizhelp
Property changes on: trunk/po
___________________________________________________________________
Added: svn:ignore
+ *.mo
Modified: trunk/po/Makefile
===================================================================
--- trunk/po/Makefile 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/po/Makefile 2009-12-18 22:04:24 UTC (rev 1141)
@@ -1,15 +1,17 @@
+SRCROOT = $(CURDIR)/..
+include ../Makefile.common
+
POFILES = $(wildcard *.po)
MOFILES = $(POFILES:.po=.mo)
CODE = $(wildcard ../src/*.c) $(wildcard ../src/*.h)
-PREFIX ?= $(CURDIR)
-LCDIR = $(PREFIX)/share/locale
+LCDIR = $(datadir)/locale
CPY = Justin Mitchell <arthur at sucs.org>
BUGSTO = mw-devel at lists.sucs.org
-VER ?= svn
+build: $(MOFILES)
mw.pot: $(CODE)
- xgettext --package-version="$(VER)" --msgid-bugs-address="$(BUGSTO)" \
+ xgettext --package-version="$(VERSION)" --msgid-bugs-address="$(BUGSTO)" \
--copyright-holder="$(CPY)" --force-po --no-wrap -E --keyword=_ \
-o $@.new ../src/*.c ../src/*.h
mv $@.new $@
@@ -23,12 +25,12 @@
msgfmt -v $< -o $@
install: $(MOFILES)
- for m in $(^:.mo=); do\
- mkdir -p "$(LCDIR)/$$m/LC_MESSAGES"; \
- cp $$m.mo "$(LCDIR)/$$m/LC_MESSAGES"; \
+ @for m in $(^:.mo=); do\
+ mkdir -vp "$(DESTDIR)$(LCDIR)/$$m/LC_MESSAGES"; \
+ install -m 644 -T $$m.mo "$(DESTDIR)$(LCDIR)/$$m/LC_MESSAGES/mw.mo"; \
done
clean:
rm -rf *.mo share/
-.PHONY: merge install
+.PHONY: merge install build clean
Modified: trunk/src/Makefile
===================================================================
--- trunk/src/Makefile 2009-12-16 20:27:45 UTC (rev 1140)
+++ trunk/src/Makefile 2009-12-18 22:04:24 UTC (rev 1141)
@@ -1,24 +1,11 @@
-# install path is in /usr/local/lib, for historical reasons
-libdir ?= /usr/local/lib
-bindir ?= /usr/local/bin
-localstatedir ?= /var
+SRCROOT = $(CURDIR)/..
+include ../Makefile.common
+
LOGDIR := $(localstatedir)/log/mw
MSGDIR := $(localstatedir)/run/mw
STATEDIR := $(localstatedir)/lib/mw
HOMEPATH := $(libdir)/mw
-TMPDIR = /tmp
-# These two only for change after a branch
-VERSION_MAJOR= 2
-VERSION_MINOR= 16
-# Change this one on feature increases/fixes, return to 0 on branch
-ifndef VERSION_TWEAK
-VERSION_TWEAK= $(shell svnversion -c .|cut -d : -f 2)
-endif
-
-# Full version number
-VERSION=$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_TWEAK)
-
# Name of the js library (differs between distros)
JSLIB=$(shell if `echo "main(){}" | gcc -x c -ljs - 2> /dev/null`; then echo js; else echo mozjs; fi; rm -f a.out)
CFLAGS+=-I/usr/include/mozjs
@@ -39,9 +26,6 @@
DEFS+= -DSTATEDIR=\"$(STATEDIR)\"
DEFS+= -DMSGDIR=\"$(MSGDIR)\"
-### uncomment for add Electric fence
-#LDFLAGS+= -L. -lefence
-
### uncomment for gdb debugging
LDFLAGS+= -ggdb -g
CFLAGS+= -ggdb -g -D__NO_STRING_INLINE -fstack-protector-all
@@ -52,12 +36,9 @@
### Only ever uncomment for final release versions
DEFS+= -DRELEASE
-### Uncomment for release candidates that all users should be able to run
-#DEFS+= -DPUBLIC
-
CFLAGS += $(DEFS)
-all: mw
+build: mw
### The magic which lets us autogenerate dependencies
CFLAGS += -MMD
@@ -70,9 +51,8 @@
-include $(CODE:.c=.d)
-.PHONY: all install clean wipe test
+.PHONY: build install clean test
-
mw: user.o main.o read.o add.o folders.o new.o perms.o edit.o mod.o who.o\
locking.o echo.o getpass.o filter.o mesg.o strings.o special.o Parse.o\
newmain.o init.o talker.o talker_privs.o colour.o bork.o rooms.o alarm.o\
@@ -86,27 +66,24 @@
$(CC) $(LDFLAGS) -o $@ $^
install: mw
- install -Ds mw $(bindir)/mw
- install -d $(LOGDIR)
- install -d $(MSGDIR)
- install -d $(STATEDIR)
+ install -Ds mw $(DESTDIR)$(bindir)/mw
+ install -d $(DESTDIR)$(LOGDIR)
+ install -d $(DESTDIR)$(MSGDIR)
+ install -d $(DESTDIR)$(STATEDIR)
clean:
-rm -f *.o *.d mw del_user
-export: export.o perms.o strings.o special.o
- $(CC) $(LDFLAGS) -o $@ $^
-
ifndef TESTDIR
test:
make TESTDIR=$(CURDIR)/mwtest $@
else
-TESTFILES=colour help login.banner scripthelp talkhelp wizhelp
test:
mkdir -p "$(TESTDIR)"
cd "$(TESTDIR)" && mkdir -p mw run/mw log/mw lib/mw
- for d in $(TESTFILES); do \
+ for d in $(INSTALLFILES); do \
svn export --force ../$$d "$(TESTDIR)/mw/$$d"; \
done
make libdir="$(TESTDIR)" localstatedir="$(TESTDIR)"
+
endif
More information about the mw-devel
mailing list