create-target.sh 4.08 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
29
30
if [ $# = 1 ]; then
    # Only target directory given.  Try to deduce the lisp-variant
    TARGET_DIR="$1"
    case `uname -s` in
    SunOS) LISP_VARIANT=sun4_solaris_gcc ;;
    Linux) LISP_VARIANT=linux_gencgc ;;
31
    Darwin) LISP_VARIANT=ppc_darwin ;;
32
33
34
35
36
37
38
39
40
41
42
43
44
45
    # 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
46
    usage
47
48
fi

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

51
TARGET="`echo $TARGET_DIR | sed 's:/*$::'`"
52
53

# Make sure the given variants exist
54
55
if [ ! -f src/lisp/Config.$LISP_VARIANT ]; then
	echo "No such lisp-variant could be found: Config.$LISP_VARIANT"
56
57
58
59
	exit 1
fi

# From the given variant, try to derive a motif variant
60
61
62
63
64
65
66
if [ "$MOTIF_VARIANT" = "" ]; then
    case $LISP_VARIANT in
      alpha_linux) MOTIF_VARIANT=alpha_linux ;;
      alpha_osf1) MOTIF_VARIANT=alpha_osf1 ;;
      FreeBSD*) MOTIF_VARIANT=FreeBSD ;;
      NetBSD*) MOTIF_VARIANT=NetBSD ;;
      OpenBSD*) MOTIF_VARIANT=OpenBSD ;;
67
      *_darwin) MOTIF_VARIANT=Darwin ;;
68
69
70
71
72
73
      sun4_solaris*) MOTIF_VARIANT=solaris ;;
      sun4c*) MOTIF_VARIANT=sun4c_411 ;;
      hp700*) MOTIF_VARIANT=hpux_cc ;;
      pmax_mach) MOTIF_VARIANT=pmax_mach ;;
      sgi*) MOTIF_VARIANT=irix ;;
      linux*) MOTIF_VARIANT=x86 ;;
74
    esac
75
76
77
elif [ ! -f src/motif/server/Config.$MOTIF_VARIANT ]; then
    echo "No such motif-variant could be found: Config.$MOTIF_VARIANT"
    exit 1
78
79
fi

80
81
82
83
# Tell user what's we've configured
echo "Lisp = $LISP_VARIANT"
echo "Motif = $MOTIF_VARIANT"

84
85
86
87
88
89
# 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
( cd $TARGET/lisp ; ln -s ../../src/lisp/GNUmakefile ./Makefile )
90
( cd $TARGET/lisp ; ln -s ../../src/lisp/Config.$LISP_VARIANT ./Config )
91
92
93
94
95
96
97

# 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

98
SETENV=src/tools/setenv-scripts
99

100
101
# Create sample setenv.lisp file
cat $SETENV/base-features.lisp > $TARGET/setenv.lisp
102
103

# Put in some platform specific items
104
case $LISP_VARIANT in
105
  *linux*)
106
      case $$LISP_VARIANT in
107
108
109
        *_gencgc*) gcname=":gencgc" ;;
	*) gcname=":cgc" ;;
      esac
110
      sed "s;@@gcname@@;$gcname;" $SETENV/linux-features.lisp >> $TARGET/setenv.lisp
111
112
      ;;
  *OpenBSD*)
113
      case $LISP_VARIANT in
114
115
116
        *_gencgc*) gcname=":gencgc" ;;
	*) gcname=":cgc" ;;
      esac
117
      sed "s;@@gcname@@;$gcname;" $SETENV/openbsd-features.lisp >> $TARGET/setenv.lisp
118
119
      ;;
  *solaris*)
120
      cat $SETENV/solaris-features.lisp >> $TARGET/setenv.lisp
121
122
      ;;
  *)
123
      sed "s;@@LISP@@;$LISP_VARIANT;" $SETENV/unknown.lisp >> $TARGET/setenv.lisp
124
125
126
127
128
      ;;
esac


# Do Motif setup
129
if [ "$MOTIF_VARIANT" != "" ]
130
then
131
132
    ( cd $TARGET/motif/server ; ln -s ../../../src/motif/server/GNUmakefile ./Makefile )
    ( cd $TARGET/motif/server ; ln -s ../../../src/motif/server/Config.$MOTIF_VARIANT ./Config )
133
fi