paths := $(foreach path,$(paths),$(wildcard $(path)))
cflags += $(foreach path,$(paths),-I$(path) -L$(path))
-#svn := $(shell svnversion $(srcdir))
-
all:
all := cycript
filters := #E4X
ldid := true
-entitle := $(ldid)
+entitle = $(ldid) -Scycript.xml
lib := lib
dll := @SO@
-depends :=
+depends ?=
restart ?= $(MAKE)
uname_s ?= $(shell uname -s)
filters += $(shell $(bison) <(echo '%code{}%%_:') -o/dev/null 2>/dev/null && echo Bison24 || echo Bison23)
ifdef arch
-deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | $(sed) -e 's/\#/$(svn)/')_$(arch).deb
+deb := $(shell grep ^Package: $(srcdir)/control.in | cut -d ' ' -f 2-)_$(shell grep ^Version: $(srcdir)/control.in | cut -d ' ' -f 2 | $(sed) -e 's/\#/$(version)/')_$(arch).deb
all:
-extra::
-
ifeq ($(depends)$(dll),dylib)
-control.tmp: control.in cycript $(lib)cycript.dylib
- $(sed) -e 's/&/'"$$(dpkg-query -S $$(otool -lah cycript *.dylib | grep dylib | grep -v ':$$' | $(sed) -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | $(sed) -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
+control.tmp: control.in .libs/cycript .libs/$(lib)cycript.dylib
+ $(sed) -e 's/&/'"$$(dpkg-query -S $$(otool -lah .libs/cycript .libs/*.dylib | grep dylib | grep -v ':$$' | $(sed) -e 's/^ *name //;s/ (offset [0-9]*)$$//' | sort -u) 2>/dev/null | $(sed) -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
else
ifeq ($(depends)$(dll),so)
-control.tmp: control.in cycript $(lib)cycript.so
- $(sed) -e 's/&/'"$$(dpkg-query -S $$(ldd cycript $(lib)cycript.so | $(sed) -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | $(sed) -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
+control.tmp: control.in .libs/cycript .libs/$(lib)cycript.so
+ $(sed) -e 's/&/'"$$(dpkg-query -S $$(ldd cycript $(lib)cycript.so | $(sed) -e '/:$$/ d; s/^[ \t]*\([^ ]* => \)\?\([^ ]*\) .*/\2/' | sort -u) 2>/dev/null | $(sed) -e 's/:.*//; /^cycript$$/ d; s/$$/,/' | sort -u | tr '\n' ' ')"'/;s/, $$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
else
control.tmp: control.in
- $(sed) -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(svn)/;s/%/$(arch)/' $< >$@
+ $(sed) -e 's/&/$(foreach depend,$(depends),$(depend),)/;s/,$$//;s/#/$(version)/;s/%/$(arch)/' $< >$@
endif
endif
rm -rf package
mkdir -p package/DEBIAN
cp -pR control package/DEBIAN
+ #sed -i -e '/^Depends: / s/\<mobilesubstrate\>/mobilesubstrate (>= 0.9.3072)/g' package/DEBIAN/control
mkdir -p package/usr/{bin,lib,sbin}
- $(restart) extra
- cp -pR $(lib)cycript.$(dll) package/usr/lib
- cp -pR cycript package/usr/bin
- #cp -pR cyrver package/usr/sbin
+ cp -pR .libs/$(lib)cycript.0.$(dll) package/usr/lib
+ cp -pR .libs/$(lib)cycript.$(dll) package/usr/lib
+ cp -pR .libs/cycript package/usr/bin
dpkg-deb -b package $(deb)
endif
all: $(all)
clean::
- rm -rf *.lo *.o *.d *.t.hpp .libs */*.d */*.lo */.libs lib*.la $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh cyrver Cycript.yy Cycript.l control Bridge.gperf Bridge.hpp Cycript.output
+ rm -rf *.lo *.o *.d *.t.hpp .libs */*.d */*.lo */.libs lib*.la $(all) Struct.hpp lex.cy.c Cycript.tab.cc Cycript.tab.hh location.hh position.hh stack.hh Cycript.yy Cycript.l control Bridge.gperf Bridge.hpp Cycript.output
ifneq ($(srcdir),.)
rm -rf Mach ObjectiveC sig
endif
libcycript.la: $(code)
$(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) $(library) $(link) -rpath $(libdir)
- $(ldid) $@
+ $(ldid) .libs/$(lib)cycript.$(dll)
cycript: Console.lo libcycript.la $(inject)
$(libtool) --mode=link $(cxx) $(ltflags) $(ldflags) -o $@ $(filter %.lo,$^) libcycript.la $(link) -rpath $(libdir)
- $(entitle) cycript
+ $(entitle) .libs/cycript
package: $(deb)
$(libtool) --mode=uninstall rm -f $(DESTDIR)$(bindir)/cycript
$(libtool) --mode=uninstall rm -f $(DESTDIR)$(libdir)/libcycript.la
-.PHONY: all clean extra dist install uninstall package test control.tmp
+.PHONY: all clean dist install uninstall package test control.tmp
#include <dlfcn.h>
#include <mach/mach.h>
-#include <mach/i386/thread_status.h>
+#include <mach/machine/thread_status.h>
#include <cstdio>
#include <pthread.h>
Trampoline *trampoline;
#if defined(__arm__)
- trampoline = &Trampoline_arm_;
+ trampoline = &Trampoline_armv6_;
arm_thread_state_t state;
flavor = ARM_THREAD_STATE;
count = ARM_THREAD_STATE_COUNT;
_assert(count == count);
#if defined(__arm__)
- state.r[0] = data;
- state.sp = stack + Stack_;
- state.pc = code + trampoline->entry_;
+ state.__r[0] = data;
+ state.__sp = stack + Stack_;
+ state.__pc = code + trampoline->entry_;
- if ((state.pc & 0x1) != 0) {
- state.pc &= ~0x1;
- state.cpsr |= 0x20;
+ if ((state.__pc & 0x1) != 0) {
+ state.__pc &= ~0x1;
+ state.__cpsr |= 0x20;
}
#elif defined(__i386__)
frame[1] = data;
**/
/* }}} */
-#if defined(__APPLE__) && defined(__arm__)
-#include <substrate.h>
-#else
-#include <objc/objc-api.h>
-#endif
-
#ifdef __APPLE__
#include "Struct.hpp"
#endif
#include "ObjectiveC/Internal.hpp"
-#include <objc/Protocol.h>
+#include <objc/objc-api.h>
+#include <objc/runtime.h>
#include "cycript.hpp"
} CYCatch }
/* Hook: objc_registerClassPair {{{ */
-#if defined(__APPLE__) && defined(__arm__)
+#if defined(__APPLE__) && defined(__arm__) && 0
// XXX: replace this with associated objects
MSHook(void, CYDealloc, id self, SEL sel) {
definition.getPropertyNames = &ObjectiveC_Protocols_getPropertyNames;
ObjectiveC_Protocols_ = JSClassCreate(&definition);
-#if defined(__APPLE__) && defined(__arm__)
+#if defined(__APPLE__) && defined(__arm__) && 0
MSHookFunction(&objc_registerClassPair, MSHake(objc_registerClassPair));
#endif
CYSetProperty(context, cycript, CYJSString("Selector"), Selector);
CYSetProperty(context, cycript, CYJSString("Super"), Super);
-#if defined(__APPLE__) && defined(__arm__)
+#if defined(__APPLE__) && defined(__arm__) && 0
CYSetProperty(context, all, CYJSString("objc_registerClassPair"), &objc_registerClassPair_, kJSPropertyAttributeDontEnum);
#endif
#!/usr/bin/env bash
+rm -rf sysroot.ios
mkdir -p sysroot.ios
-for deb in apr-lib_1.3.3-2 readline_6.0-7; do
+for deb in apr-lib_1.3.3-2 libffi_130618-4 readline_6.0-7; do
deb=${deb}_iphoneos-arm.deb
- #wget http://apt.saurik.com/debs/"${deb}"
+ [[ -f "${deb}" ]] || wget http://apt.saurik.com/debs/"${deb}"
tar=data.tar.lzma
ar -x "${deb}" "${tar}"
tar -C sysroot.ios -xf "${tar}"
rm -f "${tar}"
done
+mkdir -p sysroot.ios/usr/include/ffi
+mv -v sysroot.ios/usr/include/{,ffi/}ffi.h
+
dev=/Developer/Platforms/iPhoneOS.platform/Developer
+sdk=${dev}/SDKs/iPhoneOS4.3.sdk
+
+ln -s /System/Library/Frameworks/WebKit.framework/Versions/A/Headers sysroot.ios/usr/include/WebKit
+
+mkdir -p sysroot.ios/Library/Frameworks/JavaScriptCore.framework
+ln -s "${sdk}"/System/Library/PrivateFrameworks/JavaScriptCore.framework/JavaScriptCore sysroot.ios/Library/Frameworks/JavaScriptCore.framework
+ln -s /System/Library/Frameworks/JavaScriptCore.framework/Headers sysroot.ios/Library/Frameworks/JavaScriptCore.framework
+
export CC=${dev}/usr/bin/gcc
export CXX=${dev}/usr/bin/g++
+export OBJCXX=${dev}/usr/bin/g++
flags_armv6=()
-flags_armv6+=(-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS4.3.sdk)
+flags_armv6+=(-isysroot "${sdk}")
+flags_armv6+=(-Fsysroot.ios/Library/Frameworks)
flags_armv6+=(-Isysroot.ios/usr/include)
flags_armv6+=(-Lsysroot.ios/usr/lib)
+flags_armv6+=(-F"${sdk}"/System/Library/PrivateFrameworks)
+flags_armv6+=(-framework WebCore)
+
+
flags=()
for flag in "${flags_armv6[@]}"; do
flags+=(-Xarch_armv6 "${flag}")
cflags=${flags[*]}
export CFLAGS=${cflags}
export CXXFLAGS=${cflags}
+export OBJCXXFLAGS=${cflags}
lflags=()
for flag in "${flags[@]}"; do
export LTFLAGS=${lflags}
./configure --prefix=/usr "$@"
+
+make clean
+make -j ldid=ldid all
+make arch=iphoneos-arm version=432 dll=dylib depends='apr-lib readline libffi mobilesubstrate' package