Pure DataのexternalをMacでビルドするシェルスクリプト

MacでPure Dataの拡張オブジェクト(external object)をビルドする方法はいくつかあり、下記のMakefileを使うものなどが便利だったりします。(永野さん提案の、Xcodeを使う方法もあります)

参考:Pure Data の拡張オブジェクトを作る gcc on Mac OS X 版 - ruby trunk changes

ただ、Makefileを作るほどでもないんだよなー、というときもあります(ない?) 僕は上記ページを参考にした次のようなシェルスクリプトを使っています。

#!/bin/sh
cc -g -DMACOSX -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
   -Wno-unused -Wno-parentheses -Wno-switch -I. \
   -o $1.pd_darwin_o -c $1.c
cc -bundle -undefined suppress -flat_namespace -lm \
   -o $1.pd_darwin $1.pd_darwin_o
rm $1.pd_darwin_o

これをmakepdext.shのようなファイルに保存しておき、例えばpd-externals-HOWTOhelloworld.cがあったとして、

$ ./makepdext.sh helloworld

とするとhelloworld.pd_darwinができあがります。やってることは永野さんのMakefileと同じですが、ちょろっとコンパイルしたいだけの時にどうぞ。