1# Global definitions for MacOSX builds
2# (c) 2011 Angel Vidal ( kry@amule.org )
3# Public domain. Use at your own risk.
4
5. defs-functions.sh
6
7# Wouldn't I love to have bash4 on MacOSX (case fallthrough)
8
9pn "-- Begin global def section --"
10
11SVN_REPOSITORY=$1
12
13if [ -z $SVN_REPOSITORY ]; then
14        AMULE_FOLDER=`cd ${SCRIPTDIR}/../../../../; pwd`
15	if [ -f "${AMULE_FOLDER}/src/amule.cpp" ]; then
16		pc $GREEN "\tSVN repository has not been specified, using detected local sources at \"${AMULE_FOLDER}\""
17	else
18		pc $RED "\tSVN repository has not been specified, and no local sources found at \"${AMULE_FOLDER}\".\n\tPlease specify your aMule source folder by setting the AMULE_FOLDER variable, or call the script with the SVN repository of your choice as a first parameter, or \"public\" to download from our public SVN repository."
19		exit
20	fi
21fi
22
23if [ -z "$BUILD_FOLDER" ]; then
24	if [ -z $SVN_REPOSITORY ]; then
25		BUILD_FOLDER="$AMULE_FOLDER/build/"
26		mkdir $BUILD_FOLDER 2>/dev/null
27	else
28		BUILD_FOLDER=`pwd`
29	fi
30
31	pc $BLUE "\tAutomatically setting build folder to ${BUILD_FOLDER} - set BUILD_FOLDER to your preferred folder to change this setting."
32else
33	pc $GREEN "\tSetting build folder to $BUILD_FOLDER"
34fi
35
36ROOT_FOLDER=`cd $BUILD_FOLDER; pwd`
37
38if [ -z $AMULE_FOLDER ]; then
39        AMULE_FOLDER="${ROOT_FOLDER}/amule-dev"
40fi
41
42pc $GREEN "\tBuild root absolute path is $ROOT_FOLDER"
43
44if [ "$SDKNUMBER" == "" ]; then
45	pc $BLUE "\tAutomatically setting SDK to 10.4u (tiger with i386 and ppc, gcc 4.0) - set SDKNUMBER to your preferred SDK if you want to target it (10.5, 10.6, 10.7) or \"default\" for the default SDK."
46	SDKNUMBER=10.4
47fi
48
49case "$SDKNUMBER" in
50"10.4")
51	SDKRELEASE=10.4u
52	CCVERSION="-4.0"
53	;;
54"10.5"|"10.6"|"10.7")
55	SDKRELEASE=$SDKNUMBER
56	;;
57default)
58	;;
59*)
60	pc $RED "Valid SDKNUMBER values are 10.4, 10.5, 10.6, 10.7 and default."
61	exit
62	;;
63esac
64
65pc $GREEN "\tUsing $SDKNUMBER SDK"
66
67if [ "$SDKNUMBER" != "default" ]; then
68	SDK="-isysroot /Developer/SDKs/MacOSX${SDKRELEASE}.sdk -mmacosx-version-min=$SDKNUMBER"
69else
70	SDKNUMBER=""
71fi
72
73if [ "$UNIVERSAL" == "" ]; then
74	pc $BLUE "\tAutomatically enabling universal (i386, ppc) build. Set UNIVERSAL=NO to build just for the current architecture."
75	UNIVERSAL="YES"
76fi
77
78case "$UNIVERSAL" in
79"NO"|"no")
80	pc $GREEN "\tDisabling universal build"
81	ARCHCPPFLAGS="$BUILDARCHS"
82	ARCHCONFIGFLAGS=""
83	;;
84"YES"|"yes")
85	pc $GREEN "\tUsing universal build (i386, pcc)" 
86	ARCHCPPFLAGS="-arch i386 -arch ppc"
87	ARCHCONFIGFLAGS="--enable-universal_binary"
88	CCVERSION="-4.0"
89	;;
90*)
91	pc $RED "Only the values \"NO\" and \"YES\" are valid for UNIVERSAL"
92	exit
93	;;
94esac
95
96if [ "$STDOUT_FILE" == "" ]; then
97	STDOUT_FILE=${ROOT_FOLDER}/build_output
98fi
99
100if [ "$ERROR_FILE" == "" ]; then
101	ERROR_FILE=${ROOT_FOLDER}/error_output
102fi
103
104pc $GREEN "\tErrors will be redirected to $ERROR_FILE, normal build output to $STDOUT_FILE"
105
106pn "-- End global def section --"
107