From 4b44403aebf7f8111f755ab622535e7a8bd7790b Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 7 Sep 2010 16:57:22 +0000 Subject: reorganized libdir loader into its own folder based on the Makefile library template svn path=/trunk/externals/loaders/libdir/; revision=13981 --- LICENSE.txt | 30 ++++++ Makefile | 286 +++++++++++++++++++++++++++++++++++++++++++++++++++ README.txt | 33 ++++++ TODO.txt | 26 +++++ debian/changelog | 5 + debian/compat | 1 + debian/control | 24 +++++ debian/copyright | 22 ++++ debian/gbp.conf | 7 ++ debian/links | 2 + debian/rules | 21 ++++ debian/source/format | 1 + libdir-meta.pd | 7 ++ libdir.c | 107 +++++++++++++++++++ 14 files changed, 572 insertions(+) create mode 100644 LICENSE.txt create mode 100644 Makefile create mode 100644 README.txt create mode 100644 TODO.txt create mode 100644 debian/changelog create mode 100644 debian/compat create mode 100644 debian/control create mode 100644 debian/copyright create mode 100644 debian/gbp.conf create mode 100644 debian/links create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 libdir-meta.pd create mode 100644 libdir.c diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..a56a51e --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,30 @@ +This software is copyrighted by Miller Puckette and others. The following +terms (the "Standard Improved BSD License") apply to all files associated with +the software unless explicitly disclaimed in individual files: + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + +1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the above + copyright notice, this list of conditions and the following + disclaimer in the documentation and/or other materials provided + with the distribution. +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY +EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR +BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, +EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING +IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF +THE POSSIBILITY OF SUCH DAMAGE. diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..bd92b00 --- /dev/null +++ b/Makefile @@ -0,0 +1,286 @@ +## Pd library template version 1.0.2 +# For instructions on how to use this template, see: +# http://puredata.info/docs/developer/MakefileTemplate +LIBRARY_NAME = libdir + +# add your .c source files, one object per file, to the SOURCES +# variable, help files will be included automatically +SOURCES = libdir.c + +# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will +# be included automatically +PDOBJECTS = + +# example patches and related files, in the 'examples' subfolder +EXAMPLES = + +# manuals and related files, in the 'manual' subfolder +MANUAL = + +# if you want to include any other files in the source and binary tarballs, +# list them here. This can be anything from header files, test patches, +# documentation, etc. README.txt and LICENSE.txt are required and therefore +# automatically included +EXTRA_DIST = TODO.txt + + + +#------------------------------------------------------------------------------# +# +# things you might need to edit if you are using other C libraries +# +#------------------------------------------------------------------------------# + +CFLAGS = -DPD -I$(PD_PATH)/src -Wall -W -g +LDFLAGS = +LIBS = + +#------------------------------------------------------------------------------# +# +# you shouldn't need to edit anything below here, if we did it right :) +# +#------------------------------------------------------------------------------# + +# get library version from meta file +LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) + +CFLAGS += -DVERSION='"$(LIBRARY_VERSION)"' + +# where Pd lives +PD_PATH = ../../pd +# where to install the library +prefix = /usr/local +libdir = $(prefix)/lib +pkglibdir = $(libdir)/pd-externals +objectsdir = $(pkglibdir) + +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) -p -m 644 +INSTALL_DATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -p -m 755 -d + +ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ + $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) + +DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) +ORIGDIR=pd-$(LIBRARY_NAME)_$(LIBRARY_VERSION) + +UNAME := $(shell uname -s) +ifeq ($(UNAME),Darwin) + CPU := $(shell uname -p) + ifeq ($(CPU),arm) # iPhone/iPod Touch + SOURCES += $(SOURCES_iphoneos) + EXTENSION = pd_darwin + OS = iphoneos + IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin + CC=$(IPHONE_BASE)/gcc + CPP=$(IPHONE_BASE)/cpp + CXX=$(IPHONE_BASE)/g++ + ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk + IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 + OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer + CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) \ + -I/Applications/Pd-extended.app/Contents/Resources/include + LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) + LIBS += -lc + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) + else # Mac OS X + SOURCES += $(SOURCES_macosx) + EXTENSION = pd_darwin + OS = macosx + OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast +# build universal 32-bit on 10.4 and 32/64 on newer + ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) + FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 + else + FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + SOURCES += $(SOURCES_iphoneos) + endif + CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include \ + -I/Applications/Pd-extended.app/Contents/Resources/include + LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib + # if the 'pd' binary exists, check the linking against it to aid with stripping + LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) + LIBS += -lc + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) +# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much + pkglibdir=$(HOME)/Library/Pd + endif +endif +ifeq ($(UNAME),Linux) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + OS = linux + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += -fPIC + LDFLAGS += -Wl,--export-dynamic -shared -fPIC + LIBS += -lc + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_cygwin) + EXTENSION = dll + OS = cygwin + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += + LDFLAGS += -Wl,--export-dynamic -shared -L$(PD_PATH)/src + LIBS += -lc -lpd + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif +ifeq (MINGW,$(findstring MINGW,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_windows) + EXTENSION = dll + OS = windows + OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -march=i686 -mtune=pentium4 + CFLAGS += -mms-bitfields + LDFLAGS += -s -shared -Wl,--enable-auto-import + LIBS += -L$(PD_PATH)/src -L$(PD_PATH)/bin -L$(PD_PATH)/obj -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif + +# in case somebody manually set the HELPPATCHES above +HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.c=-help.pd) + +CFLAGS += $(OPT_CFLAGS) + + +.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME) + +all: $(SOURCES:.c=.$(EXTENSION)) + +%.o: %.c + $(CC) $(CFLAGS) -o "$*.o" -c "$*.c" + +%.$(EXTENSION): %.o + $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" $(LIBS) + chmod a-x "$*.$(EXTENSION)" + +install: libdir_install + +# The meta and help files are explicitly installed to make sure they are +# actually there. Those files are not optional, then need to be there. +libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SOURCES))" || (\ + $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ + $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + +# install library linked as single binary +single_install: $(LIBRARY_NAME) install-doc install-exec + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) + +install-doc: + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt + $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt + +install-examples: + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ + done + +install-manual: + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ + done + + +clean: + -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) + -rm -f -- $(SOURCES:.c=.$(EXTENSION)) + -rm -f -- $(LIBRARY_NAME).o + -rm -f -- $(LIBRARY_NAME).$(EXTENSION) + +distclean: clean + -rm -f -- $(DISTBINDIR).tar.gz + -rm -rf -- $(DISTBINDIR) + -rm -f -- $(DISTDIR).tar.gz + -rm -rf -- $(DISTDIR) + -rm -f -- $(ORIGDIR).tar.gz + -rm -rf -- $(ORIGDIR) + + +$(DISTBINDIR): + $(INSTALL_DIR) $(DISTBINDIR) + +libdir: all $(DISTBINDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) + $(INSTALL_DATA) $(SOURCES) $(DISTBINDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) +# tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) + +$(DISTDIR): + $(INSTALL_DIR) $(DISTDIR) + +$(ORIGDIR): + $(INSTALL_DIR) $(ORIGDIR) + +dist: $(DISTDIR) + $(INSTALL_DATA) Makefile $(DISTDIR) + $(INSTALL_DATA) README.txt $(DISTDIR) + $(INSTALL_DATA) LICENSE.txt $(DISTDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) + test -z "$(strip $(ALLSOURCES))" || \ + $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DISTDIR)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ + done + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DISTDIR)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ + done + tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) + +# make a Debian source package +dpkg-source: + debclean + make distclean dist + mv $(DISTDIR) $(ORIGDIR) + tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) + rm -f -- $(DISTDIR).tar.gz + rm -rf -- $(DISTDIR) $(ORIGDIR) + cd .. && dpkg-source -b $(LIBRARY_NAME) + +etags: + etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h + +showsetup: + @echo "PD_PATH: $(PD_PATH)" + @echo "objectsdir: $(objectsdir)" + @echo "LIBRARY_NAME: $(LIBRARY_NAME)" + @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" + @echo "SOURCES: $(SOURCES)" + @echo "PDOBJECTS: $(PDOBJECTS)" + @echo "ALLSOURCES: $(ALLSOURCES)" + @echo "UNAME: $(UNAME)" + @echo "CPU: $(CPU)" + @echo "pkglibdir: $(pkglibdir)" + @echo "DISTDIR: $(DISTDIR)" + @echo "ORIGDIR: $(ORIGDIR)" diff --git a/README.txt b/README.txt new file mode 100644 index 0000000..8d39510 --- /dev/null +++ b/README.txt @@ -0,0 +1,33 @@ +------ +libdir +------ + +This package provides support for the libdir format of libraries that is used +in Pd-extended. It should work with any version of Pd 0.40 or newer. + +The 'libdir' loader is a Pd loader which supports the libdir library +format. The libdir library format aims to be a common library format +for Pd which works with objects written in any language, including +Pd. This library format was designed to be easy to create, install, +and use. It should work when installed into the global path +(i.e. pd/extra) or when copied locally into a project folder. It +should work with objects written in any supported language +(i.e. binaries, .pd, and the various loaders like pdlua and +tclpd). Also, starting with Pd 0.43 and Pd-extended 0.42, the Help +Browser dynamically builds itself based on the libraries that are +installed. + +To install, copy the files for your platform into your "extra" folder and the +help patches to the "doc/5.reference" folder. You will need to load the +libdir.dll/libdir.pd_linux/libdir.pd_darwin as a library before trying to load +any libdirs. The libdirs have to be in the global classpath in order to be +found. + +You can add a library two ways: + - add this text to one of the fields in the "Startup" prefs: libdir + - load it on the command line with this: -lib libdir + +For more info on the structure of libdirs, see this webpage: + +http://puredata.org/docs/developer/Libdir + diff --git a/TODO.txt b/TODO.txt new file mode 100644 index 0000000..e8c3c4d --- /dev/null +++ b/TODO.txt @@ -0,0 +1,26 @@ + +- implement [classpath] which adds a path to the global path, like what + [declare -stdpath] does. The idea is that the global path serves as a + Java-style classpath. and the local path serves as the namespace. + + - inlet accepts bang to output classpath on outlet + - inlet accepts messages to add items to the classpath + - follows same interface as [textfile], [qlist] + +- implement [import] which adds the libdir path to the canvas path, similar + [declare -lib] does, except that it only looks in the global path (aka + classpath) + + - inlet accepts bang to output canvas path on outlet + - inlet accepts messages to add items to the canvas path + - follows same interface as [textfile], [qlist] + +- make [libdir] load libdirs when they are called with [import] and [declare + -lib] and [declare -stdlib]. + +- [libdir] loader should only add the libdir to the helppath, not the + additional doc/5.reference path to the helppath. The idea is that libdirs + are self-contained. + + +- test binary on 0.41 test diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..9723749 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +pd-libdir (0.0-1) unstable; urgency=low + + * Initial release (Closes: #nnnn) + + -- Hans-Christoph Steiner Thu, 21 Jan 2010 23:27:04 -0500 diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +7 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..0f2108c --- /dev/null +++ b/debian/control @@ -0,0 +1,24 @@ +Source: pd-libdir +Section: libs +Priority: optional +Maintainer: Debian Multimedia Maintainers +Uploaders: Hans-Christoph Steiner +Build-Depends: debhelper (>= 7.0.50~), puredata-dev +Standards-Version: 3.9.1 +Homepage: http://puredata.info + +Package: pd-libdir +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends}, pd +Description: provides support for the libdir library format for Pd + The 'libdir' loader is a Pure Data loader which supports the libdir + library format. The libdir library format aims to be a common + library format for Pd which works with objects written in any + language, including Pd. This library format was designed to be easy + to create, install, and use. It should work when installed into the + global path (i.e. pd/extra) or when copied locally into a project + folder. It should work with objects written in any supported language + (i.e. binaries, .pd, and the various loaders like pdlua and + tclpd). Also, starting with Pd 0.43 and Pd-extended 0.42, the Help + Browser dynamically builds itself based on the libraries that are + installed. diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..488aa95 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,22 @@ +Format-Specification: http://svn.debian.org/wsvn/dep/web/deps/dep5.mdwn?rev=135 +Name: libdir +Debianized-By: Hans-Christoph Steiner +Debianized-Date: Mon, 6 Sep 2010 17:14:25 -0400 +Files: * +Copyright: 2006-2010, Hans-Christoph Steiner + +License: BSD + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. Neither the name of the University nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + . + On Debian systems, the complete text of the Modified BSD License + can be found in file "/usr/share/common-licenses/BSD". diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 0000000..baae294 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,7 @@ +[DEFAULT] +upstream-branch = upstream +debian-branch = master +upstream-tag = upstream/%(version)s +debian-tag = debian/%(version)s +pristine-tar = True + diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..f924517 --- /dev/null +++ b/debian/links @@ -0,0 +1,2 @@ +usr/lib/pd/extra/libdir/README.txt usr/share/doc/pd-libdir/README +usr/share/common-licenses/BSD usr/lib/pd/extra/libdir/LICENSE.txt diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..3c49f8e --- /dev/null +++ b/debian/rules @@ -0,0 +1,21 @@ +#!/usr/bin/make -f + +LIBRARY_NAME = libdir +PACKAGE = pd-$(LIBRARY_NAME) +pkglibdir = /usr/lib/pd/extra + +%: + dh --with quilt $@ + +override_dh_auto_install: + make DESTDIR=$(CURDIR)/debian/$(PACKAGE) pkglibdir=$(pkglibdir) install +# replace license file with link to the Debian license file + rm -f -- $(CURDIR)/debian/$(PACKAGE)/$(pkglibdir)/$(LIBRARY_NAME)/LICENSE.txt + +override_dh_shlibdeps: + dpkg-shlibdeps $(CURDIR)/debian/$(PACKAGE)$(pkglibdir)/$(LIBRARY_NAME)/*.pd_linux \ + -T$(CURDIR)/debian/$(PACKAGE).substvars + +override_dh_strip: + strip --remove-section=.comment --remove-section=.note --strip-unneeded \ + $(CURDIR)/debian/$(PACKAGE)$(pkglibdir)/$(LIBRARY_NAME)/*.pd_linux diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/libdir-meta.pd b/libdir-meta.pd new file mode 100644 index 0000000..4172d61 --- /dev/null +++ b/libdir-meta.pd @@ -0,0 +1,7 @@ +#N canvas 15 49 200 200 10; +#N canvas 25 49 420 300 META 1; +#X text 10 10 NAME libdir; +#X text 10 30 AUTHOR hans@eds.org; +#X text 10 50 VERSION 1.9; +#X text 10 70 LICENSE BSD; +#X restore 10 10 pd META; diff --git a/libdir.c b/libdir.c new file mode 100644 index 0000000..8609e3c --- /dev/null +++ b/libdir.c @@ -0,0 +1,107 @@ +#include "m_pd.h" +#include "s_stuff.h" +#include "g_canvas.h" +#include +#include +#include + +/* this object requires Pd 0.40.3 or later */ + +/* WARNING: KLUDGE! */ +/* + * this struct is not publically defined (its in g_canvas.c) so I need to + * include this here. Its from Pd 0.41-test03 2006-11-19. */ +struct _canvasenvironment +{ + t_symbol *ce_dir; /* directory patch lives in */ + int ce_argc; /* number of "$" arguments */ + t_atom *ce_argv; /* array of "$" arguments */ + int ce_dollarzero; /* value of "$0" */ + t_namelist *ce_path; /* search path */ +}; + + +static char *version = "1.9"; + +/* This loader opens a directory with a -meta.pd file as a library. In the + * long run, the idea is that one folder will have all of objects files, all + * of the related *-help.pd files, a file with meta data for the help system, + * etc. Then to install the lib, it would just be dropped into extra, or + * anywhere in the global classpath. + * + * Ultimately, the meta file will be read for meta data, specifically for + * the auto-generated Help system, but for other things too. Right now, + * its just used as a marker that a directory is meant to be a library. + * Plus its much easier to implement it this way, I can use + * open_via_path() instead of writing a new function. The grand plan is + * to have one directory hold the objects, help files, manuals, + * etc. making it a self-contained library. + */ + +static int libdir_loader(t_canvas *canvas, char *classname) +{ + int fd = -1; + char helppathname[FILENAME_MAX]; + char fullclassname[FILENAME_MAX], dirbuf[FILENAME_MAX]; + char *nameptr; + t_canvasenvironment *canvasenvironment; + +/* look for meta file (classname)/(classname)-meta.pd */ + strncpy(fullclassname, classname, FILENAME_MAX - 6); + strcat(fullclassname, "/"); + strncat(fullclassname, classname, FILENAME_MAX - strlen(fullclassname) - 6); + strcat(fullclassname, "-meta"); + + /* if this is being called from a canvas, then add the library path to the + * canvas-local path */ + if(canvas) + { + canvasenvironment = canvas_getenv(canvas); + /* setting the canvas to NULL causes it to ignore any canvas-local path */ + if ((fd = canvas_open(NULL, fullclassname, ".pd", + dirbuf, &nameptr, FILENAME_MAX, 0)) < 0) + { + return (0); + } + close(fd); + if(sys_isabsolutepath(dirbuf)) // only include actual full paths + canvasenvironment->ce_path = namelist_append(canvasenvironment->ce_path, + dirbuf, 0); + if(sys_verbose) + post("libdir_loader: added '%s' to the canvas-local objectclass path", + classname); + } + else + { + if ((fd = open_via_path(".", fullclassname, ".pd", + dirbuf, &nameptr, FILENAME_MAX, 0)) < 0) + { + return (0); + } + close(fd); + sys_searchpath = namelist_append(sys_searchpath, dirbuf, 0); + strncpy(helppathname, sys_libdir->s_name, FILENAME_MAX-30); + helppathname[FILENAME_MAX-30] = 0; + strcat(helppathname, "/doc/5.reference/"); + strcat(helppathname, classname); + sys_helppath = namelist_append(sys_helppath, helppathname, 0); + post("libdir_loader: added '%s' to the global objectclass path", + classname); +// post("\tThis is deprecated behavior."); + } + /* post("libdir_loader loaded fullclassname: '%s'\n", fullclassname); */ + if (sys_verbose) + post("Loaded libdir '%s' from '%s'", classname, dirbuf); + + return (1); +} + +void libdir_setup(void) +{ +/* relies on t.grill's loader functionality, fully added in 0.40 */ + sys_register_loader(libdir_loader); + post("libdir loader %s",version); + post("\tcompiled on "__DATE__" at "__TIME__ " "); + post("\tcompiled against Pd version %d.%d.%d.%s", PD_MAJOR_VERSION, + PD_MINOR_VERSION, PD_BUGFIX_VERSION, PD_TEST_VERSION); +} -- cgit v1.2.1