]> git.saurik.com Git - cycript.git/blobdiff - xcode.mk
Move lib/cycript to cycript0.9 to free up cycript.
[cycript.git] / xcode.mk
index d87951fb9a0e51b123405aadaf8d469c0bfedafd..053503a4fd3aad8ed7e31abfe06fc551b593ecf5 100644 (file)
--- a/xcode.mk
+++ b/xcode.mk
 .DELETE_ON_ERROR:
 SHELL := /bin/bash
 
+include codesign.mk
+
 lipo := $(shell xcrun --sdk iphoneos -f lipo)
 
-libs := 
-libs += .libs/cycript
-libs += .libs/libcycript.dylib
-libs += .libs/libcycript-any.dylib
-libs += .libs/libcycript-sys.dylib
-libs += .libs/libcycript-sim.dylib
-libs += .libs/libcycript.o
+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.lib/cycript
+cycript += Cycript.lib/cycript0.9
+cycript += Cycript.lib/libcycript.dylib
+cycript += Cycript.lib/libcycript-any.dylib
+cycript += Cycript.lib/libcycript-sys.dylib
+cycript += Cycript.lib/libcycript-sim.dylib
 
 framework := 
 framework += Cycript.framework/Cycript
 framework += Cycript.framework/Headers/Cycript.h
 
-all: cycript $(libs) $(framework)
+links := 
+links += Cycript.lib/libsubstrate.dylib
+links += Cycript.lib/cycript0.9
+
+all: cycript $(cycript) $(framework)
 
 cycript.zip: all
        rm -f $@
-       zip -r9y $@ .libs/cycript .libs/*.dylib Cycript.framework
+       zip -r9y $@ cycript Cycript.lib Cycript.framework $(patsubst %,--exclude %,$(links))
+       zip -r9 $@ $(links)
 
 package: cycript.zip
 
+$(deb): Cycript.lib/cycript Cycript.lib/libcycript.dylib
+       rm -rf package
+       mkdir -p package/DEBIAN
+       sed -e 's/#/$(version)/' control.in >package/DEBIAN/control
+       mkdir -p package/usr/{bin,lib}
+       cp -a modules package/usr/lib/cycript0.9
+       $(lipo) -extract armv6 -output package/usr/bin/cycript Cycript.lib/cycript
+       $(lipo) -extract armv6 -extract arm64 -output package/usr/lib/libcycript.dylib Cycript.lib/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 .libs
+       rm -rf cycript Cycript.lib libcycript*.o
 
 # make stubbornly refuses to believe that these @'s are bugs
 # http://osdir.com/ml/help-make-gnu/2012-04/msg00008.html
@@ -70,7 +94,7 @@ build.ios-$(1)/.libs/libcycript.a: build-ios-$(1)
        @
 endef
 
-$(foreach arch,armv6 armv7 armv7s,$(eval $(call build_ios,$(arch))))
+$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch))))
 
 define build_sim
 .PHONY: build-sim-$(1)
@@ -82,39 +106,54 @@ 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))))
 
-.libs/%: build.mac-i386/.libs/% build.mac-x86_64/.libs/% build.ios-armv6/.libs/%
-       @mkdir -p .libs
+Cycript.lib/%.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) $@
+
+%_: %
+       @cp -af $< $@
+       install_name_tool -change /System/Library/{,Private}Frameworks/JavaScriptCore.framework/JavaScriptCore $@
+       codesign -s $(codesign) --entitlement cycript-$(word 2,$(subst ., ,$(subst -, ,$*))).xml $@
+
+Cycript.lib/%: build.mac-i386/.libs/%_ build.mac-x86_64/.libs/%_ build.ios-armv6/.libs/%_
+       @mkdir -p $(dir $@)
        $(lipo) -create -output $@ $^
 
-.libs/libcycript-sys.dylib:
-       @mkdir -p .libs
+Cycript.lib/libcycript-sys.dylib:
+       @mkdir -p $(dir $@)
        ln -sf libcycript.dylib $@
 
-.libs/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib
-       @mkdir -p .libs
-       cp -af $< $@
+Cycript.lib/libcycript-sim.dylib: build.sim-i386/.libs/libcycript.dylib build.sim-x86_64/.libs/libcycript.dylib
+       @mkdir -p $(dir $@)
+       $(lipo) -create -output $@ $^
+       codesign -s $(codesign) $@
 
-.libs/libcycript-%.o: build.%/.libs/libcycript.a
-       @mkdir -p .libs
-       ld -r -arch $$($(lipo) -detailed_info $< | sed -e '/^Non-fat file: / ! d; s/.*: //') -o $@ -all_load $< libffi.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 -exported_symbols_list xcode.map $< libffi.a
 
-.libs/libcycript.o: .libs/libcycript-ios-armv6.o .libs/libcycript-ios-armv7.o .libs/libcycript-ios-armv7s.o .libs/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: .libs/libcycript.o
+Cycript.framework/Cycript: libcycript.o
        @mkdir -p $(dir $@)
        cp -a $< $@
 
@@ -122,6 +161,10 @@ Cycript.framework/Headers/Cycript.h: Cycript.h
        @mkdir -p $(dir $@)
        cp -a $< $@
 
+Cycript.lib/cycript0.9:
+       @mkdir -p $(dir $@)
+       ln -s ../modules $@
+
 cycript: cycript.in
        cp -af $< $@
        chmod 755 $@