chiark / gitweb /
Use `auto-version' for discovering the package version.
[rocl] / Makefile
index a2d917acbaaad5c8619b66149c608b24600c7336..8a8d8a1289345e8991f9f4fb82db4ea18947d79e 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,21 +1,18 @@
-# Makefile for RIGHT ON COMMAND-LINE
-#
-# $Id: Makefile,v 1.10 2003/03/11 09:46:36 mdw Exp $
+### Makefile for RIGHT ON COMMAND-LINE
 
-#----- Configuration stuff --------------------------------------------------
-
-# --- Compiling and linking ---
+###--------------------------------------------------------------------------
+### Configuration stuff.
 
+## Compiling and linking.
 CC = gcc
-INCLUDES = 
+INCLUDES =
 CFLAGS = \
-       -O2 -g -pedantic -Wall -funroll-loops -fomit-frame-pointer \
+       -O2 -g -Wall -fPIC -funroll-loops -fomit-frame-pointer \
        $(INCLUDES)
 LD = gcc
 LDFLAGS = -shared
 
-# --- Installation ---
-
+## Installation.
 INST =
 prefix = /usr/local
 tcllibdir = $(prefix)/lib
@@ -25,16 +22,18 @@ bindir = $(prefix)/bin
 INSTALL = install
 RM = rm
 
-#----- Main machinery -------------------------------------------------------
-#
-# Shouldn't need to fiddle with thiis stuff.
+###--------------------------------------------------------------------------
+### Main machinery.
+###
+### Shouldn't need to fiddle with this stuff.
 
 PACKAGE = rocl
-VERSION = 1.1.2
+VERSION = $(shell ./auto-version)
 
 TCLSCRIPTS = \
        elite-editor elite-pairs elite-path elite-find elite-map \
-       elite-prices elite-describe elite-reach elite-cmdr elite-salesman
+       elite-prices elite-describe elite-reach elite-cmdr elite-salesman \
+       elite-tantalus
 
 SRCFILES = elite.c vec.c vec.h graph.c
 
@@ -46,15 +45,17 @@ elite.so: elite.o
        $(LD) $(LDFLAGS) elite.o -o elite.so
 vec.so: vec.o
        $(LD) $(LDFLAGS) vec.o -o vec.so
-graph.so: graph.o
-       $(LD) $(LDFLAGS) graph.o -o graph.so
+graph.so: graph.o vec.so
+       $(LD) $(LDFLAGS) -Wl,-rpath,$(pkglibdir) graph.o vec.so -o graph.so
 graph.o vec.o: vec.h
 
 .SUFFIXES: .c .o
 .c.o:; $(CC) -c $(CFLAGS) -o $@ $<
 
 pkgIndex.tcl: $(PKGFILES)
-       echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | tclsh
+       LD_LIBRARY_PATH=$$(pwd) \
+         echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | \
+         tclsh
 
 install: all
        $(INSTALL) -d $(INST)$(bindir) $(INST)$(pkglibdir)
@@ -64,34 +65,47 @@ install: all
 clean:
        $(RM) -f *.o *.so pkgIndex.tcl
 
-DISTDIR = $(PACKAGE)-$(VERSION)
-DISTFILES = README Makefile $(SRCFILES) elite.tcl elite.def $(TCLSCRIPTS)
+distdir = $(PACKAGE)-$(VERSION)
+DISTFILES = \
+       COPYING README Makefile $(SRCFILES) elite.tcl steele.cmdr \
+       elite.def vec.def graph.def $(TCLSCRIPTS) auto-version \
+       debian/rules debian/control debian/copyright debian/changelog
 distdir: $(DISTFILES)
-       $(RM) -rf $(DISTDIR)
-       mkdir $(DISTDIR)
-       for i in $(DISTFILES); do ln -s ../$$i $(DISTDIR); done
+       $(RM) -rf $(distdir)
+       mkdir $(distdir) $(distdir)/debian
+       echo $(VERSION) >$(distdir)/RELEASE
+       for i in $(DISTFILES); do \
+         case $$i in \
+           */*) \
+             dir=$${i%/*}; \
+             up=`echo $$dir | sed 's:[^/]\+:..:g'`; \
+             mkdir -p $(distdir)/$$dir;; \
+           *) dir= up=;; \
+         esac; \
+         ln -s ../$$up/$$i $(distdir)/$$i; \
+       done
 disttar: distdir
-       tar chofz $(DISTDIR).tar.gz $(DISTDIR)
+       tar chofz $(INST)$(distdir).tar.gz $(distdir)
 distzip: distdir
-       cd $(DISTDIR) && zip -rq ../$(DISTDIR).zip .
+       cd $(distdir) && zip -rq ../$(INST)$(distdir).zip .
 dist: disttar distzip
-       $(RM) -rf $(DISTDIR)
+       $(RM) -rf $(distdir)
 distcheck: dist
        @echo "*** Packing..."
        $(MAKE) dist
        @echo "*** Unpacking..."
-       tar xfz $(DISTDIR).tar.gz
+       tar xfz $(distdir).tar.gz
        @echo "*** Test building..."
        set -e; \
-       cd $(DISTDIR); \
+       cd $(distdir); \
        $(MAKE) clean; \
        $(MAKE); \
        $(MAKE) install INST=inst; \
        $(MAKE) dist
        @echo "*** Tidying up..."
-       rm -rf $(DISTDIR)
+       rm -rf $(distdir)
        @echo "*** All OK"
 
 .PHONY: all install clean dist disttar distzip distdir distcheck
 
-#----- That's all, folks ----------------------------------------------------
+###----- That's all, folks --------------------------------------------------