# Agent iPod émulé (armv6, iPhone OS 2.x)
SDK := /opt/theos/sdks/iPhoneOS2.2.1.sdk
CC  := /opt/cctools/bin/arm-apple-darwin9-gcc
CFLAGS := -isysroot $(SDK) -arch armv6 -miphoneos-version-min=2.0 -O2 -Wall -Wno-deprecated-declarations
FRAMEWORKS := -framework CoreFoundation -framework SystemConfiguration

all: overlay

emuagent: emuagent.c entitlements.plist
	$(CC) $(CFLAGS) -o $@ $< $(FRAMEWORKS)
	ldid -Sentitlements.plist $@   # entitlements vérifiés par SpringBoard pour SBSLaunchApplication

overlay: emuagent com.allovoisins.emuagent.plist
	rm -rf overlay && mkdir -p overlay/usr/libexec overlay/System/Library/LaunchDaemons
	cp emuagent overlay/usr/libexec/
	cp com.allovoisins.emuagent.plist overlay/System/Library/LaunchDaemons/
	# résolution DNS (retirée de l'image de base avec les autres démons)
	cp apple/com.apple.mDNSResponder.plist apple/com.apple.mDNSResponderHelper.plist overlay/System/Library/LaunchDaemons/

clean:
	rm -rf emuagent overlay

.PHONY: all overlay clean
