-# Makefile for RIGHT ON COMMAND-LINE
+### Makefile for RIGHT ON COMMAND-LINE
-#----- Configuration stuff --------------------------------------------------
-
-# --- Compiling and linking ---
+###--------------------------------------------------------------------------
+### Configuration stuff.
+## Compiling and linking.
CC = gcc
-INCLUDES =
-CFLAGS = -O2 -g -pedantic -Wall $(INCLUDES)
+INCLUDES = -I/usr/include/tcl
+CFLAGS = \
+ -O2 -g -Wall -fPIC -funroll-loops -fomit-frame-pointer \
+ $(INCLUDES)
LD = gcc
LDFLAGS = -shared
-# --- Installation ---
-
+## Installation.
INST =
prefix = /usr/local
tcllibdir = $(prefix)/lib
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.0.0
+VERSION = $(shell ./auto-version)
TCLSCRIPTS = \
elite-editor elite-pairs elite-path elite-find elite-map \
- elite-prices elite-describe elite-reach
+ elite-prices elite-describe elite-reach elite-cmdr elite-salesman \
+ elite-tantalus
+
+SRCFILES = elite.c vec.c vec.h graph.c
+
+PKGFILES = elite.so vec.so graph.so elite.tcl
-all: elite.so pkgIndex.tcl
+all: $(PKGFILES) pkgIndex.tcl
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 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: elite.so elite.tcl
- echo "pkg_mkIndex -verbose -direct . elite.so elite.tcl" | tclsh
+pkgIndex.tcl: $(PKGFILES)
+ LD_LIBRARY_PATH=$$(pwd) \
+ echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | \
+ tclsh
install: all
$(INSTALL) -d $(INST)$(bindir) $(INST)$(pkglibdir)
- $(INSTALL) -m 644 elite.so elite.tcl pkgIndex.tcl $(INST)$(pkglibdir)
+ $(INSTALL) -m 644 $(PKGFILES) pkgIndex.tcl $(INST)$(pkglibdir)
$(INSTALL) -m 755 $(TCLSCRIPTS) $(INST)$(bindir)
clean:
- $(RM) -f elite.o elite.so pkgIndex.tcl
-
-DISTDIR = $(PACKAGE)-$(VERSION)
-DISTFILES = README Makefile elite.c elite.def $(TCLSCRIPTS)
+ $(RM) -f *.o *.so pkgIndex.tcl
+
+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 \
+ debian/compat debian/source/format
distdir: $(DISTFILES)
- $(RM) -rf $(DISTDIR)
- mkdir $(DISTDIR)
- for i in $(DISTFILES); do ln -s ../$$i $(DISTDIR); done
-dist: distdir
- tar chofz $(DISTDIR).tar.gz $(DISTDIR)
- $(RM) -rf $(DISTDIR)
-
-.PHONY: all install clean dist distdir
-
-#----- That's all, folks ----------------------------------------------------
+ $(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 $(INST)$(distdir).tar.gz $(distdir)
+distzip: distdir
+ cd $(distdir) && zip -rq ../$(INST)$(distdir).zip .
+dist: disttar distzip
+ $(RM) -rf $(distdir)
+distcheck: dist
+ @echo "*** Packing..."
+ $(MAKE) dist
+ @echo "*** Unpacking..."
+ tar xfz $(distdir).tar.gz
+ @echo "*** Test building..."
+ set -e; \
+ cd $(distdir); \
+ $(MAKE) clean; \
+ $(MAKE); \
+ $(MAKE) install INST=inst; \
+ $(MAKE) dist
+ @echo "*** Tidying up..."
+ rm -rf $(distdir)
+ @echo "*** All OK"
+
+.PHONY: all install clean dist disttar distzip distdir distcheck
+
+###----- That's all, folks --------------------------------------------------