# -*- mode: makefile -*-
#
# Build universal curl linked to libcurl framework. The built exeutable
# can be distributed in an application bundle Resources or MacOS
# directory, with the libcurl.framework in the bundle Frameworks
# directory.
#
# Usage:
#
#	cd curl-x.x.x
#	make -f /path/to/makefile 
#
# Copyright (C) 1998 - 2006, Daniel Stenberg, <daniel@haxx.se>, et al.
#
# This software is licensed as described in the file COPYING, which
# you should have received as part of this distribution. The terms
# are also available at http://curl.haxx.se/docs/copyright.html.
#
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
# copies of the Software, and permit persons to whom the Software is
# furnished to do so, under the terms of the COPYING file.
#
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
# KIND, either express or implied.


PREFIX := $(CURDIR)/universal-framework
FRAMEWORK_DIR := $(PREFIX)/Frameworks
FRAMEWORK_PATH := $(FRAMEWORK_DIR):$(DYLD_FRAMEWORK_PATH)
SDK := /Developer/SDKs/MacOSX10.4u.sdk

all: configure framework
	cd src; make install \
		curl_LDADD="-framework libcurl" \
		curl_DEPENDENCIES="$(FRAMEWORK_DIR)/libcurl.framework"

framework: configure
	cd lib; make build -e -f libcurl.framework.make
	mkdir -p $(FRAMEWORK_DIR)
	ditto lib/libcurl.framework $(FRAMEWORK_DIR)/libcurl.framework

configure:
	./configure \
		--prefix=$(PREFIX) \
		--disable-dependency-tracking \
		CFLAGS="-F$(FRAMEWORK_DIR) -isysroot $(SDK) -arch ppc -arch i386" \
		LDFLAGS="-Wl,-syslibroot,$(SDK) -arch ppc -arch i386" \
		DYLD_FRAMEWORK_PATH=$(FRAMEWORK_PATH)

# Tests needs some refactoring so we can override the usage of
# libcurl.la with the framework.
test:
	echo "not implemented yet"

clean:
	cd src; make clean
	cd lib; make clean -e -f libcurl.framework.make
	rm -rf $(PREFIX)

.PHONY: all configure framework clean

