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 15e4ae0f1eb983d28c66d84fe104baf35b875ca8..af7486da4c0eed0e80cd6e0938b21495db05d6cc 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 43494c7ebc9c38246b97222582f71dbe1476d3b7..e98fa850a53658bacf17ff452d03d2341c89afa9 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)