Here is a patch to make buliding for ios a lot easier out of the box.

The patch:

   1. Makes building cryptopp into a 'build' directory possible.  In other 
   words, mkdir build; cd build; make -f ../GNUMakefile will put all the .o 
   and .a into the build directory.  This is needed because iOS needs to run 
   the make process twice, once for the device and once for the simulator.
   2. Adds a new target for iphone/libcryptopp.a, which uses (1) to build 
   the library
   3. Adds a new target for iphonesim/libcryptopp.a, which uses (1) to 
   build the library
   4. Adds a new target for ios/libcryptopp.a, which depends on (2) and (3) 
   and uses lipo to combine the two libraries
   5. Adds a new convenience target, ios, which depends on ios/libcryptopp.a

Of course I'd like to see this patch reviewed and committed :-)  So any 
comments would be welcome.

Thanks,

Joseph

-- 
You received this message because you are subscribed to the "Crypto++ Users" 
Google Group.
To unsubscribe, send an email to [email protected].
More information about Crypto++ and this group is available at 
http://www.cryptopp.com.
Index: GNUmakefile
===================================================================
--- GNUmakefile	(revision 533)
+++ GNUmakefile	(working copy)
@@ -1,3 +1,5 @@
+TOP := $(dir $(lastword $(MAKEFILE_LIST)))
+
 CXXFLAGS = -DNDEBUG -g -O2
 #CXXFLAGS = -g
 # -fPIC is supported. Please report any breakage of -fPIC as a bug.
@@ -13,6 +15,7 @@
 UNAME = $(shell uname)
 ISX86 = $(shell uname -m | $(EGREP) -c "i.86|x86|i86|amd64")
 IS_SUN_CC = $(shell $(CXX) -V 2>&1 | $(EGREP) -c "CC: Sun")
+RM = rm -rf
 
 # Default prefix for make install
 ifeq ($(PREFIX),)
@@ -101,6 +104,24 @@
 endif
 endif
 
+ifneq ($(filter iphone iphonesim,$(MAKECMDGOALS)),)
+	XCODE_ROOT=$(shell xcode-select --print-path)
+	CXX=$(XCODE_ROOT)/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
+	CXXFLAGS += -std=c++11 -stdlib=libc++
+	LDFLAGS += -stdlib=libc++
+
+	SDK_VERSION ?= 6.0
+	ifeq ($(MAKECMDGOALS),iphone)
+		SDKROOT=$(XCODE_ROOT)/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS$(SDK_VERSION).sdk
+		ARCHS ?= -arch armv6 -arch armv7 -arch armv7s
+	else
+		SDKROOT=$(XCODE_ROOT)/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(SDK_VERSION).sdk
+		ARCHS ?= -arch i386
+	endif
+
+	CXXFLAGS += -isysroot $(SDKROOT) $(ARCHS)
+endif
+
 ifeq ($(UNAME),SunOS)
 LDLIBS += -lnsl -lsocket
 M32OR64 = -m$(shell isainfo -b)
@@ -120,12 +141,14 @@
 endif
 endif
 
-SRCS = $(wildcard *.cpp)
+SRCS = $(wildcard $(TOP)/*.cpp)
 ifeq ($(SRCS),)				# workaround wildcard function bug in GNU Make 3.77
-SRCS = $(shell echo *.cpp)
+SRCS = $(shell echo $(TOP)/*.cpp)
 endif
 
-OBJS = $(SRCS:.cpp=.o)
+VPATH=$(TOP)
+
+OBJS = $(notdir $(SRCS:.cpp=.o))
 # test.o needs to be after bench.o for cygwin 1.1.4 (possible ld bug?)
 TESTOBJS = bench.o bench2.o test.o validat1.o validat2.o validat3.o adhoc.o datatest.o regtest.o fipsalgt.o dlltest.o
 LIBOBJS = $(filter-out $(TESTOBJS),$(OBJS))
@@ -137,14 +160,27 @@
 DLLTESTOBJS = dlltest.dllonly.o
 
 all: cryptest.exe
-static: libcryptopp.a
+static iphone iphonesim: libcryptopp.a
 dynamic: libcryptopp.so
+ios: ios/libcryptopp.a
 
+ios/libcryptopp.a: iphone/libcryptopp.a iphonesim/libcryptopp.a
+	mkdir -p ios
+	lipo -create iphone/libcryptopp.a iphonesim/libcryptopp.a -o ios/libcryptopp.a
+
+iphone/libcryptopp.a:
+	mkdir -p iphone
+	cd iphone && $(MAKE) -f ../GNUMakefile iphone
+
+iphonesim/libcryptopp.a:
+	mkdir -p iphonesim
+	cd iphonesim && $(MAKE) -f ../GNUMakefile iphonesim
+
 test: cryptest.exe
 	./cryptest.exe v
 
 clean:
-	-$(RM) cryptest.exe libcryptopp.a libcryptopp.so $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTI MPORTOBJS) $(DLLTESTOBJS)
+	-$(RM) cryptest.exe libcryptopp.a libcryptopp.so $(LIBOBJS) $(TESTOBJS) cryptopp.dll libcryptopp.dll.a libcryptopp.import.a cryptest.import.exe dlltest.exe $(DLLOBJS) $(LIBIMPORTOBJS) $(TESTI MPORTOBJS) $(DLLTESTOBJS) ios iphone iphonesim
 
 install:
 	$(MKDIR) -p $(PREFIX)/include/cryptopp $(PREFIX)/lib $(PREFIX)/bin

Reply via email to