Permalink
Browse files

Add script to assist in building fat ZMQ binaries.

  • Loading branch information...
1 parent 76a1a04 commit d0242525c6b8a2263d9b53fae93215ef1637fc27 @jeremy-w committed Jul 16, 2010
Showing with 42 additions and 0 deletions.
  1. +42 −0 scripts/build_universal.sh
View
@@ -0,0 +1,42 @@
+#!/bin/sh
+ARCHS="i386 x86_64"
+INSTALL_PREFIX="$PWD/execs"
+
+# Build each architecture's files.
+for A in $ARCHS; do
+ echo "Cleaning project..."
+ make clean # clear out previous architecture's files
+
+ echo "Building architecture: $A"
+ echo "Install prefix: $INSTALL_PREFIX-$A"
+ # -arch specifies the target architecture. --exec-prefix controls where the executables will be placed.
+ CFLAGS="$CFLAGS -arch $A" CPPFLAGS="$CPPFLAGS $CFLAGS" LDFLAGS="$LDFLAGS -arch $A" ./configure --with-pic --exec-prefix="$INSTALL_PREFIX-$A" \
+ && make \
+ && make install-exec
+done
+
+# Smoosh the results together using lipo.
+LIPO="`which lipo`"
+mkdir "$INSTALL_PREFIX" # final executables end up here
+
+MODEL_ARCH="`echo \"$ARCHS\" | cut -d' ' -f1`" # first architecture
+# Really need a proper treewalk.
+for DIR in "$INSTALL_PREFIX-$MODEL_ARCH/"*; do
+ echo "Making files in $DIR fat..."
+ DIRNAME=`basename "$DIR"`
+ mkdir "$INSTALL_PREFIX/$DIRNAME"
+
+ for FILE in $DIR/*; do
+ FNAM=`basename $FILE`
+ echo "Fattening $FNAM..."
+
+ ARCH_FILES=""
+ for A in $ARCHS; do
+ ARCH_FILES="$ARCH_FILES $INSTALL_PREFIX-$A/$DIRNAME/$FNAM"
+ done
+
+ $LIPO -create -output "$INSTALL_PREFIX/$DIRNAME/$FNAM" $ARCH_FILES
+ done
+done
+
+echo "Universal files should be under the $INSTALL_PREFIX directory."

0 comments on commit d024252

Please sign in to comment.