chiark / gitweb /
makedim multidim experiment
authorIan Jackson <ian@davenant.relativity.greenend.org.uk>
Wed, 16 Jan 2008 18:33:23 +0000 (18:33 +0000)
committerIan Jackson <ian@davenant.relativity.greenend.org.uk>
Wed, 16 Jan 2008 18:33:23 +0000 (18:33 +0000)
Makefile
makedim [new file with mode: 0755]
mgraph.h

index 15e4ae0..af7486d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,12 @@
 
 TARGETS= minimise primer view lumpy.cfm sgtatham.cfm ring.cfm
+SGTATHAM=sgtatham
 
 CWARNS=        -Wall -Wwrite-strings -Wpointer-arith -Werror -Wshadow
 CXXWARNS= $(CWARNS) -Wno-shadow -Wno-error
 
 OPTIMISE=      -O2
-CFLAGS=                -MMD $(OPTIMISE) -g $(CWARNS)
+CFLAGS=                -MMD $(OPTIMISE) -g $(CWARNS) $(DIMCFLAGS)
 CXXFLAGS=      -MMD $(OPTIMISE) -g $(CXXWARNS)
 
 LIBGSL= -lgsl -lgslcblas
@@ -26,7 +27,7 @@ prime.data:   primer
 view:          view.o common.o mgraph.o
                $(CC) $(CFLAGS) -o $@ $^ $(LIBGSL) -L/usr/X11R6/lib -lX11
 
-sgtatham.cfm:  sgtatham-regenerator prime.data sgtatham/z.typescript
+sgtatham.cfm:  sgtatham-regenerator prime.data $(SGTATHAM)/z.typescript
                ./$^ -T -o$@
 
 lumpy.cfm: oldmoebius-converter prime.data ../moebius/ins-new ../moebius/a.out
@@ -42,5 +43,6 @@ clean:
 
 realclean:     clean
                rm -f best
+               rm -rf dim,*
 
 -include *.d
diff --git a/makedim b/makedim
new file mode 100755 (executable)
index 0000000..8f5da37
--- /dev/null
+++ b/makedim
@@ -0,0 +1,18 @@
+#!/bin/sh
+set -e
+fail () { echo >&2 "$*"; exit 127; }
+badusage () { fail 'usage: makedim <xbits><ybits> [<targets>]'; }
+
+case $1 in
+[0-9][0-9]) ;;
+*) badusage ;;
+esac
+
+dim=$1; shift
+dir=dim,$dir
+
+x () { echo >&2 "    $*"; "$@"; }
+
+x make clean >/dev/null
+x mkdir -p $dir
+x make -C $dir DIMCFLAGS=-DDEFBITS=$dim PERLLIB=.. SGTATHAM=../sgtatham VPATH=.. -f ../Makefile "$@"
index 43494c7..e98fa85 100644 (file)
--- a/mgraph.h
+++ b/mgraph.h
 
 #include "common.h"
 
+#ifndef DEFBITS
 #define XBITS 3
-#define X (1<<XBITS)
 #define YBITS 3
+#else
+#define XBITS (DEFBITS / 10)
+#define YBITS (DEFBITS % 10)
+#endif
+
+#define X (1<<XBITS)
 #define Y ((1<<YBITS) - 1)
 
 #define N (X*Y)