[xiph-commits] r12297 - trunk/sushivision

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Jan 3 14:40:46 PST 2007


Author: xiphmont
Date: 2007-01-03 14:40:43 -0800 (Wed, 03 Jan 2007)
New Revision: 12297

Added:
   trunk/sushivision/example_chirpfit.c
   trunk/sushivision/sushivision.pc.in
Removed:
   trunk/sushivision/example_submain.c
Modified:
   trunk/sushivision/Makefile
   trunk/sushivision/example_fractal.c
   trunk/sushivision/main.c
   trunk/sushivision/panel-2d.c
   trunk/sushivision/sushivision.h
Log:
Add dl infrastructure for an optional sushiv_atexit()

retool makefile somewhat toward making this puppy actually field-installable

add a sushivision.pc packageconfig file to install



Modified: trunk/sushivision/Makefile
===================================================================
--- trunk/sushivision/Makefile	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/Makefile	2007-01-03 22:40:43 UTC (rev 12297)
@@ -2,45 +2,65 @@
 # Fuck the horse it rode in on
 # and Fuck its little dog Libtool too
 
-TARGET  = sushivision.so.0.0.0
-CC      = gcc 
-LD      = gcc
-INSTALL = install
-STRIP   = strip
-PREFIX  = /usr/local
-BINDIR  = $(PREFIX)/bin
-ETCDIR  = /etc/$(TARGET)
-MANDIR  = $(PREFIX)/man
+PREFIX    = /usr/local
+NAME      = sushivision
+MAJOR     = 0
+MINOR     = 0
+SUBMINOR  = 0
+
+CC        = gcc 
+LD        = gcc
+INSTALL   = install
+STRIP     = strip
+LDCONFIG  = /sbin/ldconfig
+
+VERSION   = $(MAJOR).$(MINOR).$(SUBMINOR)
+TARGET    = lib$(NAME).so.$(VERSION)
+BINDIR    = $(PREFIX)/bin
+INCDIR    = $(PREFIX)/include
+LIBDIR    = $(PREFIX)/lib
+ETCDIR    = /etc/$(TARGET)
+MANDIR    = $(PREFIX)/man
 SOCFLAGS  = -fPIC
-SOLDFLAGS = -shared -nostdlib
+SOLDFLAGS = -shared -nostdlib -Wl,-soname="lib$(NAME).so.$(MAJOR)"
 
-SRC  = main.c scale.c plot.c slider.c slice.c panel.c panel-1d.c panel-2d.c mapping.c dimension.c function.c objective.c undo.c gtksucks.c example_submain.c example_fractal.c
-OBJ  = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o
-#OBJ_EX1  = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o example_submain.o
-OBJ_EX2  = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o mapping.o dimension.o function.o objective.o undo.o gtksucks.o example_fractal.o
-INC  = sushivision.h
-LIBS = -lpthread -ldl
-CAIROVER =  >= 1.0.0
-GTKVER   =  >= 2.8.0
-GCF  = -std=gnu99 `pkg-config --static --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2 gthread-2.0"`
-LDF  = -pthread -L/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lm -lfontconfig -lpng12 -lXrender -lX11 -lpthread -lfreetype -lz -lgthread-2.0 -lglib-2.0 -lcairo
+SRC       = main.c scale.c plot.c slider.c slice.c panel.c panel-1d.c panel-2d.c \
+	mapping.c dimension.c function.c objective.c undo.c gtksucks.c \
+	example_fractal.c
+INC       = sushivision.h
+MAN	  =
+EXAMPLES  = sushivision_fractal # sushivision_chirpfit
+EX_OBJ    = example_fractal.o # example_chirpfit.o
+OBJ       = main.o scale.o plot.o slider.o slice.o panel.o panel-1d.o panel-2d.o \
+	mapping.o dimension.o function.o objective.o undo.o gtksucks.o
+LIBS      = -lpthread -ldl
+CAIROVER  =  >= 1.0.0
+GTKVER    =  >= 2.8.0
+GCF       = -std=gnu99 `pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) gthread-2.0"`
+LDF       = -pthread -L/lib -lgtk-x11-2.0 -lgdk-x11-2.0 -latk-1.0 -lgdk_pixbuf-2.0 \
+	-lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lgmodule-2.0 -ldl -lm \
+	-lfontconfig -lpng12 -lXrender -lX11 -lpthread -lfreetype -lz -lgthread-2.0 \
+	-lglib-2.0 -lcairo -ldl -rdynamic
 
 all:    
-	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2" 1>/dev/null
+	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) gthread-2.0" \
+		1>/dev/null
 	$(MAKE) target CFLAGS='-O2 -g $(SOCFLAGS) $(GCF) $(ADD_DEF)'
 	$(MAKE) examples CFLAGS='-O2 -g $(GCF) $(ADD_DEF)'
 
 debug:
-	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2" 1>/dev/null
+	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2" \
+		1>/dev/null
 	$(MAKE) target CFLAGS='-g -Wall -W -Wno-unused-parameter -D__NO_MATH_INLINES $(SOCFLAGS) $(GCF) $(ADD_DEF)'
 	$(MAKE) examples CFLAGS='-g -Wall -W -Wno-unused-parameter -D__NO_MATH_INLINES $(GCF) $(ADD_DEF)'
 
 profile:
-	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2" 1>/dev/null
+	pkg-config --cflags "gtk+-2.0 $(GTKVER) cairo $(CAIROVER) freetype2" \
+		1>/dev/null
 	$(MAKE) examples CFLAGS='-pg -g -O2 $(GCF) $(ADD_DEF)' LIBS='-lgprof-helper'
 
 clean:
-	rm -f *.o *.d *.d.* gmon.out $(TARGET)
+	rm -f *.o *.d *.d.* *.pc gmon.out $(TARGET) sushivision_*
 
 distclean: clean
 	rm -f *~
@@ -56,13 +76,31 @@
 include $(SRC:.c=.d)
 endif
 
-target:  $(OBJ) 
+sushivision.pc: Makefile
+	rm -f sushivision.pc
+	touch sushivision.pc
+	echo "prefix = $(PREFIX)" >> sushivision.pc
+	echo "version = $(VERSION)" >> sushivision.pc
+	echo "gtkver = $(GTKVER)" >> sushivision.pc
+	echo "cairover = $(CAIROVER)" >> sushivision.pc
+	cat sushivision.pc.in >> sushivision.pc	
+
+target:  $(OBJ) examples sushivision.pc
 	$(LD) $(OBJ) $(CFLAGS) $(SOLDFLAGS) -o $(TARGET) $(LIBS) $(LDF)
 
-examples:  $(OBJ_EX1) $(OBJ_EX2) 
-	$(LD) $(OBJ_EX2) $(CFLAGS) -o sushivision_fractal $(LIBS) $(LDF)
-#	$(LD) $(OBJ_EX1) $(CFLAGS) -o sushivision_example $(LIBS) $(LDF)
+examples:  $(OBJ) $(EX_OBJ)
+	$(LD) $(OBJ) example_fractal.o $(CFLAGS) -o sushivision_fractal $(LIBS) $(LDF)
+#	$(LD) $(OBJ) example_chirpfit.o $(CFLAGS) -o sushivision_chirpfit $(LIBS) $(LDF)
 
 install: target
+	$(INSTALL) -d -m 0755 $(INCDIR)
+	$(INSTALL) -m 0644 $(INC) $(INCDIR)
+#	$(INSTALL) -d -m 0755 $(MANDIR)
+#	$(INSTALL) -m 0644 $(MAN) $(MANDIR)
 	$(INSTALL) -d -m 0755 $(BINDIR)
-	$(INSTALL) -m 0755 $(TARGET) $(BINDIR)
+	$(INSTALL) -m 0755 $(EXAMPLES) $(BINDIR)
+	$(INSTALL) -d -m 0755 $(LIBDIR)
+	$(INSTALL) -d -m 0755 $(LIBDIR)/pkgconfig
+	$(INSTALL) -m 0755 $(TARGET) $(LIBDIR)
+	$(INSTALL) -m 0755 sushivision.pc $(LIBDIR)/pkgconfig
+	$(LDCONFIG)
\ No newline at end of file

Added: trunk/sushivision/example_chirpfit.c
===================================================================
--- trunk/sushivision/example_chirpfit.c	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/example_chirpfit.c	2007-01-03 22:40:43 UTC (rev 12297)
@@ -0,0 +1,139 @@
+/*
+ *
+ *     sushivision copyright (C) 2006-2007 Monty <monty at xiph.org>
+ *
+ *  sushivision is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2, or (at your option)
+ *  any later version.
+ *   
+ *  sushivision is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *   
+ *  You should have received a copy of the GNU General Public License
+ *  along with sushivision; see the file COPYING.  If not, write to the
+ *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * 
+ */
+
+#include <stdio.h>
+#include <math.h>
+#include "sushivision.h"
+
+sushiv_instance_t *s;
+#define todB(x)   ((x)==0?-400.f:log((x)*(x))*4.34294480f)
+
+/* time, blocksz, amp_0, amp_del, freq_0, phase_0, phase_del */
+int funcsize=64;
+double function[64];
+static void fourier_objective(double *d, double *ret){
+  int i;
+  double re_obj=0;
+  double im_obj=0;
+  double obj;
+
+  for(i=0;i<funcsize;i++){
+    im_obj += function[i] * sin(i*d[4]*2*M_PI);
+    re_obj += function[i] * cos(i*d[4]*2*M_PI);
+  
+  }
+  im_obj/=funcsize;
+  re_obj/=funcsize;
+
+  obj = sqrt(im_obj*im_obj + re_obj*re_obj);
+  *ret = todB(obj);
+
+}
+
+/*
+static double objective(double *d){
+  
+  return .5;
+
+}
+*/
+
+static int time_callback(sushiv_dimension_t *d){
+
+
+  return 1; // indicate that default processing chain should continue
+}
+
+static int blocksize_callback(sushiv_dimension_t *d){
+
+
+  return 1; // indicate that default processing chain should continue
+}
+
+int sushiv_submain(int argc, char *argv[]){
+  int i;
+
+  {
+    double phasechirp = 0;
+    double phi = 0;
+
+    for(i=0;i<funcsize;i++){
+      phasechirp +=.005;
+      phi += .1+phasechirp;
+      
+      function[i]=sin(phi)*.1;
+    }
+  }
+
+  s=sushiv_new_instance();
+
+  sushiv_new_dimension(s,0,"time",
+		       4,(double []){0,1024,2048,4096},
+		       time_callback,
+		       SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
+  sushiv_new_dimension(s,1,"blocksize",
+		       8,(double []){64,128,256,512,1024,2048,4096,8192},
+		       blocksize_callback,
+		       SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
+
+  sushiv_new_dimension(s,2,"amplitude",
+		       9,(double []){-96,-84,-72,-60,-48,-36,-24,-12,0},
+		       NULL,0);
+  sushiv_new_dimension(s,3,"amplitude delta",
+		       9,(double []){-96,-48,-24,-12,0,12,24,48,96},
+		       NULL,0);
+  sushiv_new_dimension(s,4,"frequency",
+		       6,(double []){0,.1,.2,.3,.4,.5},
+		       NULL,0);
+  sushiv_new_dimension(s,5,"phase",
+		       3,(double []){-.5,0,.5},
+		       NULL,0);
+  sushiv_new_dimension(s,6,"phase delta",
+		       3,(double []){-10,0,10},
+		       NULL,0);
+  
+  sushiv_new_objective(s,0,"fourier",
+		       8,(double []){-96,-48,-36,-24,-12,-6,0,6},
+		       fourier_objective,0);
+  //sushiv_new_objective(s,1,"fit",fit_objective,0);
+  //sushiv_new_objective(s,2,"waveform",fourier_objective,0);
+
+  sushiv_new_panel_2d(s,0,"fourier objective",
+		      (int []){0,-1},
+		      (int []){2,3,4,5,6,-1},
+		      0);
+  
+  /*sushiv_linked_panel_1d(s,1,"fourier x slice",8,
+		      (double []){-96,-48,-36,-24,-12,-6,0,6},
+		      0,0,
+		      0);
+  sushiv_linked_panel_1d(s,2,"fourier y slice",8,
+		      (double []){-96,-48,-36,-24,-12,-6,0,6},
+		      0,1,
+		      0);
+  sushiv_new_panel_1d(s,3,"input block",8,
+		      (double []){-96,-48,-36,-24,-12,-6,0,6},
+		      (int *){2,-1},
+		      NULL,
+		      0);*/
+
+  return 0;
+}

Modified: trunk/sushivision/example_fractal.c
===================================================================
--- trunk/sushivision/example_fractal.c	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/example_fractal.c	2007-01-03 22:40:43 UTC (rev 12297)
@@ -103,3 +103,9 @@
   
   return 0;
 }
+
+int sushiv_atexit(void){
+  fprintf(stderr,"Done!\n");
+  return 0;
+
+}

Deleted: trunk/sushivision/example_submain.c
===================================================================
--- trunk/sushivision/example_submain.c	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/example_submain.c	2007-01-03 22:40:43 UTC (rev 12297)
@@ -1,139 +0,0 @@
-/*
- *
- *     sushivision copyright (C) 2006-2007 Monty <monty at xiph.org>
- *
- *  sushivision is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2, or (at your option)
- *  any later version.
- *   
- *  sushivision is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *   
- *  You should have received a copy of the GNU General Public License
- *  along with sushivision; see the file COPYING.  If not, write to the
- *  Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- * 
- */
-
-#include <stdio.h>
-#include <math.h>
-#include "sushivision.h"
-
-sushiv_instance_t *s;
-#define todB(x)   ((x)==0?-400.f:log((x)*(x))*4.34294480f)
-
-/* time, blocksz, amp_0, amp_del, freq_0, phase_0, phase_del */
-int funcsize=64;
-double function[64];
-static void fourier_objective(double *d, double *ret){
-  int i;
-  double re_obj=0;
-  double im_obj=0;
-  double obj;
-
-  for(i=0;i<funcsize;i++){
-    im_obj += function[i] * sin(i*d[4]*2*M_PI);
-    re_obj += function[i] * cos(i*d[4]*2*M_PI);
-  
-  }
-  im_obj/=funcsize;
-  re_obj/=funcsize;
-
-  obj = sqrt(im_obj*im_obj + re_obj*re_obj);
-  *ret = todB(obj);
-
-}
-
-/*
-static double objective(double *d){
-  
-  return .5;
-
-}
-*/
-
-static int time_callback(sushiv_dimension_t *d){
-
-
-  return 1; // indicate that default processing chain should continue
-}
-
-static int blocksize_callback(sushiv_dimension_t *d){
-
-
-  return 1; // indicate that default processing chain should continue
-}
-
-int sushiv_submain(int argc, char *argv[]){
-  int i;
-
-  {
-    double phasechirp = 0;
-    double phi = 0;
-
-    for(i=0;i<funcsize;i++){
-      phasechirp +=.005;
-      phi += .1+phasechirp;
-      
-      function[i]=sin(phi)*.1;
-    }
-  }
-
-  s=sushiv_new_instance();
-
-  sushiv_new_dimension(s,0,"time",
-		       4,(double []){0,1024,2048,4096},
-		       time_callback,
-		       SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
-  sushiv_new_dimension(s,1,"blocksize",
-		       8,(double []){64,128,256,512,1024,2048,4096,8192},
-		       blocksize_callback,
-		       SUSHIV_DIM_NO_X|SUSHIV_DIM_NO_Y);
-
-  sushiv_new_dimension(s,2,"amplitude",
-		       9,(double []){-96,-84,-72,-60,-48,-36,-24,-12,0},
-		       NULL,0);
-  sushiv_new_dimension(s,3,"amplitude delta",
-		       9,(double []){-96,-48,-24,-12,0,12,24,48,96},
-		       NULL,0);
-  sushiv_new_dimension(s,4,"frequency",
-		       6,(double []){0,.1,.2,.3,.4,.5},
-		       NULL,0);
-  sushiv_new_dimension(s,5,"phase",
-		       3,(double []){-.5,0,.5},
-		       NULL,0);
-  sushiv_new_dimension(s,6,"phase delta",
-		       3,(double []){-10,0,10},
-		       NULL,0);
-  
-  sushiv_new_objective(s,0,"fourier",
-		       8,(double []){-96,-48,-36,-24,-12,-6,0,6},
-		       fourier_objective,0);
-  //sushiv_new_objective(s,1,"fit",fit_objective,0);
-  //sushiv_new_objective(s,2,"waveform",fourier_objective,0);
-
-  sushiv_new_panel_2d(s,0,"fourier objective",
-		      (int []){0,-1},
-		      (int []){2,3,4,5,6,-1},
-		      0);
-  
-  /*sushiv_linked_panel_1d(s,1,"fourier x slice",8,
-		      (double []){-96,-48,-36,-24,-12,-6,0,6},
-		      0,0,
-		      0);
-  sushiv_linked_panel_1d(s,2,"fourier y slice",8,
-		      (double []){-96,-48,-36,-24,-12,-6,0,6},
-		      0,1,
-		      0);
-  sushiv_new_panel_1d(s,3,"input block",8,
-		      (double []){-96,-48,-36,-24,-12,-6,0,6},
-		      (int *){2,-1},
-		      NULL,
-		      0);*/
-
-  return 0;
-}

Modified: trunk/sushivision/main.c
===================================================================
--- trunk/sushivision/main.c	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/main.c	2007-01-03 22:40:43 UTC (rev 12297)
@@ -31,6 +31,7 @@
 #include <gtk/gtk.h>
 #include <cairo-ft.h>
 #include <pthread.h>
+#include <dlfcn.h>
 #include "internal.h"
 
 
@@ -53,7 +54,6 @@
             "\nTrapped signal %d; exiting!\n",sig);
 
   gtk_main_quit();
-  exit(0);
 }
 
 static int num_proccies(){
@@ -212,8 +212,26 @@
     sushiv_realize_instance(instance_list[i]);
 }
 
+/* externally visible interface */
+
+sushiv_instance_t *sushiv_new_instance(void) {
+  sushiv_instance_t *ret=calloc(1,sizeof(*ret));
+  ret->private = calloc(1,sizeof(*ret->private));
+
+  if(instances){
+    instance_list = realloc(instance_list,(instances+1)*sizeof(*instance_list));
+  }else{
+    instance_list = malloc((instances+1)*sizeof(*instance_list));
+  }
+  instance_list[instances] = ret;
+  instances++;
+  
+  return ret;
+}
+
 int main (int argc, char *argv[]){
   int ret;
+
   num_threads = num_proccies();
 
   gtk_init (&argc, &argv);
@@ -226,7 +244,7 @@
 
   ret = sushiv_submain(argc,argv);
   if(ret)return ret;
-
+  
   sushiv_realize_all();
   
   {
@@ -241,25 +259,13 @@
 
   gtk_button3_fixup();
   gtk_main ();
+  
+  {
+    int (*optional_exit)(void) = dlsym(RTLD_DEFAULT, "sushiv_atexit");
+    if(optional_exit)
+      return optional_exit();
+  }
 
-
   return 0;
 }
 
-/* externally visible interface */
-
-sushiv_instance_t *sushiv_new_instance(void) {
-  sushiv_instance_t *ret=calloc(1,sizeof(*ret));
-  ret->private = calloc(1,sizeof(*ret->private));
-
-  if(instances){
-    instance_list = realloc(instance_list,(instances+1)*sizeof(*instance_list));
-  }else{
-    instance_list = malloc((instances+1)*sizeof(*instance_list));
-  }
-  instance_list[instances] = ret;
-  instances++;
-  
-  return ret;
-}
-

Modified: trunk/sushivision/panel-2d.c
===================================================================
--- trunk/sushivision/panel-2d.c	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/panel-2d.c	2007-01-03 22:40:43 UTC (rev 12297)
@@ -747,7 +747,6 @@
   int serialno;
   double x_min, x_max;
   double y_min, y_max;
-  double invh;
   int x_d=-1, y_d=-1;
   int render_scale_flag = 0;
   scalespace sx;
@@ -768,7 +767,6 @@
   plot = PLOT(p->private->graph);
 
   serialno = p2->serialno;
-  invh = 1./h;
   d = p->dimensions;
 
   /* render using local dimension array; several threads will be

Modified: trunk/sushivision/sushivision.h
===================================================================
--- trunk/sushivision/sushivision.h	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/sushivision.h	2007-01-03 22:40:43 UTC (rev 12297)
@@ -275,5 +275,6 @@
 
 
 extern int sushiv_submain(int argc, char *argv[]);
+extern int sushiv_atexit(void);
 
 #endif

Added: trunk/sushivision/sushivision.pc.in
===================================================================
--- trunk/sushivision/sushivision.pc.in	2007-01-03 21:22:15 UTC (rev 12296)
+++ trunk/sushivision/sushivision.pc.in	2007-01-03 22:40:43 UTC (rev 12297)
@@ -0,0 +1,13 @@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+bindir=${exec_prefix}/bin
+includedir=${prefix}/include
+
+Name: Sushivision
+Description: Function visualization UI library
+Version: ${version}
+URL: http://www.sushivision.org/
+Requires: gtk+-2.0 ${gtkver} cairo ${cairover} freetype2 gthread-2.0
+Libs: -rdynamic -L${libdir} -lsushivision
+Cflags: -g -I${includedir}
+



More information about the commits mailing list