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

3
4
5
6
LISP_VARIANT=
MOTIF_VARIANT=
TARGET_DIR=

7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
usage() {
    echo "Usage: `basename $0` target-dir [lisp-variant [motif-variant]]"
    echo ""
    echo "Creates a directory structure in TARGET-DIR for use in compiling"
    echo "CMUCL.  If the lisp-variant is not given, uname is used to select"
    echo "a version, if possible.  If motif-variant is not given, one is"
    echo "determined from the lisp-variant."
    echo ""
    # List possible values for lisp-variant and motif-variant
    echo "Possible lisp-variants:"
    ( cd src/lisp/ ; ls -1 Config.* ) | sed 's;^Config[.];;g' | \
	    pr -3at -o 8
    echo "Possible Motif-variants:"
    ( cd src/motif/server/ ; ls -1 Config.* ) | sed 's;^Config[.];;g' | \
	    pr -3at -o 8
    exit 1
}

25
26
27
28
if [ $# = 1 ]; then
    # Only target directory given.  Try to deduce the lisp-variant
    TARGET_DIR="$1"
    case `uname -s` in
29
    SunOS) LISP_VARIANT=sparc_gcc ;;
30
    Linux) LISP_VARIANT=x86_linux ;;
cshapiro's avatar
cshapiro committed
31
32
33
34
35
    Darwin) case `uname -m` in
            ppc) LISP_VARIANT=ppc_darwin ;;
	    i386) LISP_VARIANT=x86_darwin ;;
	    esac
	    ;;
36
    FreeBSD|freebsd) LISP_VARIANT=x86_freebsd ;;
37
38
39
40
41
42
43
44
45
46
47
48
49
50
    # Please fill in some other common systems
    *) echo "Sorry, please specify the desired Lisp variant." 
       exit 1 ;;
    esac
elif [ $# = 2 ]; then
    # Target directory and lisp-variant given 
    TARGET_DIR="$1"
    LISP_VARIANT="$2"
elif [ $# = 3 ]; then
    # Target directory, lisp-variant, and motif variant given 
    TARGET_DIR="$1"
    LISP_VARIANT="$2"
    MOTIF_VARIANT="$3"
else
51
    usage
52
53
fi

54
[ -d $1 ] && echo "Error: Directory $1 exists already!" && exit 2
55

56
TARGET="`echo $TARGET_DIR | sed 's:/*$::'`"
57
58

# Make sure the given variants exist
59
60
if [ ! -f src/lisp/Config.$LISP_VARIANT ]; then
	echo "No such lisp-variant could be found: Config.$LISP_VARIANT"
61
62
63
64
	exit 1
fi

# From the given variant, try to derive a motif variant
65
66
67
68
if [ "$MOTIF_VARIANT" = "" ]; then
    case $LISP_VARIANT in
      alpha_linux) MOTIF_VARIANT=alpha_linux ;;
      alpha_osf1) MOTIF_VARIANT=alpha_osf1 ;;
69
      x86_freebsd|FreeBSD*|freebsd*) MOTIF_VARIANT=FreeBSD ;;
70
71
      NetBSD*) MOTIF_VARIANT=NetBSD ;;
      OpenBSD*) MOTIF_VARIANT=OpenBSD ;;
72
      *_darwin) MOTIF_VARIANT=Darwin ;;
rtoy's avatar
rtoy committed
73
74
      sun4_solaris_gcc|sparc_gcc) MOTIF_VARIANT=solaris ;;
      sun4_solaris_sunc|sparc_sunc) MOTIF_VARIANT=solaris_sunc ;;
75
76
77
78
      sun4c*) MOTIF_VARIANT=sun4c_411 ;;
      hp700*) MOTIF_VARIANT=hpux_cc ;;
      pmax_mach) MOTIF_VARIANT=pmax_mach ;;
      sgi*) MOTIF_VARIANT=irix ;;
79
      x86_linux|linux*) MOTIF_VARIANT=x86 ;;
80
    esac
81
82
83
elif [ ! -f src/motif/server/Config.$MOTIF_VARIANT ]; then
    echo "No such motif-variant could be found: Config.$MOTIF_VARIANT"
    exit 1
84
85
fi

86
87
88
89
# Tell user what's we've configured
echo "Lisp = $LISP_VARIANT"
echo "Motif = $MOTIF_VARIANT"

90
91
92
93
94
# Create a directory tree that mirrors the source directory tree
find src -name 'CVS' -prune -o -type d -print \
	| sed "s:^src:$TARGET:g" | xargs mkdir

# Link Makefile and Config files
95
 
96
97
98
99
(cd $TARGET/lisp
 ln -s ../../src/lisp/GNUmakefile ../../src/lisp/Config.$LISP_VARIANT ../../src/lisp/Config.*_common .
 ln -s Config.$LISP_VARIANT Config
)
100
101
102
103
104
105
106

# Create empty initial map file
echo 'Map file for lisp version 0' > $TARGET/lisp/lisp.nm

# Create dummy internals.h so we get warned to recompile
echo '#error You need to run genesis (via build-world.sh) before compiling the startup code!' > $TARGET/lisp/internals.h

107
SETENV=src/tools/setenv-scripts
108

109
110
# Create sample setenv.lisp file
cat $SETENV/base-features.lisp > $TARGET/setenv.lisp
111
112

# Put in some platform specific items
113
case $LISP_VARIANT in
114
  *linux*)
rtoy's avatar
rtoy committed
115
      gcname=":gencgc"
116
      sed "s;@@gcname@@;$gcname;" $SETENV/linux-features.lisp >> $TARGET/setenv.lisp
117
118
      ;;
  *OpenBSD*)
119
      case $LISP_VARIANT in
120
121
122
        *_gencgc*) gcname=":gencgc" ;;
	*) gcname=":cgc" ;;
      esac
123
      sed "s;@@gcname@@;$gcname;" $SETENV/openbsd-features.lisp >> $TARGET/setenv.lisp
124
      ;;
125
  *FreeBSD*|*freebsd*)
rtoy's avatar
rtoy committed
126
127
      gcname=":gencgc"
      sed "s;@@gcname@@;$gcname;" $SETENV/freebsd-features.lisp >> $TARGET/setenv.lisp
128
      ;;
129
  *solaris*)
130
      cat $SETENV/solaris-features.lisp >> $TARGET/setenv.lisp
131
132
      ;;
  *)
133
      sed "s;@@LISP@@;$LISP_VARIANT;" $SETENV/unknown.lisp >> $TARGET/setenv.lisp
134
135
136
137
138
      ;;
esac


# Do Motif setup
139
if [ "$MOTIF_VARIANT" != "" ]
140
then
141
142
    ( cd $TARGET/motif/server ; ln -s ../../../src/motif/server/GNUmakefile ./Makefile )
    ( cd $TARGET/motif/server ; ln -s ../../../src/motif/server/Config.$MOTIF_VARIANT ./Config )
143
fi