From: Jay Freeman (saurik) Date: Sat, 11 Oct 2014 08:57:34 +0000 (-0700) Subject: Give Xcode/Apple/iOS build scripts a common prefix. X-Git-Tag: v0.9.503~28 X-Git-Url: https://git.saurik.com/cycript.git/commitdiff_plain/42311506d531ad98d674cbaa4768453cf8950451?ds=inline Give Xcode/Apple/iOS build scripts a common prefix. --- diff --git a/.gitignore b/.gitignore index 96b2ad4..bb5c540 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ aclocal.m4 stamp-h1 readline-6.2 readline-6.2.tar.gz +readline.* libffi.* build.* Cycript.ios diff --git a/apple-configure.sh b/apple-configure.sh new file mode 100755 index 0000000..c4bfd02 --- /dev/null +++ b/apple-configure.sh @@ -0,0 +1,115 @@ +#!/usr/bin/env bash + +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2013 Jay Freeman (saurik) + +# GNU General Public License, Version 3 {{{ +# +# Cycript is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Cycript is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cycript. If not, see . +# }}} + +set -e + +cd "${0%%/*}" + +if [[ ! -e readline.osx/libreadline.a ]]; then + ./apple-readline.sh; fi +if [[ ! -e libffi.a ]]; then + ./libffi.sh; fi + +if ! which aclocal; then + touch aclocal.m4; fi +if ! which autoconf; then + touch configure.ac; fi +if ! which automake; then + touch Makefile.in; fi +if ! which autoheader; then + touch config.h.in; fi + +flags=("$@") + +function path() { + xcodebuild -sdk "$1" -version Path +} + +xcs=$(xcode-select --print-path) +mac=$(path macosx) + +function configure() { + local dir=$1 + local sdk=$2 + local flg=$3 + shift 3 + + cc=$(xcrun --sdk "${sdk}" -f clang) + cxx=$(xcrun --sdk "${sdk}" -f clang++) + flg+=" -isysroot $(path "${sdk}")" + + rm -rf build."${dir}" + mkdir build."${dir}" + cd build."${dir}" + + CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \ + ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" + + cd .. +} + +function build() { + local dir=$1 + local sdk=$2 + local flg=$3 + shift 3 + + configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic +} + +for arch in i386 x86_64; do + build "osx-${arch}" "${mac}" "-arch ${arch} -mmacosx-version-min=10.6" \ + CPPFLAGS="-I../readline.osx" LDFLAGS="-L../readline.osx" +done + +for arch in i386 x86_64; do + build "sim-${arch}" iphonesimulator "-arch ${arch} -mios-simulator-version-min=4.0" \ + OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" \ + CPPFLAGS="-I../libffi.${arch}/include" \ + LDFLAGS="-L.." \ + --disable-console +done + +for arch in armv6 armv7 armv7s arm64; do + cpf="-I../libffi.${arch}/include" + ldf="-L.." + + flg=() + if [[ ${arch} != armv6 ]]; then + flg+=(--disable-console) + else + flg+=(LTLIBGCC="-lgcc_s.1") + cpf+=" -include ${PWD}/xcode.h" + cpf+=" -mllvm -arm-reserve-r9" + cpf+=" -I../sysroot.ios/usr/include" + ldf+=" -L../sysroot.ios/usr/lib" + fi + + if [[ ${arch} == arm64 ]]; then + min=7.0 + else + min=2.0 + #cpf+=" -mthumb" + fi + + build "ios-${arch}" iphoneos "-arch ${arch} -miphoneos-version-min=${min}" --host=arm-apple-darwin10 \ + CPPFLAGS="${cpf}" LDFLAGS="${ldf}" "${flg[@]}" --host=arm-apple-darwin10 +done diff --git a/apple-libffi.sh b/apple-libffi.sh new file mode 100755 index 0000000..ac980df --- /dev/null +++ b/apple-libffi.sh @@ -0,0 +1,74 @@ +#!/usr/bin/env bash + +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2013 Jay Freeman (saurik) + +# GNU General Public License, Version 3 {{{ +# +# Cycript is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Cycript is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cycript. If not, see . +# }}} + +set -e + +archs=() +function arch() { + local arch=$1 + local host=$2 + local sdk=$3 + local os=$4 + local min=$5 + shift 5 + + rm -rf "libffi.${arch}" + if ! isysroot=$(xcodebuild -sdk "${sdk}" -version Path); then + return + fi + + archs+=("${arch}") + mkdir "libffi.${arch}" + + flags=() + flags+=(-isysroot "${isysroot}") + flags+=(-m${os}-version-min="${min}") + flags+=(-no-integrated-as) + flags+=(-fno-stack-protector) + flags+=(-O3 -g3) + + if [[ ${arch} == arm* && ${arch} != arm64 ]]; then + flags+=(-mthumb) + fi + + cd "libffi.${arch}" + CC="clang -arch ${arch}" CFLAGS="${flags[*]}" CPPFLAGS="${flags[*]} $*" ../libffi/configure --host="${host}" + make + cd .. +} + +arch armv6 arm-apple-darwin10 iphoneos iphoneos 2.0 -mllvm -arm-reserve-r9 +arch armv7 arm-apple-darwin10 iphoneos iphoneos 2.0 +arch armv7s arm-apple-darwin10 iphoneos iphoneos 2.0 +arch arm64 aarch64-apple-darwin11 iphoneos iphoneos 2.0 + +arch i386 i386-apple-darwin10 iphonesimulator ios-simulator 4.0 +arch x86_64 x86_64-apple-darwin11 iphonesimulator ios-simulator 4.0 + +libffi=() +for arch in "${archs[@]}"; do + a=libffi."${arch}"/.libs/libffi.a + # sectionForAddress(...) address not in any section file '...' for architecture i386 + ar m "${a}" src/prep_cif.o + libffi+=("${a}") +done + +lipo -create -output libffi.a "${libffi[@]}" diff --git a/apple-make.sh b/apple-make.sh new file mode 100755 index 0000000..0f552ba --- /dev/null +++ b/apple-make.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2013 Jay Freeman (saurik) + +# GNU General Public License, Version 3 {{{ +# +# Cycript is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Cycript is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cycript. If not, see . +# }}} + +exec make -f apple.mk "$@" diff --git a/apple-readline.sh b/apple-readline.sh new file mode 100755 index 0000000..185db6c --- /dev/null +++ b/apple-readline.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2013 Jay Freeman (saurik) + +# GNU General Public License, Version 3 {{{ +# +# Cycript is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Cycript is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cycript. If not, see . +# }}} + +set -e + +arch="-arch i386 -arch x86_64" + +rm -rf readline.osx +mkdir readline.osx +cd readline.osx +CFLAGS="-g -O2 ${arch}" ../readline/configure --disable-shared --enable-static +make +ln -sf . readline diff --git a/apple.mk b/apple.mk new file mode 100644 index 0000000..b72d40d --- /dev/null +++ b/apple.mk @@ -0,0 +1,187 @@ +# Cycript - Optimizing JavaScript Compiler/Runtime +# Copyright (C) 2009-2013 Jay Freeman (saurik) + +# GNU General Public License, Version 3 {{{ +# +# Cycript is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation, either version 3 of the License, +# or (at your option) any later version. +# +# Cycript is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with Cycript. If not, see . +# }}} + +.DELETE_ON_ERROR: +SHELL := /bin/bash + +include codesign.mk + +lipo := $(shell xcrun --sdk iphoneos -f lipo) + +monotonic := $(shell git log -1 --pretty=format:%ct) +version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g') + +deb := cycript_$(version)_iphoneos-arm.deb +zip := cycript_$(version).zip + +cycript := +cycript += Cycript.lib/cycript +cycript += Cycript.lib/cycript0.9 +cycript += Cycript.lib/libcycript.dylib +cycript += Cycript.lib/libcycript-sys.dylib +cycript += Cycript.lib/libcycript-sim.dylib + +framework := +framework += Cycript +framework += Headers/Cycript.h + +framework := $(foreach os,ios osx,$(foreach file,$(framework),Cycript.$(os)/Cycript.framework/$(file))) + +links := +links += Cycript.lib/libsubstrate.dylib +links += Cycript.lib/cycript0.9 + +all := cycript $(cycript) $(framework) +all: $(all) + +$(zip): $(all) + rm -f $@ + zip -r9y $@ cycript Cycript.lib Cycript.{ios,osx} $(patsubst %,--exclude %,$(links)) + zip -r9 $@ $(links) + +zip: $(zip) + ln -sf $< 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 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 + +define build_any +.PHONY: build-$(1)-$(2) +build-$(1)-$(2): + $(MAKE) -C build.$(1)-$(2) +build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2) + @ +endef + +define build_lib +build.$(1)-$(2)/.libs/libcycript.dylib: build-$(1)-$(2) + @ +endef + +define build_osx +$(call build_any,osx,$(1)) +$(call build_lib,osx,$(1)) +build.osx-$(1)/.libs/cycript: build-osx-$(1) + @ +endef + +$(foreach arch,i386 x86_64,$(eval $(call build_osx,$(arch)))) + +define build_ios +$(call build_any,ios,$(1)) +endef + +$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch)))) + +define build_sim +$(call build_any,sim,$(1)) +$(call build_lib,sim,$(1)) +endef + +$(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 +$(call build_lib,ios,$(1)) +endef + +$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch)))) + +Cycript.lib/libcycript.dylib: build.osx-i386/.libs/libcycript.dylib build.osx-x86_64/.libs/libcycript.dylib build.ios-armv6/.libs/libcycript.dylib build.ios-arm64/.libs/libcycript.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.osx-i386/.libs/%_ build.osx-x86_64/.libs/%_ build.ios-armv6/.libs/%_ + @mkdir -p $(dir $@) + $(lipo) -create -output $@ $^ + +Cycript.lib/libcycript-sys.dylib: + @mkdir -p $(dir $@) + ln -sf libcycript.dylib $@ + +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) $@ + +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 + +libcycript-ios.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 $@ $^ + +libcycript-osx.o: libcycript-osx-i386.o libcycript-osx-x86_64.o + $(lipo) -create -output $@ $^ + +Cycript.%/Cycript.framework/Cycript: libcycript-%.o + @mkdir -p $(dir $@) + cp -a $< $@ + +Cycript.%/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 $@ + +install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-sim.dylib + sudo cp -af $(filter-out %.dylib,$^) /usr/bin + sudo cp -af $(filter %.dylib,$^) /usr/lib + + +cast: $(zip) + appcast.sh cycript/mac $(monotonic) $(version) $< "$(CYCRIPT_CHANGES)" + +.PHONY: all cast clean install zip diff --git a/libffi.sh b/libffi.sh deleted file mode 100755 index ac980df..0000000 --- a/libffi.sh +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env bash - -# Cycript - Optimizing JavaScript Compiler/Runtime -# Copyright (C) 2009-2013 Jay Freeman (saurik) - -# GNU General Public License, Version 3 {{{ -# -# Cycript is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. -# -# Cycript is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Cycript. If not, see . -# }}} - -set -e - -archs=() -function arch() { - local arch=$1 - local host=$2 - local sdk=$3 - local os=$4 - local min=$5 - shift 5 - - rm -rf "libffi.${arch}" - if ! isysroot=$(xcodebuild -sdk "${sdk}" -version Path); then - return - fi - - archs+=("${arch}") - mkdir "libffi.${arch}" - - flags=() - flags+=(-isysroot "${isysroot}") - flags+=(-m${os}-version-min="${min}") - flags+=(-no-integrated-as) - flags+=(-fno-stack-protector) - flags+=(-O3 -g3) - - if [[ ${arch} == arm* && ${arch} != arm64 ]]; then - flags+=(-mthumb) - fi - - cd "libffi.${arch}" - CC="clang -arch ${arch}" CFLAGS="${flags[*]}" CPPFLAGS="${flags[*]} $*" ../libffi/configure --host="${host}" - make - cd .. -} - -arch armv6 arm-apple-darwin10 iphoneos iphoneos 2.0 -mllvm -arm-reserve-r9 -arch armv7 arm-apple-darwin10 iphoneos iphoneos 2.0 -arch armv7s arm-apple-darwin10 iphoneos iphoneos 2.0 -arch arm64 aarch64-apple-darwin11 iphoneos iphoneos 2.0 - -arch i386 i386-apple-darwin10 iphonesimulator ios-simulator 4.0 -arch x86_64 x86_64-apple-darwin11 iphonesimulator ios-simulator 4.0 - -libffi=() -for arch in "${archs[@]}"; do - a=libffi."${arch}"/.libs/libffi.a - # sectionForAddress(...) address not in any section file '...' for architecture i386 - ar m "${a}" src/prep_cif.o - libffi+=("${a}") -done - -lipo -create -output libffi.a "${libffi[@]}" diff --git a/make.sh b/make.sh deleted file mode 100755 index a30c27c..0000000 --- a/make.sh +++ /dev/null @@ -1,22 +0,0 @@ -#!/usr/bin/env bash - -# Cycript - Optimizing JavaScript Compiler/Runtime -# Copyright (C) 2009-2013 Jay Freeman (saurik) - -# GNU General Public License, Version 3 {{{ -# -# Cycript is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. -# -# Cycript is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Cycript. If not, see . -# }}} - -exec make -f xcode.mk "$@" diff --git a/readline.sh b/readline.sh deleted file mode 100755 index cd11152..0000000 --- a/readline.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env bash - -# Cycript - Optimizing JavaScript Compiler/Runtime -# Copyright (C) 2009-2013 Jay Freeman (saurik) - -# GNU General Public License, Version 3 {{{ -# -# Cycript is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. -# -# Cycript is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Cycript. If not, see . -# }}} - -set -e - -arch="-arch i386 -arch x86_64" - -cd readline -CFLAGS="-g -O2 ${arch}" ./configure --disable-shared --enable-static -make -ln -sf . readline diff --git a/xcode.mk b/xcode.mk deleted file mode 100644 index b72d40d..0000000 --- a/xcode.mk +++ /dev/null @@ -1,187 +0,0 @@ -# Cycript - Optimizing JavaScript Compiler/Runtime -# Copyright (C) 2009-2013 Jay Freeman (saurik) - -# GNU General Public License, Version 3 {{{ -# -# Cycript is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. -# -# Cycript is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Cycript. If not, see . -# }}} - -.DELETE_ON_ERROR: -SHELL := /bin/bash - -include codesign.mk - -lipo := $(shell xcrun --sdk iphoneos -f lipo) - -monotonic := $(shell git log -1 --pretty=format:%ct) -version := $(shell git describe --always --tags --dirty="+" --match="v*" | sed -e 's@-\([^-]*\)-\([^-]*\)$$@+\1.\2@;s@^v@@;s@%@~@g') - -deb := cycript_$(version)_iphoneos-arm.deb -zip := cycript_$(version).zip - -cycript := -cycript += Cycript.lib/cycript -cycript += Cycript.lib/cycript0.9 -cycript += Cycript.lib/libcycript.dylib -cycript += Cycript.lib/libcycript-sys.dylib -cycript += Cycript.lib/libcycript-sim.dylib - -framework := -framework += Cycript -framework += Headers/Cycript.h - -framework := $(foreach os,ios osx,$(foreach file,$(framework),Cycript.$(os)/Cycript.framework/$(file))) - -links := -links += Cycript.lib/libsubstrate.dylib -links += Cycript.lib/cycript0.9 - -all := cycript $(cycript) $(framework) -all: $(all) - -$(zip): $(all) - rm -f $@ - zip -r9y $@ cycript Cycript.lib Cycript.{ios,osx} $(patsubst %,--exclude %,$(links)) - zip -r9 $@ $(links) - -zip: $(zip) - ln -sf $< 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 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 - -define build_any -.PHONY: build-$(1)-$(2) -build-$(1)-$(2): - $(MAKE) -C build.$(1)-$(2) -build.$(1)-$(2)/.libs/libcycript.a: build-$(1)-$(2) - @ -endef - -define build_lib -build.$(1)-$(2)/.libs/libcycript.dylib: build-$(1)-$(2) - @ -endef - -define build_osx -$(call build_any,osx,$(1)) -$(call build_lib,osx,$(1)) -build.osx-$(1)/.libs/cycript: build-osx-$(1) - @ -endef - -$(foreach arch,i386 x86_64,$(eval $(call build_osx,$(arch)))) - -define build_ios -$(call build_any,ios,$(1)) -endef - -$(foreach arch,armv6 armv7 armv7s arm64,$(eval $(call build_ios,$(arch)))) - -define build_sim -$(call build_any,sim,$(1)) -$(call build_lib,sim,$(1)) -endef - -$(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 -$(call build_lib,ios,$(1)) -endef - -$(foreach arch,armv6 arm64,$(eval $(call build_arm,$(arch)))) - -Cycript.lib/libcycript.dylib: build.osx-i386/.libs/libcycript.dylib build.osx-x86_64/.libs/libcycript.dylib build.ios-armv6/.libs/libcycript.dylib build.ios-arm64/.libs/libcycript.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.osx-i386/.libs/%_ build.osx-x86_64/.libs/%_ build.ios-armv6/.libs/%_ - @mkdir -p $(dir $@) - $(lipo) -create -output $@ $^ - -Cycript.lib/libcycript-sys.dylib: - @mkdir -p $(dir $@) - ln -sf libcycript.dylib $@ - -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) $@ - -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 - -libcycript-ios.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 $@ $^ - -libcycript-osx.o: libcycript-osx-i386.o libcycript-osx-x86_64.o - $(lipo) -create -output $@ $^ - -Cycript.%/Cycript.framework/Cycript: libcycript-%.o - @mkdir -p $(dir $@) - cp -a $< $@ - -Cycript.%/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 $@ - -install: Cycript.lib/cycript Cycript.lib/libcycript.dylib Cycript.lib/libcycript-sys.dylib Cycript.lib/libcycript-sim.dylib - sudo cp -af $(filter-out %.dylib,$^) /usr/bin - sudo cp -af $(filter %.dylib,$^) /usr/lib - - -cast: $(zip) - appcast.sh cycript/mac $(monotonic) $(version) $< "$(CYCRIPT_CHANGES)" - -.PHONY: all cast clean install zip diff --git a/xcode.sh b/xcode.sh deleted file mode 100755 index f6ab534..0000000 --- a/xcode.sh +++ /dev/null @@ -1,115 +0,0 @@ -#!/usr/bin/env bash - -# Cycript - Optimizing JavaScript Compiler/Runtime -# Copyright (C) 2009-2013 Jay Freeman (saurik) - -# GNU General Public License, Version 3 {{{ -# -# Cycript is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published -# by the Free Software Foundation, either version 3 of the License, -# or (at your option) any later version. -# -# Cycript is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with Cycript. If not, see . -# }}} - -set -e - -cd "${0%%/*}" - -if [[ ! -e readline/libreadline.a ]]; then - ./readline.sh; fi -if [[ ! -e libffi.a ]]; then - ./libffi.sh; fi - -if ! which aclocal; then - touch aclocal.m4; fi -if ! which autoconf; then - touch configure.ac; fi -if ! which automake; then - touch Makefile.in; fi -if ! which autoheader; then - touch config.h.in; fi - -flags=("$@") - -function path() { - xcodebuild -sdk "$1" -version Path -} - -xcs=$(xcode-select --print-path) -mac=$(path macosx) - -function configure() { - local dir=$1 - local sdk=$2 - local flg=$3 - shift 3 - - cc=$(xcrun --sdk "${sdk}" -f clang) - cxx=$(xcrun --sdk "${sdk}" -f clang++) - flg+=" -isysroot $(path "${sdk}")" - - rm -rf build."${dir}" - mkdir build."${dir}" - cd build."${dir}" - - CC="${cc} ${flg}" CXX="${cxx} ${flg}" OBJCXX="${cxx} ${flg}" \ - ../configure --enable-maintainer-mode "${flags[@]}" --prefix="/usr" "$@" - - cd .. -} - -function build() { - local dir=$1 - local sdk=$2 - local flg=$3 - shift 3 - - configure "${dir}" "${sdk}" "${flg}" "$@" --enable-static --with-pic -} - -for arch in i386 x86_64; do - build "osx-${arch}" "${mac}" "-arch ${arch} -mmacosx-version-min=10.6" \ - CPPFLAGS="-I../readline" LDFLAGS="-L../readline" -done - -for arch in i386 x86_64; do - build "sim-${arch}" iphonesimulator "-arch ${arch} -mios-simulator-version-min=4.0" \ - OBJCXXFLAGS="-fobjc-abi-version=2 -fobjc-legacy-dispatch" \ - CPPFLAGS="-I../libffi.${arch}/include" \ - LDFLAGS="-L.." \ - --disable-console -done - -for arch in armv6 armv7 armv7s arm64; do - cpf="-I../libffi.${arch}/include" - ldf="-L.." - - flg=() - if [[ ${arch} != armv6 ]]; then - flg+=(--disable-console) - else - flg+=(LTLIBGCC="-lgcc_s.1") - cpf+=" -include ${PWD}/xcode.h" - cpf+=" -mllvm -arm-reserve-r9" - cpf+=" -I../sysroot.ios/usr/include" - ldf+=" -L../sysroot.ios/usr/lib" - fi - - if [[ ${arch} == arm64 ]]; then - min=7.0 - else - min=2.0 - #cpf+=" -mthumb" - fi - - build "ios-${arch}" iphoneos "-arch ${arch} -miphoneos-version-min=${min}" --host=arm-apple-darwin10 \ - CPPFLAGS="${cpf}" LDFLAGS="${ldf}" "${flg[@]}" --host=arm-apple-darwin10 -done