-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathconfigure
executable file
·75 lines (60 loc) · 2.03 KB
/
configure
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
#!/usr/bin/env bash
# configure: Makefile generator
# Copyright © 2011-2019 Lukas Martini
# This file is part of Xelix.
#
# Xelix 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 3 of the License, or
# (at your option) any later version.
#
# Xelix 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 Xelix. If not, see <http://www.gnu.org/licenses/>.
function w {
echo "$@" >> Makefile
}
FIND=$(command -v gfind || command -v find)
# Update submodules
[ -x "$(command -v git)" ] && git submodule update --init 1> /dev/null
# Make sure config.h exists on first build
if [ ! -f ".config" ]; then
util/kconfiglib/alldefconfig.py
fi
if [ ! -f "src/lib/config.h" ]; then
util/kconfiglib/genconfig.py --header-path src/lib/config.h
fi
# Get architecture from config
arch=`sed -rn 's/\#define CONFIG_ARCH "([^"]+)"/\1/p' src/lib/config.h`
# Get files
extensions="\.\(c\|asm\|s\|psf\|img\)"
arch_files=`$FIND -L src -type f -iregex "^.*$arch-.*$extensions" | tr '\n' ' '`
files=`$FIND -L src -type f -iregex "^[^\-]*$extensions" | tr '\n' ' '`
files="$arch_files$files"
echo -e "# This file has been generated by ./configure. You usually don't \
want to change it manually.\n" > Makefile
w "ARCH := $arch"
w "include Makefile.static"
w -n "xelix.bin: "
for i in $files
do
w -n " ${i%\.*}"
if [[ ${i##*.} =~ ^(asm|S|psf|img)$ ]]; then
w -n "-${i##*.}"
fi
w -n ".o"
done
w " ext/picotcp/build/lib/libpicotcp.a"
w " \$(LD) $^ -o xelix.bin \$(MAKE_LDFLAGS) \$(LDFLAGS)"
for i in $files
do
deps=`gcc -nostdinc -I src -MM $i -MQ $i 2> /dev/null | tr ' \n ' ' ' | tr ' \\\ ' ' '`
deps=($deps)
unset deps[1]
deps[0]=$(echo "${deps[0]}" | sed 's/\.c/\.o/')
w ${deps[*]}
done