summaryrefslogtreecommitdiff
path: root/configure
blob: bc7585f06f5af2bea1de2e67bbadc841f30435d5 (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
#!/bin/sh

for i in `seq 30`; do
    echo "Lots of output to emulate automake... ok"
    echo "Testing for things you'll never use... fail"
    echo "Satisfying the fortran77 lobby... ok"
    echo "Burning CPU time checking for the bloody obvious... ok"
done
echo "Automake emulated successfully"

prefix="/usr/local"

for arg in $*; do
    shift 1
    case $arg in
        "--redo" | "-r")
            if [ -f ./configvar_cache ]; then
                . ./configvar_cache
            fi
            ;;
        "--prefix" | "-p") 
            prefix=shift $*
            ;;
        --prefix=*)
            prefix=`echo $arg | sed 's/^--prefix=//g'`
            ;;
        "--help" | "-h") 
            echo "Usage:"
            echo "      --prefix | -p: The prefix to install to"
            break;
            ;;
        *) echo "Unrecognized argument $arg";;
    esac
done

OS=`uname`
MACH=`uname -m`

rm -f config.mk
rm -f config.h
rm -f mbld/config.myr
rm -f configvar_cache

echo export INST_ROOT=$prefix >> config.mk

echo "pkg config = " >> mbld/config.myr

symprefix='""'
defaultasm='Gnugaself'
sysinit=''
case $OS in
    *Linux*)
        echo 'export SYS=linux' >> config.mk
        echo 'const Sys = "Linux"' >> mbld/config.myr
        echo 'const Linkcmd = ["ld", "-o"]' >> mbld/config.myr
        ;;
    *Darwin*)
	symprefix='"_"'
	defaultasm=Gnugasmacho
	sysinit='setenv("MACOSX_DEPLOYMENT_TARGET", "10.6", 0)'
        echo 'export SYS=osx' >> config.mk
        echo 'const Sys = "OSX"' >> mbld/config.myr
        echo 'const Linkcmd = ["ld", ' \
            '"-pagezero_size", "0x100000000",' \
            '"-macosx_version_min", "10.6",'\
            '"-o"]' >> mbld/config.myr
        ;;
    *FreeBSD*)
        echo 'export SYS=freebsd' >> config.mk
        echo 'const Sys = "FreeBSD"' >> mbld/config.myr
        echo 'const Linkcmd = ["ld", "-o"]' >> mbld/config.myr
        ;;
    *OpenBSD*)
        echo 'export SYS=openbsd' >> config.mk
        echo 'const Sys = "OpenBSD"' >> mbld/config.myr
        echo 'const Linkcmd = ["ld", "-static", "-nopie", "-o"]' >> mbld/config.myr
        ;;
    *)
        echo ''
        echo '********************************'
        echo 'Unknown system '$OS
        echo 'Cannot build'
        echo '********************************'
        rm -f config.h config.mk
        exit 1
        ;;
esac

# config.h
echo '#define Instroot "'$prefix'"' >> config.h
echo '#define Asmcmd {"as", "-g", "-o", NULL}' >> config.h
echo '#define Objsuffix ".o"' >> config.h
echo 'export SYSCLASS=posixy' >> config.mk
echo '#define Symprefix' $symprefix >> config.h
echo '#define Defaultasm' $defaultasm >> config.h
echo '#define Sysinit ' $sysinit >> config.h

# mbld mbld/config.myr
echo "const Instroot = \"$prefix\"" >> mbld/config.myr
echo "const Objsuffix = \".o\"" >> mbld/config.myr
echo "const Arcmd = [\"ar\", \"-rcs\"]" >> mbld/config.myr
echo "const Ascmd = [\"as\", \"-g\"]" >> mbld/config.myr
echo "const Directlib = false" >> mbld/config.myr
echo "const Runtime = \"_myrrt.o\"" >> mbld/config.myr

# paths to install to
echo "const Manpath = \"share/man/man\"" >> mbld/config.myr
echo "const Sharepath = \"share\"" >> mbld/config.myr
echo "const Binpath = \"bin\"" >> mbld/config.myr
echo "const Libpath = \"lib/myr\"" >> mbld/config.myr


case $MACH in
    *x86_64* | *amd64*)
	echo 'export ARCH=x64' >> config.mk
        echo 'const Arch = "x64"' >> mbld/config.myr
        ;;
    *)
        echo ''
        echo '********************************'
        echo 'Unknown arch '$MACH
        echo 'Cannot build'
        echo '********************************'
	;;
esac

echo ';;' >> mbld/config.myr

echo "prefix=$prefix" > configvar_cache
cat << EOF
    Building with:
        prefix=$prefix
EOF