1PREFIX?=
2BUILD_DIR?=$(shell defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null)
3
4ifeq ($(strip $(BUILD_DIR)),)
5	BUILD_DIR=build
6endif
7
8DEFAULT_BUILDCONFIGURATION=Release-Debug
9
10BUILDCONFIGURATION?=$(DEFAULT_BUILDCONFIGURATION)
11
12# Choose xcodebuild 
13# currently used for build machines
14# XCODEBUILD ?= $(shell if test -d /Xcode4; then echo "/Xcode4/usr/bin/xcodebuild"; else echo "xcodebuild"; fi)
15XCODEBUILD ?= xcodebuild
16#
17
18CP=ditto --rsrc
19RM=rm
20
21.PHONY: all adium clean localizable-strings latest test astest install
22
23adium:
24	$(XCODEBUILD) -version
25	$(XCODEBUILD) -project Adium.xcodeproj -configuration $(BUILDCONFIGURATION) CFLAGS="$(ADIUM_CFLAGS)" $(ADIUM_NIGHTLY_FLAGS) build
26
27test:
28	$(XCODEBUILD) -version
29	$(XCODEBUILD) -project Adium.xcodeproj -configuration $(BUILDCONFIGURATION) CFLAGS="$(ADIUM_CFLAGS)" $(ADIUM_NIGHTLY_FLAGS) -target "Unit tests" build
30astest:
31	osascript unittest\ runner.applescript | tr '\r' '\n'
32
33install:
34	mkdir -p ~/Applications
35	cp -R build/$(BUILDCONFIGURATION)/Adium.app ~/Applications/
36
37clean:
38	$(XCODEBUILD) -version
39	$(XCODEBUILD) -project Adium.xcodeproj -configuration $(BUILDCONFIGURATION) $(ADIUM_NIGHTLY_FLAGS) clean
40
41localizable-strings:
42	mkdir tmp || true
43	mv "Plugins/Purple Service" tmp
44	genstrings -o Resources/en.lproj -s AILocalizedString Source/*.m Source/*.h Plugins/*/*.h Plugins/*/*.m Plugins/*/*/*.h Plugins/*/*/*.m
45	genstrings -o tmp/Purple\ Service/Resources/en.lproj -s AILocalizedString tmp/Purple\ Service/*.h tmp/Purple\ Service/*.m
46	genstrings -o Frameworks/AIUtilities\ Framework/Resources/en.lproj -s AILocalizedString Frameworks/AIUtilities\ Framework/Source/*.h Frameworks/AIUtilities\ Framework/Source/*.m
47	genstrings -o Frameworks/Adium\ Framework/Resources/en.lproj -s AILocalizedString Frameworks/Adium\ Framework/Source/*.m Frameworks/Adium\ Framework/Source/*.h
48	mv "tmp/Purple Service" Plugins
49	rmdir tmp || true
50
51latest:
52	hg pull -u
53	make adium
54