build.sh 8.39 KB
Newer Older
1
set -e
Bas Lijnse's avatar
Bas Lijnse committed
2

3
4
5
6
PACKAGE=$1
OS=$2
ARCH=$3

Bas Lijnse's avatar
Bas Lijnse committed
7
8
9
10
#Where to look for the clean system to build with
export PATH=`pwd`/build/clean/bin:$PATH
export CLEAN_HOME=`pwd`/build/clean

11
12
#### Component build functions ####

13
14
build_codegenerator () { # $1:target 
    mkdir -p build
15
	cp -r src/code-generator-master build/codegenerator
16
17
18
    (cd build/codegenerator
        make -f Makefile.macosx64 cg
    )
19
20
21

	mkdir -p $1/lib/exe
    cp build/codegenerator/cg $1/lib/exe
22
}
23

24
25
build_runtimesystem_c () { # $1:target
    mkdir -p build
26
	cp -r src/run-time-system-master build/runtimesystem
27
	(cd build/runtimesystem/macho64
28
        source make.sh
29
    )
30
31
32
33
34
35
36
37
38

    mkdir -p $1/lib/StdEnv/Clean\ System\ Files

    touch $1/lib/StdEnv/_startupProfile.dcl
    touch $1/lib/StdEnv/_startupTrace.dcl

    cp build/runtimesystem/macho64/_startup.o $1/lib/StdEnv/Clean\ System\ Files/_startup.o
    cp build/runtimesystem/macho64/_startupProfile.o $1/lib/StdEnv/Clean\ System\ Files/_startupProfile.o
    cp build/runtimesystem/macho64/_startupTrace.o $1/lib/StdEnv/Clean\ System\ Files/_startupTrace.o
39
}
40
41
42
build_runtimesystem_clean () { # $1:target
    #Generate the 'clean part' of the runtime system
    mkdir -p $1/lib/StdEnv/Clean\ System\ Files
43
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdEnv\ 64\ Changed\ Files/_system.abc $1/lib/StdEnv/Clean\ System\ Files/_system.abc
44
45
46
47
48
    $CLEAN_HOME/lib/exe/cg $1/lib/StdEnv/Clean\ System\ Files/_system
}

build_clm () { # $1:target
    mkdir -p build
49
	cp -r src/clean-tools-trunk build/tools
50
51
52
	(cd build/tools/clm
        make -f Makefile.macho64 clm
	)
53
54
55
	mkdir -p $1/bin
    cp build/tools/clm/clm $1/bin/clm
}
56

57
build_batchbuild() { #$1:target
58

59
    mkdir -p build/batchbuild/deps/
60
61
    cp -r src/clean-libraries-trunk/Libraries/StdEnv/StdMaybe.* build/batchbuild/deps/
    cp -r src/clean-libraries-trunk/Libraries/StdLib/* build/batchbuild/deps/
62

63
    cp -r src/clean-ide-master build/batchbuild/CleanIDE
64
65
    (cd build/batchbuild/CleanIDE/BatchBuild
        clm -h 256M -nr -nt -I Posix -I ../Pm -I ../MacOSX\
66
			-I ../Util -I ../Interfaces/LinkerInterface -I ../../deps/\
67
			-IL ArgEnv -IL Directory -IL Generics BatchBuild -o batchbuild
68
69
	)
	mkdir -p $1/bin
70
    cp build/batchbuild/CleanIDE/BatchBuild/batchbuild $1/bin/batchbuild
71
72
73

	mkdir -p $1/etc
	mkdir -p $1/Temp
74
    cp $PACKAGE/$OS-$ARCH/txt/IDEEnvs $1/etc/IDEEnvs
75
}
76
77
78
79
build_cpm () { # $1:target
	mkdir -p build/cpm

    #Get cpm source code
80
    cp -r src/clean-ide-master build/cpm/CleanIDE
Bas Lijnse's avatar
Bas Lijnse committed
81
82
83
84

	#Add dependencies
    cp -r src/clean-libraries-trunk/Libraries/StdLib/* build/cpm/CleanIDE/Util/

85
86
87
88
89
    (cd build/cpm/CleanIDE
		batchbuild CpmMacOSX.prj
	)
    cp build/cpm/CleanIDE/cpm/cpm $1/bin/cpm
}
90
91
92

build_compiler() { # $1:target
    mkdir -p build
93
    cp -r src/compiler-itask build/compiler
94
95
    (cd build/compiler
        clm -ABC -nw -ci -I backend -I frontend -I main -I main/Unix -IL ArgEnv backendconvert
96
        source unix/make.macosx64.sh
97
98
99
    )
    mkdir -p $1/lib/exe
    cp build/compiler/cocl $1/lib/exe/cocl
100
}
101
102
103

build_stdenv() { # $1:target
    mkdir -p $1/lib/StdEnv
104
105
106
    cp src/clean-libraries-trunk/Libraries/StdEnv/_library.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/_startup.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/_system.dcl $1/lib/StdEnv/
107
108

    for a in StdArray StdBool StdChar StdCharList StdClass StdDebug StdEnum StdEnv \
109
	  StdFunc StdFunctions StdList StdMisc StdOrdList StdOverloaded StdOverloadedList \
110
	  StdStrictLists StdTuple StdMaybe _SystemArray _SystemEnum _SystemEnumStrict \
111
	  _SystemStrictLists StdGeneric;
112
    do cp src/clean-libraries-trunk/Libraries/StdEnv/$a.[di]cl $1/lib/StdEnv ;
113
114
    done

115
116
117
118
119
120
121
122
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdInt.icl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdEnv\ 64\ Changed\ Files/StdInt.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdFile.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdEnv\ 64\ Changed\ Files/StdFile.icl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdReal.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdEnv\ 64\ Changed\ Files/StdReal.icl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdString.dcl $1/lib/StdEnv/
    cp src/clean-libraries-trunk/Libraries/StdEnv/StdEnv\ 64\ Changed\ Files/StdString.icl $1/lib/StdEnv/
123

124
125
126
    patch $1/lib/StdEnv/StdGeneric.icl < $PACKAGE/$OS-$ARCH/txt/StdGeneric.icl.patch
    patch $1/lib/StdEnv/StdGeneric.dcl < $PACKAGE/$OS-$ARCH/txt/StdGeneric.dcl.patch

127
128
    echo first compile of system modules
    for a in StdChar; # compile twice for inlining
129
    do $CLEAN_HOME/lib/exe/cocl -ou -pm -pt -P $1/lib/StdEnv $a ;
130
131
132
133
    done

    echo second compile of system modules
    for a in StdMisc StdBool StdInt StdChar StdFile StdReal StdString;
134
    do $CLEAN_HOME/lib/exe/cocl -ou -pm -pt -P $1/lib/StdEnv $a ;
135
    done
136

137
138
139
}

build_argenv() { # $1:target
140
    mkdir -p build/libraries/
141
    cp -r src/clean-libraries-trunk/Libraries/ArgEnvUnix build/libraries/ArgEnv
142
143
144
    (cd build/libraries/ArgEnv
        make -e
    )
145
146
147
148
149
150

    mkdir -p "$1/lib/ArgEnv/Clean System Files"
    for f in ArgEnvC.c ArgEnv.dcl printenv.icl ArgEnv.icl Makefile README;
    do  cp build/libraries/ArgEnv/$f $1/lib/ArgEnv/$f
    done
    cp "build/libraries/ArgEnv/Clean System Files/ArgEnvC.o" "$1/lib/ArgEnv/Clean System Files/"
151
}
152
153
154
155

build_dynamics() { #$1:target
	#Copy minimal Dynamics libraries
    mkdir -p "$1/lib/Dynamics/Clean System Files"
156
157
158
159
160
161
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/extension/StdCleanTypes.dcl $1/lib/Dynamics/
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/extension/StdCleanTypes.icl $1/lib/Dynamics/
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/extension/StdDynamic.dcl $1/lib/Dynamics/
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/extension/StdDynamicNoLinker.icl $1/lib/Dynamics/StdDynamic.icl
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/implementation/_SystemDynamic.dcl $1/lib/Dynamics/
    cp src/clean-dynamic-system-trunk/dynamics/StdDynamicEnv/implementation/_SystemDynamic.icl $1/lib/Dynamics/
162
}
163
164
165
build_generics() { #$1:target
	#Copy generics library
    mkdir -p $1/lib/Generics
166
    cp src/clean-libraries-trunk/Libraries/GenLib/*.[id]cl $1/lib/Generics/
167
168
169
}
build_directory() {
	mkdir -p build/Directory
170
171
    cp -r src/clean-libraries-trunk/Libraries/Directory/* build/Directory/
    cp src/clean-tools-trunk/htoclean/Clean.h "build/Directory/Clean System Files Unix/Clean.h"
172
173
174
175
176
177
178
179

    (cd "build/Directory/Clean System Files Unix"
         gcc -c -O cDirectory.c
    )
    mkdir -p "$1/lib/Directory/Clean System Files"
    cp build/Directory/*.[id]cl $1/lib/Directory/
    cp build/Directory/Clean\ System\ Files\ Unix/* $1/lib/Directory/Clean\ System\ Files/
}
180

181
182
183
184
185
build_clean_c_components () { # $1:target
    mkdir -p $1
    build_codegenerator $1
    build_runtimesystem_c $1
    build_clm $1
186
187
}

188
189
190
191
192
193
194
build_clean() { # $1:target
    mkdir -p $1

	#Copy all C components (they are built only once)
	cp -r target/clean-c-components/* $1/

    #Copy docs
195
    cp src/clean-ide-master/CleanLicenseConditions.txt $1/CleanLicenseConditions.txt
196
    cp $PACKAGE/$OS-$ARCH/txt/README $1/README.md
197
198

    mkdir -p $1/doc
199
    cp src/language-report-master/CleanLangRep.2.2.pdf $1/doc/
200
    mkdir -p $1/doc/CleanLangRep/
201
202
203
    cp src/language-report-master/*.htm $1/doc/CleanLangRep/
    cp src/language-report-master/*.css $1/doc/CleanLangRep/
    cp src/language-report-master/*.png $1/doc/CleanLangRep/
204
	mkdir -p $1/doc/CleanLangRep/CleanRep.2.2_files/
205
    cp src/language-report-master/CleanRep.2.2_files/* $1/doc/CleanLangRep/CleanRep.2.2_files/
206
207

    # Build all Clean components
208
    # Standard libraries
209
    build_stdenv $1
210
    # Rts and compiler
211
212
    build_runtimesystem_clean $1
    build_compiler $1
213
214
    # Build tools
	build_batchbuild $1
215
216
217
218
}

#### Main build process ####

Bas Lijnse's avatar
Bas Lijnse committed
219
# Build components written in C (code generator, runtime system and clm)
220
build_clean_c_components target/clean-c-components
Bas Lijnse's avatar
Bas Lijnse committed
221
222

# First pass: build a clean system using the boot compiler
223
build_clean target/clean-intermediate
Bas Lijnse's avatar
Bas Lijnse committed
224

225
# Standard libraries as dependencies for the second pass
226
227
228
229
build_dynamics target/clean-intermediate
build_generics target/clean-intermediate
build_directory target/clean-intermediate
build_argenv target/clean-intermediate
Bas Lijnse's avatar
Bas Lijnse committed
230

Bas Lijnse's avatar
Bas Lijnse committed
231
# Second pass: Build a minimal clean system using the clean system from the previous pass
232
rm -rf build
Bas Lijnse's avatar
Bas Lijnse committed
233
234
mkdir -p build/clean
cp -r target/clean-intermediate/* build/clean
235

236
build_clean target/clean-base
237
build_cpm target/clean-base