aboutsummaryrefslogtreecommitdiffstats
path: root/generate/release/build.sh
blob: 9c46e66b4caf0cbb2e3770735b7a19687b08d0c4 (plain) (blame)
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
#!/bin/bash

#******************************************************************************
#
# ACPICA package generation script for Cygwin/Windows execution
#
# Requires cygwin be installed - http://www.cygwin.com
# and its /bin be *first* in your path.
#
# Windows packages require pkzip25 (free, and is available from numerous
# sources - search for "pkzip25" or "pkzip25.exe")
#
# Execute this script from the acpica/generate/release directory.
#
# Constructed packages are placed in the acpica/generate/release/current
# directory.
#
# Line Terminators: Windows source packages leave the CR/LF terminator.
# Unix packages convert the CR/LF terminators to LF only.
#
# Usage:
#
#   build <package_type> <target_type>
#
#   where:
#       <package_type> is one of:
#           source  - Build an ACPICA source package (core and all tools)
#           test    - Build an ACPICA test suite package
#           binary  - Build an ACPICA binary tools package
#
#       <target_type> is one of:
#           win     - Generate Windows package (Intel license, CRLF line terminators)
#           unix    - Generate Unix package (Intel license, LF line terminators)
#           unix2   - Generate Unix package (dual license, LF line terminators)
#
#******************************************************************************

# Configuration

ZIP_UTILITY="c:/windows/pkzip25.exe"
ACPISRC="libraries/acpisrc.exe"
DOS2UNIX="dos2unix"
UNIX2DOS="unix2dos"

# Filenames and paths

TARGET_DIR="generate/release/current"
TEMP_DIR=acpitemp
TEST_PREFIX=acpitests
SOURCE_PREFIX=acpica
BINARY_PREFIX=iasl
PACKAGE_SUFFIX=`date +%Y%m%d`

NPARAM=$#


#******************************************************************************
#
# Miscellaneous utility functions
#
#******************************************************************************

usage()
{
	echo "$1"
	echo
	echo "Low-level build script for ACPICA release packages"
	echo "Usage:"
	echo "    $0 source <win | unix | unix2>"
	echo "    $0 test   <win | unix>"
	echo "    $0 binary <win>"
}

banner()
{
	echo
	echo "$1"
	echo
}

check_zip_utility_exists()
{
	#
	# Need pkzip (or similar) to build the windows packages
	#
	if [ ! -e "$ZIP_UTILITY" ]; then
		echo "ZIP_UTILITY ($ZIP_UTILITY) does not exist!"
		exit 1
	fi
}

convert_to_unix_line_terminators()
{
	#
	# Convert all CR/LF pairs to Unix format (LF only)
	#
	cd $TEMP_DIR
	echo Starting CR/LF to LF Conversion
	find . -name "*" | xargs $DOS2UNIX
	echo Completed CR/LF to LF Conversion
	cd ..
}

convert_to_dos_line_terminators()
{
	#
	# Convert all lone LF terminators to CR/LF
	# Note: Checks shell scripts only (*.sh)
	#
	cd $TEMP_DIR
	echo Starting LF to CR/LF Conversion
	find . -name "*.sh" | xargs $UNIX2DOS
	echo Completed LF to CR/LF Conversion
	cd ..
}

insert_dual_license_headers()
{
	#
	# Need acpisrc utility to insert the headers
	#
	if [ ! -e "$ACPISRC" ]; then
		echo "acpisrc ($ACPISRC) does not exist!"
		exit 1
	fi

	#
	# Insert the dual license into *.c and *.h files
	#
	echo "Inserting dual-license into all source files"
	$ACPISRC -h -y $TEMP_DIR
}

build_unix_package()
{
	convert_to_unix_line_terminators

	#
	# Build release package
	#
	rm -r -f $PACKAGE_FILENAME
	mv $TEMP_DIR $PACKAGE_FILENAME
	tar czf $PACKAGE_FILENAME.tar.gz $PACKAGE_FILENAME

	#
	# Move the completed package
	#
	mv $PACKAGE_FILENAME.tar.gz $TARGET_DIR
	mv $PACKAGE_FILENAME $TEMP_DIR
}

build_windows_package()
{
	convert_to_dos_line_terminators

	#
	# Build release package
	#
	cd $TEMP_DIR
	rm -r -f ../$TARGET_DIR/$PACKAGE_FILENAME
	$ZIP_UTILITY -add -max -dir -sort=name ../$TARGET_DIR/$PACKAGE_FILENAME
	cd ..
}


#******************************************************************************
#
# generate_source_package
#
# Generates the ACPICA source code packages (core and all tools)
#
# Arguments:
#   %1  - Target type (win or unix or unix2)
#
#******************************************************************************

generate_source_package ()
{
	#
	# Parameter evaluation
	#
	if [ $1 == win ]; then
		PACKAGE_NAME=Windows
		PACKAGE_TYPE=Win
		LICENSE=Intel
		check_zip_utility_exists

	elif [ $1 == unix ]; then
		PACKAGE_NAME="Unix (Intel License)"
		PACKAGE_TYPE=Unix
		LICENSE=Intel

	elif [ $1 == unix2 ]; then
		PACKAGE_NAME="Unix (Dual License)"
		PACKAGE_TYPE=Unix
		LICENSE=Dual

	else
		usage "Invalid argument ($1)"
		exit 1
	fi

	PACKAGE_FILENAME=$SOURCE_PREFIX-$1-$PACKAGE_SUFFIX
	banner "ACPICA - Generating $PACKAGE_NAME source code package ($PACKAGE_FILENAME)"

	#
	# Make directories common to all source packages
	#
	mkdir $TEMP_DIR
	mkdir $TEMP_DIR/libraries
	mkdir $TEMP_DIR/generate
	mkdir $TEMP_DIR/generate/lint
	mkdir $TEMP_DIR/generate/release
	mkdir $TEMP_DIR/generate/unix
	mkdir $TEMP_DIR/generate/unix/acpibin
	mkdir $TEMP_DIR/generate/unix/acpiexec
	mkdir $TEMP_DIR/generate/unix/acpihelp
	mkdir $TEMP_DIR/generate/unix/acpinames
	mkdir $TEMP_DIR/generate/unix/acpisrc
	mkdir $TEMP_DIR/generate/unix/acpixtract
	mkdir $TEMP_DIR/generate/unix/iasl
	mkdir $TEMP_DIR/tests
	mkdir $TEMP_DIR/tests/misc
	mkdir $TEMP_DIR/tests/templates
	mkdir -p $TEMP_DIR/source/os_specific/service_layers

	#
	# Copy ACPICA subsystem source code
	#
	cp -r documents/changes.txt             $TEMP_DIR/changes.txt
	cp -r source/common                     $TEMP_DIR/source/common
	cp -r source/components                 $TEMP_DIR/source/
	cp -r source/include                    $TEMP_DIR/source/include
	cp -r generate/release/*.sh             $TEMP_DIR/generate/release

	#
	# Copy iASL compiler and tools source
	#
	cp -r source/compiler                   $TEMP_DIR/source/compiler
	cp -r source/tools                      $TEMP_DIR/source/tools

	#
	# Copy iASL/ACPICA miscellaneous tests (not full test suites)
	#
	cp -r tests/misc/*.asl                  $TEMP_DIR/tests/misc
	cp -r tests/templates/Makefile          $TEMP_DIR/tests/templates
	cp -r tests/templates/templates.sh      $TEMP_DIR/tests/templates

	#
	# Copy all OS-specific interfaces
	#
	cp source/os_specific/service_layers/*.c $TEMP_DIR/source/os_specific/service_layers

	#
	# Copy generic UNIX makefiles
	#
	cp generate/unix/readme.txt             $TEMP_DIR/generate/unix/readme.txt
	cp generate/unix/Makefile*              $TEMP_DIR/generate/unix
	cp generate/unix/acpibin/Makefile       $TEMP_DIR/generate/unix/acpibin
	cp generate/unix/acpiexec/Makefile      $TEMP_DIR/generate/unix/acpiexec
	cp generate/unix/acpihelp/Makefile      $TEMP_DIR/generate/unix/acpihelp
	cp generate/unix/acpinames/Makefile     $TEMP_DIR/generate/unix/acpinames
	cp generate/unix/acpisrc/Makefile       $TEMP_DIR/generate/unix/acpisrc
	cp generate/unix/acpixtract/Makefile    $TEMP_DIR/generate/unix/acpixtract
	cp generate/unix/iasl/Makefile          $TEMP_DIR/generate/unix/iasl

	#
	# Copy Lint directory
	#
	cp -r generate/lint $TEMP_DIR/generate
	rm -f $TEMP_DIR/generate/lint/co*
	rm -f $TEMP_DIR/generate/lint/env*
	rm -f $TEMP_DIR/generate/lint/lib*
	rm -f $TEMP_DIR/generate/lint/LintOut.txt

	if [ $PACKAGE_TYPE == Unix ]; then
		#
		# Unix/Linux-specific activities
		#
		
		# Copy Linux/UNIX utility generation makefiles

		cp generate/linux/Makefile.acpibin      $TEMP_DIR/source/tools/acpibin/Makefile
		cp generate/linux/Makefile.acpiexec     $TEMP_DIR/source/tools/acpiexec/Makefile
		cp generate/linux/Makefile.acpihelp     $TEMP_DIR/source/tools/acpihelp/Makefile
		cp generate/linux/Makefile.acpinames    $TEMP_DIR/source/tools/acpinames/Makefile
		cp generate/linux/Makefile.acpisrc      $TEMP_DIR/source/tools/acpisrc/Makefile
		cp generate/linux/Makefile.acpixtract   $TEMP_DIR/source/tools/acpixtract/Makefile
		cp generate/linux/Makefile.iasl         $TEMP_DIR/source/compiler/Makefile
		cp generate/linux/README.acpica-unix    $TEMP_DIR/README

		#
		# For Unix2 case, insert the dual license header into all source files
		#
		if [ $LICENSE == Dual ]; then
			insert_dual_license_headers
		fi

		build_unix_package

	else
		#
		# Windows-specific activities
		#

		# Copy project files for MS Visual Studio 2008 (VC++ 9.0)

		mkdir $TEMP_DIR/generate/msvc9
		cp -r generate/msvc9/*.sln $TEMP_DIR/generate/msvc9/
		cp -r generate/msvc9/*.vcproj $TEMP_DIR/generate/msvc9/

		build_windows_package
	fi

	banner "ACPICA - Completed $PACKAGE_NAME source code package ($PACKAGE_FILENAME)"
}


#******************************************************************************
#
# generate_test_package
#
# Generates the ACPICA test suite packages
#
# Arguments:
#   %1  - Target type (win or unix)
#
#******************************************************************************

generate_test_package()
{
	#
	# Parameter evaluation
	#
	if [ $1 == win ]; then
		PACKAGE_NAME=Windows
		PACKAGE_TYPE=Win
		check_zip_utility_exists

	elif [ $1 == unix ]; then
		PACKAGE_NAME="Unix"
		PACKAGE_TYPE=Unix

	else
		usage "Invalid argument ($1)"
		exit 1
	fi

	PACKAGE_FILENAME=$TEST_PREFIX-$1-$PACKAGE_SUFFIX
	banner "ACPICA - Generating $PACKAGE_NAME test suite package ($PACKAGE_FILENAME)"

	#
	# Copy the ASL Test source
	#
	mkdir $TEMP_DIR
	cp -r tests $TEMP_DIR/tests

	#
	# Delete extraneous files
	#
	cd $TEMP_DIR
	find . -name "tmp" | xargs rm -r -f
	find . -name "aml" | xargs rm -r -f
	find . -name "CVS" | xargs rm -r -f
	cd ..

	if [ $PACKAGE_TYPE == Unix ]; then
		#
		# Unix/Linux-specific activities
		#
		build_unix_package

	else
		#
		# Windows-specific activities
		#
		build_windows_package
	fi

	banner "ACPICA - Completed $PACKAGE_NAME test suite package ($PACKAGE_FILENAME)"
}


#******************************************************************************
#
# generate_binary_package
#
# Generates the ACPICA binary package (Currently Windows only)
#
# Arguments:
#   %1  - Target type (win)
#
#******************************************************************************

generate_binary_package()
{
	#
	# Parameter evaluation
	#
	if [ $1 == win ]; then
		PACKAGE_NAME=Windows
		PACKAGE_TYPE=Win
		check_zip_utility_exists

	else
		usage "Invalid argument ($1)"
		exit 1
	fi

	PACKAGE_FILENAME=$BINARY_PREFIX-$1-$PACKAGE_SUFFIX
	banner "ACPICA - Generating $PACKAGE_NAME binary tools package ($PACKAGE_FILENAME)"

	#
	# Copy executables and documentation
	#
	mkdir $TEMP_DIR
	cp -r documents/changes.txt     $TEMP_DIR/changes.txt
	cp documents/aslcompiler.pdf    $TEMP_DIR
	cp libraries/acpibin.exe        $TEMP_DIR
	cp libraries/acpiexec.exe       $TEMP_DIR
	cp libraries/acpihelp.exe       $TEMP_DIR
	cp libraries/acpinames.exe      $TEMP_DIR
	cp libraries/acpisrc.exe        $TEMP_DIR
	cp libraries/acpixtract.exe     $TEMP_DIR
	cp libraries/iasl.exe           $TEMP_DIR
	cp tests/misc/badcode.asl       $TEMP_DIR

	build_windows_package
	banner "ACPICA - Completed $PACKAGE_NAME binary tools package ($PACKAGE_FILENAME)"
}


#******************************************************************************
#
# main
#
# Arguments:
#       $1 (package_type) is one of:
#           source  - Build an ACPICA source package (core and all tools)
#           test    - Build an ACPICA test suite package
#           binary  - Build an ACPICA binary tools package
#
#       $2 (target_type) is one of:
#           win     - Generate Windows package (Intel license, CRLF line terminators)
#           unix    - Generate Unix package (Intel license, LF line terminators)
#           unix2   - Generate Unix package (dual license, LF line terminators)
#
#******************************************************************************

set -e		# Abort on any error

if [ $NPARAM -ne 2 ]; then
	usage "Wrong argument count ($NPARAM)"
	exit 1
fi

#
# cd from acpica/generate/release to acpica
#
cd ../..

#
# Ensure that the temporary directory is created fresh
#
rm -rf $TEMP_DIR
		
#
# Parameter evaluation
#
if [ $1 == source ]; then
	generate_source_package $2

elif [ $1 == test ]; then
	generate_test_package $2

elif [ $1 == binary ]; then
	generate_binary_package $2

else
	usage "Invalid argument ($1)"
	exit 1
fi

#
# Remove temporary directory
#
rm -rf $TEMP_DIR