summaryrefslogtreecommitdiffstats
path: root/zmake
blob: 31e0df80271f6382954ab5868b04cd5447c24e5e (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
#!/bin/zsh

# {{{ LICENSE

# Copyright (C) 2012-2013 Denis Roio <jaromil@dyne.org>
#
# This source  code is free  software; you can redistribute  it and/or
# modify it under the terms of  the GNU Public License as published by
# the Free  Software Foundation; either  version 3 of the  License, or
# (at your option) any later version.
#
# This source code 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.
# Please refer to the GNU Public License for more details.
#
# You should have received a copy of the GNU Public License along with
# this source code; if not, write to:
# Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

# }}}

# {{{ GLOBAL VARIABLES

# ZShaolin system build and basic configuration

FORCE=${FORCE:-0}
QUIET=${QUIET:-0}
DEBUG=${DEBUG:-0}

#TARGET=arm-linux-androideabi
# same value should be the bootstrap target

# the location inside android
APKPATH=/data/data/org.dyne.zshaolin



LOGS=build.log

## Architecture compiler flags
#ARCH="-mfloat-abi=softfp -march=armv7-a -mtune=cortex-a8"
# very old devices: ARCH="-march=armv5 -mfloat-abi=softfp"

REPO="http://releases.dyne.org/zshaolin/sources"


autoload colors; colors
# standard output message routines
# it's always useful to wrap them, in case we change behaviour later
notice() { if [[ $QUIET == 0 ]]; then print "$fg_bold[green][*]$fg_no_bold[default] $1" >&2; fi }
error()  { if [[ $QUIET == 0 ]]; then print "$fg[red][!]$fg[default] $1" >&2; fi }
func()   { if [[ $DEBUG == 1 ]]; then print "$fg[blue][D]$fg[default] $1" >&2; fi }
act()    {
    if [[ $QUIET == 0 ]]; then
	if [ "$1" = "-n" ]; then
	    print -n "$fg_bold[white] . $fg_no_bold[default] $2" >&2;
	else
	    print "$fg_bold[white] . $fg_no_bold[default] $1" >&2;
	fi
    fi
}

typeset ZHOME

{ test "$ZHOME" = "" } && {
    error "Set ZHOME environment to Zshaolin path"
    # where are we (configure accordingly)
#    ZHOME=${ZHOME:-/srv/zshaolin}
#   act "using default: $ZHOME"
    return 1
}


enter() {
    if ! [ -r $1/conf.zsh ]; then
	error "build directory misses configuration file: $1/conf.zsh"
	return 1
    fi
    pushd $1
    act "Enter `pwd`"
    shift
    source conf.zsh
#    popd
}

list_sources() {
	touch /tmp/zshaolin.list
	typeset -a modules
	if [ "${#@}" = "1" ]; then modules=(`find ${ZHOME}/build -type f -name Sources`)
	else
	    shift
	    for m in ${=@}; do
		modules+=(${ZHOME}/build/${m}/Sources); done
	fi
	for i in  $modules; do
		cat $i | awk '!/^#/ { print $1 $2 " " $4 }' >> /tmp/zshaolin.list
	done
	swlist=`cat /tmp/zshaolin.list | sort | uniq | sed 's/_arm//;s/eabi//'`
	rm -f /tmp/zshaolin.list
	for i in ${(f)swlist}; do
		name=${i[(ws: :)1]}
		url=${i[(ws: :)2]}
		if [ "$url" = "$name" ]; then
			print "<li>$name</li>"
		else
			print "<li><a href=\"${url}\" target=\"_blank\">$name</a></li>"
		fi
	done
}

typeset -h operation
typeset -h module



case "$1" in

# here module is set with the second argument, after the commands listed here:
    build)
	operation=build
	module=${2:-all}
	enter build/ ${=@}
       	;;

# same here. if no setting specified, it becomes "all".
# internal conf.zsh supports also "list" to list options
    pack)
	operation=pack
	module=${2:-list}
	enter pack/ ${=@}
	;;

    clean)
	operation=clean
	module=${2:-all}
	{ test $module = all } && { rm -rf $PREFIX }
	enter build/ ${=@}
	;;

    # this can be called from commandline
    compile)
	args=($@) && shift args
	operation=compile
	zconfigure ${args}
	;;

    # this initialized the current shell with the zshaolin setup
    test)
	ZHOME=$ZHOME zsh system/etc/zlogin
	;;

    source)
	return ;;
    list)
	list_sources ${=@}
	;;
    help|-h)
	error "No help. We're all on our own, for now."
	;;
    "")
	error "No command specified, see help" ;;
    *)
	error "Command not found: $@" ;;

esac