Skip to content
Snippets Groups Projects
Commit 1010bab0 authored by Fred Wright's avatar Fred Wright Committed by Christopher Nielsen
Browse files

Add tool to create temporary tool Makefile.

This creates a simple Makefile for C programs, with architecture(s)
derived from macports.conf.

TESTED:
Makefile has proper architectures with all options on all platforms.
parent 42932b8d
No related branches found
No related tags found
No related merge requests found
#! /bin/bash
# Tool to create temporary simple "C" Makefile for misc tools, based on
# the architecture settings in macports.conf.
#
# Usage is: archsetup.sh [-m32|-m64|-unv] [<output dir>]
# Options modify the architecture specification.
DIR=$(dirname "$0")
OPT=""
case "$1" in
"-m32" | "-m64" | "-unv" )
OPT="$1"
shift
;;
esac
if [ "$1" != "" ]; then
DEST="$1"
else
DEST="$DIR"
fi
PREFIX="/opt/local/"
CONF="$PREFIX/etc/macports/macports.conf"
OUT="Makefile"
BUILD_ARCH="$(grep '^build_arch' $CONF | awk '{print $2}')"
UNV_ARCHS="$(grep '^universal_archs' $CONF \
| sed 's|universal_archs[[:blank:]]*||')"
case "$OPT" in
"-m32" )
case "$BUILD_ARCH" in
"ppc64" )
ARCHS="ppc"
;;
"x86_64" )
ARCHS="i386"
;;
* )
ARCHS="$BUILD_ARCH"
esac
;;
"-m64" )
case "$BUILD_ARCH" in
"ppc" | "ppc7400" )
ARCHS="ppc64"
;;
"i386" )
ARCHS="x86_64"
;;
* )
ARCHS="$BUILD_ARCH"
esac
;;
"-unv" )
ARCHS="$UNV_ARCHS"
;;
* )
ARCHS="$BUILD_ARCH"
;;
esac
if [ "$CC" == "" ]; then
CC="cc"
fi
ARCHFLAGS="$(for a in $ARCHS; do echo -n ' -arch' $a; done)"
CCCMD=$'\t'"$CC$ARCHFLAGS \$^ -o \$@"
cat >"$DEST/$OUT" <<EOF
%: %.c
$CCCMD
EOF
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment