diff options
Diffstat (limited to 'scaf')
-rw-r--r-- | scaf/Makefile | 30 | ||||
-rw-r--r-- | scaf/README | 18 | ||||
-rw-r--r-- | scaf/pdp/Makefile | 2 | ||||
-rw-r--r-- | scaf/pdp/pdp_ca.c | 66 |
4 files changed, 100 insertions, 16 deletions
diff --git a/scaf/Makefile b/scaf/Makefile index 2ac26a5..783b459 100644 --- a/scaf/Makefile +++ b/scaf/Makefile @@ -4,19 +4,39 @@ all: pdp_scaf.pd_linux pdp_scaf_all: make -C include - make -C system - make -C modules + make -C compiler + make -C rules make -C pdp clean: rm -f *~ rm -f pdp_scaf.pd_linux make -C include clean - make -C system clean - make -C modules clean + make -C compiler clean + make -C rules clean make -C pdp clean +mrproper: clean + rm -rf configure + rm -rf Makefile.config + rm -rf config.status + rm -rf config.log + rm -rf autom4te.cache pdp_scaf.pd_linux: pdp_scaf_all rm -f pdp_scaf.pd_linux - gcc -export_dynamic -shared -o pdp_scaf.pd_linux pdp/*.o system/scaf_feeder.o $(PDP_CA_LIBS) + gcc -export_dynamic -shared -o pdp_scaf.pd_linux pdp/*.o $(PDP_CA_LIBS) + +install: all + install -d $(prefix)/lib/scaf + install -m 755 compiler/scafc $(prefix)/bin + install -m 755 compiler/scafc.pl $(prefix)/lib/scaf + install -m 644 compiler/kernel.scaf $(prefix)/lib/scaf + install -m 644 compiler/scafmacro.s $(prefix)/lib/scaf + install -m 644 compiler/optim.rules $(prefix)/lib/scaf + install -m 755 rules/carules.scafo $(prefix)/lib/scaf/default.scafo + #Check if pd is installed in $(prefix)/lib/pd. + #If this fails the pdp_scaf lib and the docs won't be installed. + test -d $(prefix)/lib/pd + install -m 755 pdp_scaf.pd_linux $(prefix)/lib/pd/externs + install -m 644 doc/*.pd $(prefix)/lib/pd/doc/5.reference diff --git a/scaf/README b/scaf/README index 60ee4dd..e71d1c9 100644 --- a/scaf/README +++ b/scaf/README @@ -51,12 +51,16 @@ Requirements: Building: -Edit Makefile.config to reflect your system settings. For now this -should be the pd dir, the pdp dir and the pdp_scaf dir. - -type "make" in the top directory. Remember to type "make clean all" -after editing Makefile.config +./configure +make +make install +If you don't have both libraries in the same dir and want to keep +it that way, hardcode the paths in Makefile.config.in and run +configure. You need to do "make install" to install the scaf compiler +"scafc" and the default ruleset. This is to be able to load plain +(text) rule files and have the default rules loaded when you create +a pdp_ca object. Using: @@ -71,9 +75,9 @@ Directory structure: include/ header files pdp/ pdp external code -system/ forth system code +compiler/ forth system code test/ some test patches (cryptic doc) -modules/ ca rule libraries +rules/ ca rule libraries diff --git a/scaf/pdp/Makefile b/scaf/pdp/Makefile index 73c8892..5ec8a0d 100644 --- a/scaf/pdp/Makefile +++ b/scaf/pdp/Makefile @@ -2,7 +2,7 @@ current: all_modules include ../Makefile.config -OBJECTS = pdp_ca.o pdp_ca_system.o +OBJECTS = pdp_ca.o pdp_ca_system.o scaf_feeder.o all_modules: $(OBJECTS) diff --git a/scaf/pdp/pdp_ca.c b/scaf/pdp/pdp_ca.c index f9180cb..9724912 100644 --- a/scaf/pdp/pdp_ca.c +++ b/scaf/pdp/pdp_ca.c @@ -33,6 +33,8 @@ t_class *pdp_image2ca_class; // converter from grey/yv12 -> ca // *********************** CA CLASS STUFF ********************* +// this is defined in the makefile +// #define PDP_CA_RULES_LIB "/path/default.scafo" #define PDP_CA_STACKSIZE 256 #define PDP_CA_MODE_1D 1 @@ -64,6 +66,7 @@ typedef struct pdp_ca_struct char *x_ca_rulenames; int x_ca_nbrules; char ** x_ca_rulename; + t_symbol *x_lastrule; /* nb of iterations */ int x_iterations; @@ -477,6 +480,7 @@ static void pdp_ca_rule_string(t_pdp_ca *x, char *c) /* ok, so store routine address */ else{ x->x_ca_routine = ca_routine; + x->x_lastrule = gensym(c); } } @@ -503,7 +507,7 @@ static void pdp_ca_rule_index(t_pdp_ca *x, t_float f) /* set rule by index */ pdp_ca_rule_string(x, x->x_ca_rulename[i]); - + } @@ -534,7 +538,8 @@ static void pdp_ca_printrules(t_pdp_ca *x) } -static void pdp_ca_open(t_pdp_ca *x, t_symbol *s) +/* open code library */ +static void pdp_ca_openlib(t_pdp_ca *x, t_symbol *s) { char *c; @@ -545,8 +550,9 @@ static void pdp_ca_open(t_pdp_ca *x, t_symbol *s) /* try to open new lib */ if (!(x->x_ca_libhandle = dlopen(s->s_name, RTLD_NOW))){ - post("pdp_ca: can't open ca library %s, %s", s->s_name, dlerror()); + post("pdp_ca: can't open ca library %s\n%s", s->s_name, dlerror()); x->x_ca_libhandle = 0; + return; } /* scan for valid rules */ @@ -579,10 +585,59 @@ static void pdp_ca_open(t_pdp_ca *x, t_symbol *s) /* print rule names */ //pdp_ca_printrules(x); + /* set last selected rule */ + pdp_ca_rule(x, x->x_lastrule); } +/* compile source file and open resulting code library */ +static void pdp_ca_opensrc(t_pdp_ca *x, t_symbol *s) +{ + #define TMPSIZE 1024 + char commandline[TMPSIZE]; + char library[TMPSIZE]; + int status; + + /* setup compiler args */ + snprintf(library, TMPSIZE, "%so", s->s_name); + snprintf(commandline, TMPSIZE, "scafc %s %s", s->s_name, library); + + + + /* call compiler */ + if (system(commandline)) + { + post ("pdp_ca: error compiling %s", s->s_name); + } + else + { + post("pdp_ca: compiled %s", s->s_name); + pdp_ca_openlib(x, gensym(library)); + } +} + +/* open a source file or a library, depending on extension */ +static void pdp_ca_open(t_pdp_ca *x, t_symbol *s) +{ + char *name = s->s_name; + char *end = name; + while(*end) end++; + if (end == name){ + post("pdp_ca: invalid file name"); + return; + } + /* if the name ends with 'o' assume it is a library */ + if (end[-1] == 'o'){ + pdp_ca_openlib(x, s); + } + /* otherwize, assume it is a source file */ + else{ + pdp_ca_opensrc(x, s); + } + +} + /* init the current packet with random noise */ static void pdp_ca_rand(t_pdp_ca *x){ @@ -736,6 +791,8 @@ void *pdp_ca_new(void) pdp_ca_fullscreen1d(x, 0); x->x_packet_type = gensym("grey"); + x->x_lastrule = gensym("gameoflife"); + pdp_ca_openlib(x, gensym(PDP_CA_RULES_LIB)); return (void *)x; } @@ -878,9 +935,12 @@ void pdp_ca_setup(void) class_addmethod(pdp_ca_class, (t_method)pdp_ca_printrules, gensym("rules"), A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_rand, gensym("random"), A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_newca, gensym("ca"), A_FLOAT, A_FLOAT, A_NULL); + class_addmethod(pdp_ca_class, (t_method)pdp_ca_newca, gensym("dim"), A_FLOAT, A_FLOAT, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_horshift16, gensym("hshift16"), A_FLOAT, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_vershift, gensym("vshift"), A_FLOAT, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_close, gensym("close"), A_NULL); + class_addmethod(pdp_ca_class, (t_method)pdp_ca_openlib, gensym("openlib"), A_SYMBOL, A_NULL); + class_addmethod(pdp_ca_class, (t_method)pdp_ca_opensrc, gensym("opensrc"), A_SYMBOL, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_open, gensym("open"), A_SYMBOL, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_rule, gensym("rule"), A_SYMBOL, A_NULL); class_addmethod(pdp_ca_class, (t_method)pdp_ca_rule_index, gensym("ruleindex"), A_FLOAT, A_NULL); |