iOS static library cross-compile script

 
 
# iOS builds for ARMv7 and simulator i386.
# Assumes any dependencies are in a local folder called libs and
# headers in a local folder called headers.
# Dependencies should already have been compiled for the target arch.
 
PROJ =untitled
ifeq ($(IOS), 1)
ARCH =armv7
DEVICE =OS
CC_FLAGS =-arch $(ARCH )
CFLAGS_FLAGS =-mcpu =cortex-a8 -marm
else
ARCH =i386
CC_FLAGS =-arch $(ARCH )
DEVICE =Simulator
endif
 
DEVROOT =/Developer/Platforms/iPhone $(DEVICE ).platform/Developer
SDKROOT = ${ DEVROOT }/SDKs/iPhone $(DEVICE )4.3.sdk
CC = $(DEVROOT )/usr/bin/gcc $(CC_FLAGS )
LD = $(CC )
CFLAGS =-isysroot ${ SDKROOT } -Iheaders $(CFLAGS_FLAGS )
LDFLAGS =-isysroot ${ SDKROOT } -Wl, -syslibroot ${ SDKROOT }
 
SRC = $(wildcard *.c )
#OBJS := $(foreach var, $(SRC), $(SRC_ROOT)/$(basename $(var)).o)
OBJS = $(patsubst %.c,%.o, $(SRC ))
DEPS =ssl crypto expat
LIBDIR = $(shell pwd )/libs
LDLIBS = $(patsubst %, $(DIR )/lib%.a, $(DEPS ))
 
all : $( ARCH )- $( PROJ ). a
 
$(ARCH)-$(PROJ).a : $( OBJS )
@echo $(LDLIBS ) $(OBJS )
ar rcs $@ $(OBJS )
ranlib $@
 
.PHONY : lipo
lipo :
lipo -create -arch armv7 armv7- $(PROJ ).a -arch i386 i386- $(PROJ ).a -output $(PROJ ).a
 
clean :
rm $(OBJS )
 
 
.PHONY : realclean
realclean : clean
rm *.a
   
   
make realclean ;
make ;
make clean ;
make IOS =1 ;
make lipo

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值