Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
92 lines (71 sloc) 3.23 KB
SHELL=/bin/bash
# somewhat minimal makefile for iPhone
# current as of xcode 3.2.5, iOS 4.2 (January 2011)
#
# usage:
# make (compiles and installs app in simulator)
# make clean (also removes app from simulator)
# make sim (runs simulator)
APPNAME=BasicApp
# this needs to be changed if you using a different SDK version. affects paths.
IOSVERSION=4.2
# use /usr/bin/uuidgen to generate a unique UUID for this app
UUID=4663FCE9-0675-432B-8390-1E17D122859C
SRCS = \
main.m \
BasicApp.m # \ Debug.m # save for later date
# you shouldn't need to change anything below this line
##########################################################
# redirects errors/warnings and stops make if error. pretty printing to prepend tab to gcc messages
# (perl is used as sed always returns true and doesn't stop compilation process)
PREPEND_CMD = 2>&1 | perl -p -e 'if ($$_=~/error/) {print "\t$$_"; exit 1;} else {print "\t";}'
PATH=/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/Developer/usr/bin:/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin
MACOSX_DEPLOYMENT_TARGET=10.6
SIMULATOR=/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
APP_LOC = ~/Library/Application\ Support/iPhone\ Simulator/$(IOSVERSION)/Applications/$(UUID)
DIR:=$(shell pwd)
BUILDDIR:=$(DIR)/build
CC = /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/gcc-4.2
CFLAGS = -x objective-c -arch i386 -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -Os \
-mdynamic-no-pic -Wreturn-type -Wunused-variable -D__IPHONE_OS_VERSION_MIN_REQUIRED=30200 -DNS_BLOCK_ASSERTIONS=1 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(IOSVERSION).sdk \
-fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch
LDFLAGS = -arch i386 -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 \
-isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator$(IOSVERSION).sdk \
-L$(DIR) \
-F$(DIR) \
-framework Foundation \
-framework UIKit \
-framework CoreGraphics
SRCS := $(addprefix $(DIR)/, $(SRCS))
OBJS := $(SRCS:.m=.o)
OBJS := $(notdir $(OBJS))
OBJS := $(addprefix $(BUILDDIR)/, $(OBJS))
##########################################################
all: prep Application
prep: ;
@cd $(DIR); \
mkdir -p build; \
mkdir -p build/$(UUID); \
mkdir -p build/$(UUID)/$(APPNAME).app
Application: $(OBJS)
@tput setf 4 # red
@echo 'Linking...'
@tput setf 9 # white
@$(CC) $(LDFLAGS) -o $(BUILDDIR)/$(UUID)/$(APPNAME).app/$(APPNAME) $^ $(PREPEND_CMD)
@tput setf 3 # teal
@echo 'Generating Info.plist...'
@sed 's/SecondTest/$(APPNAME)/g' Info.plist > $(BUILDDIR)/$(UUID)/$(APPNAME).app/Info.plist
@echo 'Copying $(APPNAME) to simulator...'
@tput setf 9 # white
@cp -R $(BUILDDIR)/$(UUID) ~/Library/Application\ Support/iPhone\ Simulator/$(IOSVERSION)/Applications/
%.o: ../%.m
@tput setf 5 # purple
@echo 'Compiling $(notdir $<)...'
@tput setf 9 # white
@$(CC) $(CFLAGS) -I. -c $< -o $@ $(PREPEND_CMD)
sim: ;
@open $(SIMULATOR)
clean:
@rm -rf build
@rm -rf $(APP_LOC)