]> git.saurik.com Git - cycript.git/blobdiff - xcode.mk
CYONify pointers as the address of their values.
[cycript.git] / xcode.mk
index 42aa66f4b537dd78effda78a694b542c021f37b7..22dc9134096192afcaf9be3752d623aaefce1f7d 100644 (file)
--- a/xcode.mk
+++ b/xcode.mk
@@ -24,8 +24,11 @@ include codesign.mk
 
 lipo := $(shell xcrun --sdk iphoneos -f lipo)
 
+version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g')
+deb := cycript_$(version)_iphoneos-arm.deb
+
 cycript := 
-cycript += Cycript_/cycript
+cycript += Cycript_/cycript_
 cycript += Cycript_/libcycript.dylib
 cycript += Cycript_/libcycript-any.dylib
 cycript += Cycript_/libcycript-sys.dylib
@@ -43,6 +46,19 @@ cycript.zip: all
 
 package: cycript.zip
 
+$(deb): Cycript_/cycript_ Cycript_/libcycript.dylib
+       rm -rf package
+       mkdir -p package/DEBIAN
+       sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
+       mkdir -p package/usr/{bin,lib}
+       $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript_/cycript_
+       $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript_/libcycript.dylib
+       ln -s libcycript.dylib package/usr/lib/libcycript.0.dylib
+       dpkg-deb -Zlzma -b package $@
+
+deb: $(deb)
+       ln -sf $< cycript.deb
+
 clean:
        rm -rf cycript Cycript_ libcycript*.o
 
@@ -83,42 +99,51 @@ build.sim-$(1)/.libs/libcycript.a: build-sim-$(1)
        @
 endef
 
-$(foreach arch,i386,$(eval $(call build_sim,$(arch))))
+$(foreach arch,i386 x86_64,$(eval $(call build_sim,$(arch))))
 
 define build_arm
 build.ios-$(1)/.libs/cycript: build-ios-$(1)
        @
+endef
+
+$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
+
+define build_arm
 build.ios-$(1)/.libs/libcycript.dylib: build-ios-$(1)
        @
-build.ios-$(1)/.libs/libcycript-any.dylib: build-ios-$(1)
-       @
 endef
 
-$(foreach arch,armv6,$(eval $(call build_arm,$(arch))))
+$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch))))
 
 Cycript_/%.dylib: build.mac-i386/.libs/%.dylib build.mac-x86_64/.libs/%.dylib build.ios-armv6/.libs/%.dylib build.ios-arm64/.libs/%.dylib
        @mkdir -p $(dir $@)
        $(lipo) -create -output $@ $^
+       install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
+       codesign -s $(codesign) $@
 
-Cycript_/%: build.mac-i386/.libs/% build.mac-x86_64/.libs/% build.ios-armv6/.libs/%
+%_: %
+       @cp -af $< $@
+       install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
+       codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
+
+Cycript_/cycript_: build.mac-i386/.libs/cycript_ build.mac-x86_64/.libs/cycript_ build.ios-armv6/.libs/cycript_
        @mkdir -p $(dir $@)
        $(lipo) -create -output $@ $^
-       codesign -s $(codesign) --entitlement cycript.xml $@
 
 Cycript_/libcycript-sys.dylib:
        @mkdir -p $(dir $@)
        ln -sf libcycript.dylib $@
 
-Cycript_/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib
+Cycript_/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
        @mkdir -p $(dir $@)
-       cp -af $< $@
+       $(lipo) -create -output $@ $^
        codesign -s $(codesign) $@
 
-libcycript-%.o: build.%/.libs/libcycript.a
+libcycript-%.o: build.%/.libs/libcycript.a xcode.map
        @mkdir -p $(dir $@)
-       ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.a
+       ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load -exported_symbols_list xcode.map $< libffi.a
 
-libcycript.o: libcycript-ios-armv6.o libcycript-ios-armv7.o libcycript-ios-armv7s.o libcycript-ios-arm64.o libcycript-sim-i386.o
+libcycript.o: libcycript-ios-armv6.o libcycript-ios-armv7.o libcycript-ios-armv7s.o libcycript-ios-arm64.o libcycript-sim-i386.o libcycript-sim-x86_64.o
        $(lipo) -create -output $@ $^
 
 Cycript.framework/Cycript: libcycript.o