summaryrefslogtreecommitdiff
path: root/setup/build-env.sh
blob: 50d844660a4c4fc5ad259363991fad5997c29a71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#!/bin/sh

# Familiar Build Setup Script
#
# Copyright (C) 2006  Rene Wagner <rw@handhelds.org>
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#

BASE_TITLE="Familiar Build Setup:"
FAMILIAR_RELEASE="0.8.4"

fatal() {
	echo "Fatal: $1"
	exit 1
}

error() {
	zenity --error --text="$1"
}

abort() {
	zenity --info --text="Setup aborted."
	exit 1
}

which zenity > /dev/null || fatal "You must have zenity installed."

BASE_DIR=${PWD}
while [ ! -d ${BASE_DIR}/org.handhelds.familiar ]; do
	 BASE_DIR=`zenity --file-selection --directory --filename=${BASE_DIR} --title="${BASE_TITLE} Select Build Tree Base Directory"`
	 case $? in
	 	0)
			if [ ! -d ${BASE_DIR}/org.handhelds.familiar ]; then
				error "Does not look like a Familiar build tree: ${BASE_DIR}"
			fi
			;;
		1)
			abort;;
		-1)
			abort;;
	esac
done

DL_DIR="${BASE_DIR}/downloads"
DL_DIR=`zenity  --entry \
	--title="${BASE_TITLE} Downloads Directory" \
        --text="Where do you want downloaded files to be stored?" \
        --entry-text="${DL_DIR}"`
case $? in
	1)
		abort;;
	-1)
		abort;;
esac

while [ -z "$MACHINE" ]; do
MACHINE=`zenity  --list \
	--height=280 \
	--title="${BASE_TITLE} Target Machine" \
	--text="Select a target machine type from the list below:" \
	--column="Name" --column="Description" \
	"h3600" "HP iPAQ h36xx/h37xx/h38xx Series" \
	"h3900" "HP iPAQ h39xx/h51xx/h54xx/h55xx Series" \
	"h2200" "HP iPAQ h22xx Series" \
	"ipaq-pxa270" "HP iPAQ hx4700 Series" \
	"h6300" "HP iPAQ h63xx Series"`
case $? in
	0)
		if [ -z "$MACHINE" ]; then
			error "Please select a target machine."
		fi
		;;
	1)
		abort;;
	-1)
		abort;;
esac
done

while [ -z "$GRAPHICAL_ENV" ]; do
GRAPHICAL_ENV=`zenity  --list \
	--height=280 \
	--title="${BASE_TITLE} Primary Graphical Environment" \
	--text="Select the graphical environment you want to build for from the list below:" \
	--column="Name" --column="Description" \
	"gpe" "The GPE Palmtop Environment. X11 based." \
	"opie" "The Open Palmtop Integrated Environment. Qt/Embedded based." \
	"any" "No preference. This may break certain things."`
case $? in
	0)
		if [ -z "$GRAPHICAL_ENV" ]; then
			error "Please select a graphical environment."
		fi
		;;
	1)
		abort;;
	-1)
		abort;;
esac
done

BUILD_DIR="${BASE_DIR}/build-${MACHINE}-${GRAPHICAL_ENV}"
while true; do
	BUILD_DIR=`zenity  --entry \
		--title="${BASE_TITLE} Build Directory" \
		--text="A build directory will be created for the configuration you selected at the following location:" \
		--entry-text="${BUILD_DIR}"`
	case $? in
		1)
			abort;;
		-1)
			abort;;
	esac
	if [ -z ${BUILD_DIR} ]; then
		error "Please specify a build directory."
		continue
	fi
	if [ -d ${BUILD_DIR} ]; then
		error "${BUILD_DIR} exists."
		continue
	fi
	
	break
done

mkdir -p ${BUILD_DIR}/conf
CONFFILE="${BUILD_DIR}/conf/auto.conf"
cat >  ${CONFFILE} <<EOF
# Auto-generated Familiar Build Configuration

DISTRO="familiar-${FAMILIAR_RELEASE}"

# where to store downloaded files
DL_DIR = "${DL_DIR}"

# list of .bb files as a shell glob
BBFILES = "${BASE_DIR}/org.handhelds.familiar/packages/*/*bb"

# top level build directory for this configuration
TOPDIR = "${BUILD_DIR}"

# target MACHINE
MACHINE = "${MACHINE}"

EOF

if [ "${GRAPHICAL_ENV}" == "gpe" ]; then
cat >> ${CONFFILE} <<EOF
# X11 specific settings
PREFERRED_PROVIDERS += " virtual/libsdl:libsdl-x11"

EOF
elif [ "${GRAPHICAL_ENV}" == "opie" ]; then
cat >> ${CONFFILE} <<EOF
# Opie specific settings
PREFERRED_PROVIDERS += " virtual/libsdl:libsdl-qpe"

EOF
fi

ENVSCRIPT="${BUILD_DIR}/conf/env.sh"
cat > ${ENVSCRIPT} <<EOF
PATH="${BASE_DIR}/bitbake/bin:${PATH}"
BBPATH="${BUILD_DIR}:${BASE_DIR}/org.handhelds.familiar"
EOF

zenity  --info \
	--title="${BASE_TITLE} Setup Complete" \
	--text="Your configuration was written to ${CONFFILE}. It will be displayed after this dialog. Please verify that all settings are correct. To re-start the setup please delete the build directory and re-run the setup tool."

zenity  --text-info \
	--width=600 --height=400 \
	--title="${BASE_TITLE} Configuration Written to ${CONFFILE}" \
	--filename="${CONFFILE}"

zenity  --info \
	--title="${BASE_TITLE} Running a Build" \
	--text="Please run the following command before attempting to run a build: \"$ source ${ENVSCRIPT}\". It will configure the environment so you can run bitbake."