create-target.sh 3.9 KB
Newer Older
1
2
#!/bin/sh

3
4
diag() { echo "($prgm_name) $@" >&2; }
quit() { diag "not OK: $@"; exit 1; }
5
usage() {
6
    echo "Usage: $prgm_name TARGET-DIR [LISP-VARIANT [MOTIF-VARIANT]]"
7
    echo ""
8
9
    echo "Creates a directory structure in TARGET-DIR for use in building CMUCL."
    echo "A simple logic is used to find the optional -VARIANT parameters."
10
11
    echo ""
    # List possible values for lisp-variant and motif-variant
12
    echo "Possible LISP-VARIANTs:"
13
    ( cd src/lisp/ && ls -1 Config.* ) | sed 's;^Config[.];;g' | grep -v common | pr -3at -o 8 || quit "Can't list lisp-variants"
14
    echo "Possible MOTIF-VARIANTs:"
15
16
    ( cd src/motif/server/ && ls -1 Config.* ) | sed 's;^Config[.];;g' | pr -3at -o 8 || quit "Can't list lisp-variants"
    exit 2
17
18
}

19
20
##--
prgm_name=`basename $0` bld_dir=$1 lisp_variant=$2 motif_variant=$3
21
22
exec 2>&1

23
24
[ -n "$bld_dir" ] || usage

25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
uname_s=`uname -s`
uname_m=`uname -m 2>/dev/null`
[ -n "$lisp_variant" ] || {
    case $uname_s in
	Linux) lisp_variant=x86_linux ;;
	FreeBSD) lisp_variant=x86_freebsd ;;
	SunOS)
	    case $uname_m in
		i86pc) lisp_variant=x86_solaris_sunc ;;
		sun*) lisp_variant=sparc_gcc ;;
	    esac 
	    ;;
	Darwin)
	    case $uname_m in
		ppc) lisp_variant=ppc_darwin ;;
Raymond Toy's avatar
Raymond Toy committed
40
		i386|x86_64) lisp_variant=x86_darwin ;;
cshapiro's avatar
cshapiro committed
41
42
	    esac
	    ;;
Raymond Toy's avatar
Raymond Toy committed
43
        NetBSD) lisp_variant=x86_netbsd ;;
44
	*) quit "Unsupported OS: $uname_s";;
45
    esac
46
}
47
[ -n "$lisp_variant" ] || quit "Can't determine lisp_variant"
48
49
50
51
52
53
54
55
[ -f src/lisp/Config.$lisp_variant ] || quit "Config.$lisp_variant not found"

case $lisp_variant in
    *linux*) lvshort=linux;;
    *freebsd*) lvshort=freebsd;;
    *solaris*) lvshort=solaris;;
    *) lvshort=unknown;;
esac
56

57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# Beats me why we care about Motif today but let it be, other than on FreeBSD,
# where the config file is wrong anyway. (agoncharov, 2011-10-07)
case $uname_s in
    FreeBSD) :;; # Free
    *) # Enjoy
	[ -n "$motif_variant" ] || {
	    case $lisp_variant in
		NetBSD*) motif_variant=NetBSD ;;
		OpenBSD*) motif_variant=OpenBSD ;;
		*_darwin) motif_variant=Darwin ;;
		sun4_solaris_gcc|sparc_gcc) motif_variant=solaris ;;
		sun4_solaris_sunc|sparc_sunc|x86_solaris_sunc) motif_variant=solaris_sunc ;;
		sun4c*) motif_variant=sun4c_411 ;;
		hp700*) motif_variant=hpux_cc ;;
		pmax_mach) motif_variant=pmax_mach ;;
		sgi*) motif_variant=irix ;;
		x86_linux|linux*) motif_variant=x86 ;;
	    esac
	}
	[ -f src/motif/server/Config.$motif_variant ] || quit "No such motif-variant could be found: Config.$motif_variant"
	;;
esac
79

80
# Tell user what's we've configured
81
diag "Settings: bld_dir=$bld_dir lisp_variant=$lisp_variant ${motif_variant:+motif_variant=$motif_variant}"
82

83
# Create a directory tree that mirrors the source directory tree
84
[ -d "$bld_dir" -o -f "$bld_dir" ] && quit "Exists: `ls -ld $bld_dir`"
85
86
87
88
89
90
mkdir -p "$bld_dir"
(cd src && find . -name .git -prune -o -type d -print) | (cd $bld_dir && xargs mkdir -p) ||
quit "Can't create target directories"

top_dir=$PWD
cd $bld_dir/lisp || quit "Can't cd $bld_dir/lisp"
91
92

# Link Makefile and Config files
93
94
95
ln -s ../../src/lisp/GNUmakefile ../../src/lisp/Config.$lisp_variant ../../src/lisp/Config.*_common .
ln -s Config.$lisp_variant Config
[ -n "$motif_variant" ] && (
96
    cd ../motif/server || quit "Can't cd motif/server" # We will still continue in the outer shell
97
98
    ln -s ../../../src/motif/server/GNUmakefile ./Makefile
    ln -s ../../../src/motif/server/Config.$motif_variant ./Config
99
)
100

101
102
103
104
105
106
107
108
109
110
echo 'Map file for lisp version 0' > lisp.nm # Empty initial map file
echo '#error You need to run genesis (via build-world.sh) before compiling the startup code!' > internals.h
(
    setenv_dir=$top_dir/src/tools/setenv-scripts
    cat $setenv_dir/base-features.lisp 
    case $lvshort in
	linux|freebsd) gcname=":gencgc"; sed "s;@@gcname@@;$gcname;" $setenv_dir/$lvshort-features.lisp >> setenv.lisp;;
	solaris) cat $setenv_dir/solaris-features.lisp;;
	*) sed "s;@@LISP@@;$lisp_variant;" $setenv_dir/unknown.lisp;;
    esac
111
) > ../setenv.lisp || quit "Can't create setenv.lisp"