-
-
Save RGPaul/9599ea627a5190055233fd1c3782acaa to your computer and use it in GitHub Desktop.
iOS static library cross-compile script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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=$(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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
make realclean; | |
make; | |
make clean; | |
make IOS=1; | |
make lipo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment