#!/bin/sh

# Clozure CL.app has already been built with :standalone-app # on *features*

ccl=~/ccl
app="$ccl/Clozure CL.app"
target="$app/Contents/Resources/ccl"

mkdir "$target"
( cd "$ccl/lisp-kernel/darwinx8664" && make clean )
( cd "$ccl/lisp-kernel/darwinx8632" && make clean )
( cd "$ccl/cocoa-ide/altconsole" && make clean && rm -rf AltConsole.app )

for i in cocoa-ide compiler darwin-x86-headers64 doc examples level-0 level-1 lib library lisp-kernel objc-bridge scripts tools xdump; do
  cp -Rp "$ccl/$i" "$target"
  # we want the fasls for tools/, mainly because asdf.lisp is slow
  # to load from source
  if test "$i" != tools; then
    find "$target/$i" -type f -name "*.*fsl" -exec rm -rf {} \;
  fi
done

find "$app" -type d -name .svn -exec rm -rf {} \;

codesign -s "3rd Party Mac Developer Application: Clozure Associates, LLC" "$app/Contents/Resources/AltConsole.app"
codesign -s "3rd Party Mac Developer Application: Clozure Associates, LLC" "$app"

