chiark / gitweb /
8a8d8a1289345e8991f9f4fb82db4ea18947d79e
[rocl] / Makefile
1 ### Makefile for RIGHT ON COMMAND-LINE
2
3 ###--------------------------------------------------------------------------
4 ### Configuration stuff.
5
6 ## Compiling and linking.
7 CC = gcc
8 INCLUDES =
9 CFLAGS = \
10         -O2 -g -Wall -fPIC -funroll-loops -fomit-frame-pointer \
11         $(INCLUDES)
12 LD = gcc
13 LDFLAGS = -shared
14
15 ## Installation.
16 INST =
17 prefix = /usr/local
18 tcllibdir = $(prefix)/lib
19 pkglibdir = $(tcllibdir)/elite
20 bindir = $(prefix)/bin
21
22 INSTALL = install
23 RM = rm
24
25 ###--------------------------------------------------------------------------
26 ### Main machinery.
27 ###
28 ### Shouldn't need to fiddle with this stuff.
29
30 PACKAGE = rocl
31 VERSION = $(shell ./auto-version)
32
33 TCLSCRIPTS = \
34         elite-editor elite-pairs elite-path elite-find elite-map \
35         elite-prices elite-describe elite-reach elite-cmdr elite-salesman \
36         elite-tantalus
37
38 SRCFILES = elite.c vec.c vec.h graph.c
39
40 PKGFILES = elite.so vec.so graph.so elite.tcl
41
42 all: $(PKGFILES) pkgIndex.tcl
43
44 elite.so: elite.o
45         $(LD) $(LDFLAGS) elite.o -o elite.so
46 vec.so: vec.o
47         $(LD) $(LDFLAGS) vec.o -o vec.so
48 graph.so: graph.o vec.so
49         $(LD) $(LDFLAGS) -Wl,-rpath,$(pkglibdir) graph.o vec.so -o graph.so
50 graph.o vec.o: vec.h
51
52 .SUFFIXES: .c .o
53 .c.o:; $(CC) -c $(CFLAGS) -o $@ $<
54
55 pkgIndex.tcl: $(PKGFILES)
56         LD_LIBRARY_PATH=$$(pwd) \
57           echo "pkg_mkIndex -verbose -direct -load Vec . $(PKGFILES) " | \
58           tclsh
59
60 install: all
61         $(INSTALL) -d $(INST)$(bindir) $(INST)$(pkglibdir)
62         $(INSTALL) -m 644 $(PKGFILES) pkgIndex.tcl $(INST)$(pkglibdir)
63         $(INSTALL) -m 755 $(TCLSCRIPTS) $(INST)$(bindir)
64
65 clean:
66         $(RM) -f *.o *.so pkgIndex.tcl
67
68 distdir = $(PACKAGE)-$(VERSION)
69 DISTFILES = \
70         COPYING README Makefile $(SRCFILES) elite.tcl steele.cmdr \
71         elite.def vec.def graph.def $(TCLSCRIPTS) auto-version \
72         debian/rules debian/control debian/copyright debian/changelog
73 distdir: $(DISTFILES)
74         $(RM) -rf $(distdir)
75         mkdir $(distdir) $(distdir)/debian
76         echo $(VERSION) >$(distdir)/RELEASE
77         for i in $(DISTFILES); do \
78           case $$i in \
79             */*) \
80               dir=$${i%/*}; \
81               up=`echo $$dir | sed 's:[^/]\+:..:g'`; \
82               mkdir -p $(distdir)/$$dir;; \
83             *) dir= up=;; \
84           esac; \
85           ln -s ../$$up/$$i $(distdir)/$$i; \
86         done
87 disttar: distdir
88         tar chofz $(INST)$(distdir).tar.gz $(distdir)
89 distzip: distdir
90         cd $(distdir) && zip -rq ../$(INST)$(distdir).zip .
91 dist: disttar distzip
92         $(RM) -rf $(distdir)
93 distcheck: dist
94         @echo "*** Packing..."
95         $(MAKE) dist
96         @echo "*** Unpacking..."
97         tar xfz $(distdir).tar.gz
98         @echo "*** Test building..."
99         set -e; \
100         cd $(distdir); \
101         $(MAKE) clean; \
102         $(MAKE); \
103         $(MAKE) install INST=inst; \
104         $(MAKE) dist
105         @echo "*** Tidying up..."
106         rm -rf $(distdir)
107         @echo "*** All OK"
108
109 .PHONY: all install clean dist disttar distzip distdir distcheck
110
111 ###----- That's all, folks --------------------------------------------------