aboutsummaryrefslogtreecommitdiff
path: root/scaf
diff options
context:
space:
mode:
authorTom Schouten <doelie@users.sourceforge.net>2003-02-28 09:57:32 +0000
committerTom Schouten <doelie@users.sourceforge.net>2003-02-28 09:57:32 +0000
commitfa3fa16330b07b13c8d11f1c83f090c328247547 (patch)
tree14920edb0f4248cd8f0953caa88644498ff12602 /scaf
parent240da8f9db69b36778b5bc90701968935ff82413 (diff)
pdp scaf
svn path=/trunk/externals/pdp/; revision=443
Diffstat (limited to 'scaf')
-rw-r--r--scaf/Makefile.config34
-rw-r--r--scaf/Makefile.config.in30
-rw-r--r--scaf/compiler/Makefile6
-rw-r--r--scaf/compiler/kernel.scaf (renamed from scaf/system/kernel.scaf)0
-rw-r--r--scaf/compiler/optim.rules (renamed from scaf/system/optim.rules)0
-rwxr-xr-xscaf/compiler/scafc44
-rwxr-xr-xscaf/compiler/scafc.pl (renamed from scaf/system/scafc.pl)0
-rw-r--r--scaf/compiler/scafmacro.s (renamed from scaf/system/scafmacro.s)0
-rw-r--r--scaf/configure.ac53
-rw-r--r--scaf/doc/pdp_ca.pd78
-rw-r--r--scaf/modules/Makefile21
-rw-r--r--scaf/pdp/scaf_feeder.s (renamed from scaf/system/scaf_feeder.s)3
-rw-r--r--scaf/rules/Makefile14
-rw-r--r--scaf/rules/carules.scaf (renamed from scaf/modules/carules.scaf)0
-rw-r--r--scaf/system/Makefile21
-rw-r--r--scaf/system/scaf_feeder_test.c30
16 files changed, 227 insertions, 107 deletions
diff --git a/scaf/Makefile.config b/scaf/Makefile.config
deleted file mode 100644
index c41fd37..0000000
--- a/scaf/Makefile.config
+++ /dev/null
@@ -1,34 +0,0 @@
-# pd's directory
-PD_DIR = /home/tom/pd/distro/pd
-PDP_DIR = /home/tom/pd/packet
-
-#PD_DIR = /usr/local/pd
-#PDP_DIR = /usr/local/pdp
-
-SCAF_DIR = $(PDP_DIR)/scaf
-
-
-
-
-# build flags
-
-PDP_CA_INCLUDE = -I$(PD_DIR)/src -I$(PDP_DIR)/include -I$(SCAF_DIR)/include
-PDP_CA_LIBS = -ldl
-PDP_CA_AFLAGS =
-#--gstabs
-PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
- -Wall -W -Wstrict-prototypes -Werror \
- -Wno-unused -Wno-parentheses -Wno-switch -g
-# -Wshadow
-
-# compiler and assembler
-#CC = gcc-3.2
-CC = gcc
-AS = as
-
-# build rules
-
-.c.o:
- $(CC) $(PDP_CA_CFLAGS) $(PDP_CA_INCLUDE) -o $*.o -c $*.c
-.s.o:
- $(AS) -o $*.o $*.s $(PDP_CA_AFLAGS)
diff --git a/scaf/Makefile.config.in b/scaf/Makefile.config.in
new file mode 100644
index 0000000..12927d3
--- /dev/null
+++ b/scaf/Makefile.config.in
@@ -0,0 +1,30 @@
+# build flags
+
+# define the include paths here if configure can't find them
+# PDP_CFLAGS=-I/somehere/pdp/include
+# PD_CFLAGS=-I/somewhere/pd/src
+
+
+prefix=@prefix@
+PDP_CA_INCLUDE = @CPPFLAGS@
+PDP_CA_LIBS = @LIBS@
+DEFAULT_RULES_LIB = @DEFAULT_RULES_LIB@
+PDP_CA_AFLAGS =
+#--gstabs
+PDP_CA_CFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer -ffast-math \
+ -Wall -W -Wstrict-prototypes -Werror \
+ -Wno-unused -Wno-parentheses -Wno-switch -g $(PDP_CFLAGS) $(PD_CFLAGS) \
+ -DPDP_CA_RULES_LIB=\"$(DEFAULT_RULES_LIB)\"
+# -Wshadow
+
+# compiler and assembler
+#CC = gcc-3.2
+#CC = gcc
+#AS = as
+
+# build rules
+
+.c.o:
+ $(CC) $(PDP_CA_CFLAGS) $(PDP_CA_INCLUDE) $(PDP_CA_DEFS) -o $*.o -c $*.c
+.s.o:
+ $(AS) -o $*.o $*.s $(PDP_CA_AFLAGS)
diff --git a/scaf/compiler/Makefile b/scaf/compiler/Makefile
new file mode 100644
index 0000000..16e82cd
--- /dev/null
+++ b/scaf/compiler/Makefile
@@ -0,0 +1,6 @@
+all:
+
+clean:
+ rm -f *~
+ rm -f *.o
+
diff --git a/scaf/system/kernel.scaf b/scaf/compiler/kernel.scaf
index 0bc2788..0bc2788 100644
--- a/scaf/system/kernel.scaf
+++ b/scaf/compiler/kernel.scaf
diff --git a/scaf/system/optim.rules b/scaf/compiler/optim.rules
index 282caf4..282caf4 100644
--- a/scaf/system/optim.rules
+++ b/scaf/compiler/optim.rules
diff --git a/scaf/compiler/scafc b/scaf/compiler/scafc
new file mode 100755
index 0000000..ae800e5
--- /dev/null
+++ b/scaf/compiler/scafc
@@ -0,0 +1,44 @@
+#!/bin/sh
+#scaf->scafo compiler
+
+if test "xx$1" == "xx"
+then
+ echo
+ echo "scaf rules compiler"
+ echo "usage:"
+ echo " scafc source [dest]"
+ echo
+ exit 0
+fi
+
+if test "xx$2" == "xx"
+then
+ DEST=$1o
+else
+ DEST=$2
+fi
+
+if ! test -f $1
+then
+ echo "source module $1 not found."
+ exit 1
+fi
+
+SCAFDIR=`dirname $0`
+if ! test -f $SCAFDIR/scafc.pl;
+then
+ SCAFDIR=`dirname $SCAFDIR`
+ SCAFDIR="$SCAFDIR/lib/scaf"
+ if ! test -f $SCAFDIR/scafc.pl
+ then
+ echo "scaf library not found in $SCAFDIR"
+ exit 1
+ fi
+fi
+
+TMP_S=`tempfile -s .s`
+$SCAFDIR/scafc.pl -I$SCAFDIR $1 > $TMP_S \
+&& gcc -export_dynamic -shared -o $DEST $TMP_S \
+&& strip --strip-unneeded $DEST \
+&& rm $TMP_S \
+|| exit 1
diff --git a/scaf/system/scafc.pl b/scaf/compiler/scafc.pl
index ee6b969..ee6b969 100755
--- a/scaf/system/scafc.pl
+++ b/scaf/compiler/scafc.pl
diff --git a/scaf/system/scafmacro.s b/scaf/compiler/scafmacro.s
index 04e6537..04e6537 100644
--- a/scaf/system/scafmacro.s
+++ b/scaf/compiler/scafmacro.s
diff --git a/scaf/configure.ac b/scaf/configure.ac
new file mode 100644
index 0000000..4b15a18
--- /dev/null
+++ b/scaf/configure.ac
@@ -0,0 +1,53 @@
+AC_INIT(pdp/pdp_ca_system.c)
+AC_PROG_CC
+AC_HEADER_STDC
+
+dnl default install prefix is /usr/local
+if test $prefix == "NONE";
+then
+ prefix=/usr/local
+fi
+
+AC_PATH_PROG(PDP_CONFIG,pdp-config,"no", $PATH)
+
+AC_CHECK_LIB(m,sin)
+AC_CHECK_LIB(dl,dlopen,, echo libdl not found. sorry... || exit 1)
+
+
+TOPSRC=`pwd`
+PARENT=`dirname $TOPSRC`
+
+dnl if pdp-config is found use it to get the cflags
+if ! test $PDP_CONFIG == "no"
+then
+ PDP_CPPFLAGS=`$PDP_CONFIG --cflags`
+
+dnl if not, check in the parent dir (in case we are distributed with the pdp package)
+elif test -f $PARENT/include/pdp.h
+then
+ PDP_CPPFLAGS="-I$PARENT/include"
+fi
+
+CPPFLAGS="$CPPFLAGS $PDP_CPPFLAGS"
+AC_CHECK_HEADER(m_pd.h,,PD_OK=no)
+AC_CHECK_HEADER(pdp.h,,PDP_OK=no)
+
+if test PD_OK == "no";
+then
+ echo "WARNING: m_pd.h not found. Is PD installed?
+ echo "WARNING: You can ignore this warning if you have set the PD_CFLAGS manually in Makefile.config.in
+fi
+
+if test PDP_OK == "no";
+then
+ echo "WARNING: pdp.h not found. Is PDP installed?
+ echo "WARNING: You can ignore this warning if you have set the PDP_CFLAGS manually in Makefile.config.in
+fi
+
+CPPFLAGS="$CPPFLAGS $PDFLAGS $PDPFLAGS -I$TOPSRC/include"
+
+DEFAULT_RULES_LIB=$prefix/lib/scaf/default.scafo;
+AC_SUBST(DEFAULT_RULES_LIB)
+
+AC_CONFIG_FILES(Makefile.config)
+AC_OUTPUT
diff --git a/scaf/doc/pdp_ca.pd b/scaf/doc/pdp_ca.pd
new file mode 100644
index 0000000..64e7e27
--- /dev/null
+++ b/scaf/doc/pdp_ca.pd
@@ -0,0 +1,78 @@
+#N canvas 62 0 753 664 10;
+#X obj 46 613 pdp_ca;
+#X obj 45 254 metro 40;
+#X msg 45 206 bang;
+#X msg 84 206 stop;
+#X msg 184 340 random;
+#X msg 181 137 rule gameoflife;
+#X floatatom 185 586 5 0 0 0 - - -;
+#X obj 185 558 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X obj 46 638 pdp_ca2image;
+#X msg 181 215 rules;
+#X msg 185 434 close;
+#X floatatom 96 228 5 0 0 0 - - -;
+#X obj 46 662 pdp_xv;
+#X floatatom 183 285 5 0 0 0 - - -;
+#X msg 183 314 vshift \$1;
+#X msg 185 486 2D;
+#X msg 185 535 fullscreen1D \$1;
+#X obj 185 513 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0
+1;
+#X text 197 606 1st inlet: active input (bang or ca);
+#X text 197 621 2nd inlet: passive input (ca);
+#X text 196 638 3rd inlet: nb of iterations;
+#X text 307 137 set a rule by name;
+#X text 308 206 print rules in library;
+#X msg 181 187 ruleindex \$1;
+#X text 307 183 set a rule by index;
+#X floatatom 181 165 5 0 0 0 - - -;
+#X text 313 534 off: compute one line at a time;
+#X text 313 548 on: update entire image (all lines);
+#X text 313 520 specify how to compute a 1D ca;
+#X text 313 464 interpret rules as a 1D ca with (space+time);
+#X text 313 493 interpret rules as a 2D ca with (space);
+#X msg 185 465 1D;
+#X text 314 436 close current library;
+#X obj 179 43 openpanel;
+#X msg 179 66 open \$1;
+#X msg 184 370 dim 64 64;
+#X text 314 371 set ca dimensions;
+#X obj 179 24 bng 15 250 50 0 empty empty empty 0 -6 0 8 -262144 -1
+-1;
+#X text 306 22 open a source rule file or compiled rule library;
+#X text 306 38 (when it's a source file \, make sure the "scafc" compiler
+is in the system path);
+#X msg 340 70 opensrc \$1;
+#X msg 446 70 openlib \$1;
+#X text 306 72 use;
+#X text 419 71 and;
+#X text 306 89 to explicitly open source or library;
+#X text 314 342 init ca with random noise;
+#X text 314 312 vertical shift compensation;
+#X text 181 257 bang computes next iteration(s);
+#X msg 185 397 dim 512 512;
+#X connect 0 0 8 0;
+#X connect 1 0 0 0;
+#X connect 2 0 1 0;
+#X connect 3 0 1 0;
+#X connect 4 0 0 0;
+#X connect 5 0 0 0;
+#X connect 6 0 0 2;
+#X connect 7 0 6 0;
+#X connect 8 0 12 0;
+#X connect 9 0 0 0;
+#X connect 10 0 0 0;
+#X connect 11 0 1 1;
+#X connect 13 0 14 0;
+#X connect 14 0 0 0;
+#X connect 15 0 0 0;
+#X connect 16 0 0 0;
+#X connect 17 0 16 0;
+#X connect 23 0 0 0;
+#X connect 25 0 23 0;
+#X connect 33 0 34 0;
+#X connect 34 0 0 0;
+#X connect 35 0 0 0;
+#X connect 37 0 33 0;
+#X connect 48 0 0 0;
diff --git a/scaf/modules/Makefile b/scaf/modules/Makefile
deleted file mode 100644
index 7bb0dc9..0000000
--- a/scaf/modules/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-OBJ = carules.scafo
-
-SCAFDIR = ../system
-
-.SUFFIXES: .scaf
-.SUFFIXES: .scafo
-
-.scaf.o:
- $(SCAFDIR)/scafc.pl -I$(SCAFDIR) $*.scaf | as -o $*.o
-
-.o.scafo:
- gcc -export_dynamic -shared -o $*.scafo $*.o
- rm $*.o
- strip --strip-unneeded $*.scafo
-
-all: $(OBJ)
-
-clean:
- rm -f *.scafo
- rm -f *~
-
diff --git a/scaf/system/scaf_feeder.s b/scaf/pdp/scaf_feeder.s
index 1cd8fd3..e7ef3c6 100644
--- a/scaf/system/scaf_feeder.s
+++ b/scaf/pdp/scaf_feeder.s
@@ -16,7 +16,8 @@
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#
-.include "scafmacro.s"
+# for dup
+.include "../compiler/scafmacro.s"
# *rg is only used for returning the stack pointer
diff --git a/scaf/rules/Makefile b/scaf/rules/Makefile
new file mode 100644
index 0000000..997207c
--- /dev/null
+++ b/scaf/rules/Makefile
@@ -0,0 +1,14 @@
+OBJ = carules.scafo
+
+.SUFFIXES: .scaf
+.SUFFIXES: .scafo
+
+.scaf.scafo:
+ ../compiler/scafc $*.scaf
+
+all: $(OBJ)
+
+clean:
+ rm -f *.scafo
+ rm -f *.s
+ rm -f *~
diff --git a/scaf/modules/carules.scaf b/scaf/rules/carules.scaf
index 32aef4a..32aef4a 100644
--- a/scaf/modules/carules.scaf
+++ b/scaf/rules/carules.scaf
diff --git a/scaf/system/Makefile b/scaf/system/Makefile
deleted file mode 100644
index 2a07f4f..0000000
--- a/scaf/system/Makefile
+++ /dev/null
@@ -1,21 +0,0 @@
-all: scaf_feeder.o
-
-test: scaf_feeder_test
-
-OBJ = scaf_feeder_test.o scaf_feeder.o
-
-
-scaf_feeder_test: $(OBJ)
- gcc -o scaf_feeder_test *.o -g -ldl
-
-.s.o:
- as -o $*.o $*.s
-
-.c.o:
- gcc -c $*.c -o $*.o -g
-
-clean:
- rm -f *~
- rm -f *.o
- rm -f scaf_feeder_test
-
diff --git a/scaf/system/scaf_feeder_test.c b/scaf/system/scaf_feeder_test.c
deleted file mode 100644
index 23a2661..0000000
--- a/scaf/system/scaf_feeder_test.c
+++ /dev/null
@@ -1,30 +0,0 @@
-#include <dlfcn.h>
-
-void scaf_feeder_asm (void *tos, void *reg, void (*ca_rule)(), void *env);
-
-void ca_test() {}
-
-main()
-{
- int stack[256];
- int reg[8];
- int env[8];
-
- void *libhandle;
- void *ca_routine;
-
-
- if (!(libhandle = dlopen("../modules/test.scafo", RTLD_NOW))){
- printf("error: %s\n", dlerror());
- exit(1);
- }
-
- if (!(ca_routine = dlsym(libhandle, "carule_1"))){
- printf("error: %s\n", dlerror());
- exit(1);
- }
-
- scaf_feeder_asm(stack+254, reg, ca_routine, env);
-
- dlclose(libhandle);
-}