1#!/bin/bash 2 3#****************************************************************************** 4# 5# ACPICA package generation script for Cygwin/Windows execution 6# 7# Requires cygwin be installed - http://www.cygwin.com 8# and its /bin be *first* in your path. 9# 10# Windows packages require pkzip25 (free, and is available from numerous 11# sources - search for "pkzip25" or "pkzip25.exe") 12# 13# Execute this script from the acpica/generate/release directory. 14# 15# Constructed packages are placed in the acpica/generate/release/current 16# directory. 17# 18# Line Terminators: Windows source packages leave the CR/LF terminator. 19# Unix packages convert the CR/LF terminators to LF only. 20# 21# Usage: 22# 23# build <package_type> <target_type> 24# 25# where: 26# <package_type> is one of: 27# source - Build an ACPICA source package (core and all tools) 28# test - Build an ACPICA test suite package 29# binary - Build an ACPICA binary tools package 30# 31# <target_type> is one of: 32# win - Generate Windows package (Intel license, CRLF line terminators) 33# unix - Generate Unix package (Intel license, LF line terminators) 34# unix2 - Generate Unix package (dual license, LF line terminators) 35# 36#****************************************************************************** 37 38# Configuration 39 40ZIP_UTILITY="/cygdrive/c/windows/pkzip25.exe" 41ACPISRC="libraries/acpisrc.exe" 42DOS2UNIX="dos2unix" 43UNIX2DOS="unix2dos" 44 45# Filenames and paths 46 47TARGET_DIR="generate/release/current" 48TEMP_DIR=acpitemp 49TEST_PREFIX=acpitests 50SOURCE_PREFIX=acpica 51BINARY_PREFIX=iasl 52PACKAGE_SUFFIX=`date +%Y%m%d` 53 54NPARAM=$# 55 56 57#****************************************************************************** 58# 59# Miscellaneous utility functions 60# 61#****************************************************************************** 62 63usage() 64{ 65 echo "$1" 66 echo 67 echo "Low-level build script for ACPICA release packages" 68 echo "Usage:" 69 echo " $0 source <win | unix | unix2>" 70 echo " $0 test <win | unix>" 71 echo " $0 binary <win>" 72} 73 74banner() 75{ 76 echo 77 echo "$1" 78 echo 79} 80 81check_zip_utility_exists() 82{ 83 # 84 # Need pkzip (or similar) to build the windows packages 85 # 86 if [ ! -e "$ZIP_UTILITY" ]; then 87 echo "ZIP_UTILITY ($ZIP_UTILITY) does not exist!" 88 exit 1 89 fi 90} 91 92convert_to_unix_line_terminators() 93{ 94 # 95 # Convert all CR/LF pairs to Unix format (LF only) 96 # 97 cd $TEMP_DIR 98 echo "Starting CR/LF to LF (UNIX) full source conversion" 99 find . -name "*" | xargs $DOS2UNIX -q 100 echo "Completed CR/LF to LF (UNIX) full source conversion" 101 cd .. 102} 103 104convert_to_dos_line_terminators() 105{ 106 # 107 # Convert all lone LF terminators to CR/LF 108 # Note: Checks shell scripts only (*.sh) 109 # 110 cd $TEMP_DIR 111 echo "Starting LF to CR/LF (DOS) script conversion" 112 find . -name "*.sh" | xargs $UNIX2DOS -q 113 echo "Completed LF to CR/LF (DOS) script conversion" 114 cd .. 115} 116 117insert_dual_license_headers() 118{ 119 # 120 # Need acpisrc utility to insert the headers 121 # 122 if [ ! -e "$ACPISRC" ]; then 123 echo "acpisrc ($ACPISRC) does not exist!" 124 exit 1 125 fi 126 127 # 128 # Insert the dual license into *.c and *.h files 129 # 130 echo "Inserting dual-license into all source files" 131 $ACPISRC -h -y $TEMP_DIR 132} 133 134build_unix_package() 135{ 136 convert_to_unix_line_terminators 137 138 # 139 # Build release package 140 # 141 rm -r -f $PACKAGE_FILENAME 142 mv $TEMP_DIR $PACKAGE_FILENAME 143 tar czf $PACKAGE_FILENAME.tar.gz $PACKAGE_FILENAME 144 145 # 146 # Move the completed package 147 # 148 mv $PACKAGE_FILENAME.tar.gz $TARGET_DIR 149 mv $PACKAGE_FILENAME $TEMP_DIR 150} 151 152build_windows_package() 153{ 154 convert_to_dos_line_terminators 155 156 # 157 # Build release package 158 # 159 cd $TEMP_DIR 160 rm -r -f ../$TARGET_DIR/$PACKAGE_FILENAME 161 $ZIP_UTILITY -silent -add -max -dir -sort=name ../$TARGET_DIR/$PACKAGE_FILENAME 162 cd .. 163} 164 165 166#****************************************************************************** 167# 168# generate_source_package 169# 170# Generates the ACPICA source code packages (core and all tools) 171# 172# Arguments: 173# %1 - Target type (win or unix or unix2) 174# 175#****************************************************************************** 176 177generate_source_package () 178{ 179 # 180 # Parameter evaluation 181 # 182 if [ $1 == win ]; then 183 PACKAGE_NAME=Windows 184 PACKAGE_TYPE=Win 185 LICENSE=Intel 186 check_zip_utility_exists 187 188 elif [ $1 == unix ]; then 189 PACKAGE_NAME="Unix (Intel License)" 190 PACKAGE_TYPE=Unix 191 LICENSE=Intel 192 193 elif [ $1 == unix2 ]; then 194 PACKAGE_NAME="Unix (Dual License)" 195 PACKAGE_TYPE=Unix 196 LICENSE=Dual 197 198 else 199 usage "Invalid argument ($1)" 200 exit 1 201 fi 202 203 PACKAGE_FILENAME=$SOURCE_PREFIX-$1-$PACKAGE_SUFFIX 204 banner "ACPICA - Generating $PACKAGE_NAME source code package ($PACKAGE_FILENAME)" 205 206 # 207 # Make directories common to all source packages 208 # 209 mkdir $TEMP_DIR 210 mkdir $TEMP_DIR/libraries 211 mkdir $TEMP_DIR/generate 212 mkdir $TEMP_DIR/generate/lint 213 mkdir $TEMP_DIR/generate/release 214 mkdir $TEMP_DIR/generate/unix 215 mkdir $TEMP_DIR/generate/unix/acpibin 216 mkdir $TEMP_DIR/generate/unix/acpidump 217 mkdir $TEMP_DIR/generate/unix/acpiexamples 218 mkdir $TEMP_DIR/generate/unix/acpiexec 219 mkdir $TEMP_DIR/generate/unix/acpihelp 220 mkdir $TEMP_DIR/generate/unix/acpisrc 221 mkdir $TEMP_DIR/generate/unix/acpixtract 222 mkdir $TEMP_DIR/generate/unix/iasl 223 mkdir $TEMP_DIR/tests 224 mkdir $TEMP_DIR/tests/misc 225 mkdir $TEMP_DIR/tests/templates 226 mkdir -p $TEMP_DIR/source/os_specific/service_layers 227 228 # 229 # Copy ACPICA subsystem source code 230 # 231 cp -r documents/changes.txt $TEMP_DIR/changes.txt 232 cp -r source/common $TEMP_DIR/source/common 233 cp -r source/components $TEMP_DIR/source/ 234 cp -r source/include $TEMP_DIR/source/include 235 cp -r generate/release/*.sh $TEMP_DIR/generate/release 236 237 # 238 # Copy iASL compiler and tools source 239 # 240 cp -r source/compiler $TEMP_DIR/source/compiler 241 cp -r source/tools $TEMP_DIR/source/tools 242 243 # 244 # Copy iASL/ACPICA miscellaneous tests (not full test suites) 245 # 246 cp -r tests/misc/*.asl $TEMP_DIR/tests/misc 247 cp -r tests/templates/Makefile $TEMP_DIR/tests/templates 248 cp -r tests/templates/templates.sh $TEMP_DIR/tests/templates 249 250 # 251 # Copy all OS-specific interfaces 252 # 253 cp source/os_specific/service_layers/*.c $TEMP_DIR/source/os_specific/service_layers 254 255 # 256 # Copy generic UNIX makefiles 257 # 258 cp Makefile $TEMP_DIR 259 cp generate/unix/readme.txt $TEMP_DIR/generate/unix/readme.txt 260 cp generate/unix/Makefile* $TEMP_DIR/generate/unix 261 cp generate/unix/acpibin/Makefile $TEMP_DIR/generate/unix/acpibin 262 cp generate/unix/acpidump/Makefile $TEMP_DIR/generate/unix/acpidump 263 cp generate/unix/acpiexamples/Makefile $TEMP_DIR/generate/unix/acpiexamples 264 cp generate/unix/acpiexec/Makefile $TEMP_DIR/generate/unix/acpiexec 265 cp generate/unix/acpihelp/Makefile $TEMP_DIR/generate/unix/acpihelp 266 cp generate/unix/acpisrc/Makefile $TEMP_DIR/generate/unix/acpisrc 267 cp generate/unix/acpixtract/Makefile $TEMP_DIR/generate/unix/acpixtract 268 cp generate/unix/iasl/Makefile $TEMP_DIR/generate/unix/iasl 269 270 # 271 # Copy Lint directory 272 # 273 cp -r generate/lint $TEMP_DIR/generate 274 rm -f $TEMP_DIR/generate/lint/co* 275 rm -f $TEMP_DIR/generate/lint/env* 276 rm -f $TEMP_DIR/generate/lint/lib* 277 rm -f $TEMP_DIR/generate/lint/LintOut.txt 278 279 if [ $PACKAGE_TYPE == Unix ]; then 280 # 281 # Unix/Linux-specific activities 282 # 283 # For Unix2 case, insert the dual license header into all source files 284 # 285 if [ $LICENSE == Dual ]; then 286 insert_dual_license_headers 287 fi 288 289 build_unix_package 290 291 else 292 # 293 # Windows-specific activities 294 # 295 296 # Copy project files for MS Visual Studio 2017 297 298 mkdir $TEMP_DIR/generate/msvc2017 299 cp -r generate/msvc2017/*.sln $TEMP_DIR/generate/msvc2017/ 300 cp -r generate/msvc2017/*.dsp $TEMP_DIR/generate/msvc2017/ 301 cp -r generate/msvc2017/*.dsw $TEMP_DIR/generate/msvc2017/ 302 cp -r generate/msvc2017/*.vcxproj $TEMP_DIR/generate/msvc2017/ 303 304 build_windows_package 305 fi 306 307 banner "ACPICA - Completed $PACKAGE_NAME source code package ($PACKAGE_FILENAME)" 308} 309 310 311#****************************************************************************** 312# 313# generate_test_package 314# 315# Generates the ACPICA test suite packages 316# 317# Arguments: 318# %1 - Target type (win or unix) 319# 320#****************************************************************************** 321 322generate_test_package() 323{ 324 # 325 # Parameter evaluation 326 # 327 if [ $1 == win ]; then 328 PACKAGE_NAME=Windows 329 PACKAGE_TYPE=Win 330 check_zip_utility_exists 331 332 elif [ $1 == unix ]; then 333 PACKAGE_NAME="Unix" 334 PACKAGE_TYPE=Unix 335 336 else 337 usage "Invalid argument ($1)" 338 exit 1 339 fi 340 341 PACKAGE_FILENAME=$TEST_PREFIX-$1-$PACKAGE_SUFFIX 342 banner "ACPICA - Generating $PACKAGE_NAME test suite package ($PACKAGE_FILENAME)" 343 344 # 345 # Copy the ASL Test source 346 # 347 mkdir $TEMP_DIR 348 cp -r tests $TEMP_DIR/tests 349 350 # 351 # Delete extraneous files 352 # 353 cd $TEMP_DIR 354 find . -name "tmp" | xargs rm -r -f 355 find . -name "aml" | xargs rm -r -f 356 find . -name "CVS" | xargs rm -r -f 357 cd .. 358 359 if [ $PACKAGE_TYPE == Unix ]; then 360 # 361 # Unix/Linux-specific activities 362 # 363 build_unix_package 364 365 else 366 # 367 # Windows-specific activities 368 # 369 build_windows_package 370 fi 371 372 banner "ACPICA - Completed $PACKAGE_NAME test suite package ($PACKAGE_FILENAME)" 373} 374 375 376#****************************************************************************** 377# 378# generate_binary_package 379# 380# Generates the ACPICA binary package (Currently Windows only) 381# 382# Arguments: 383# %1 - Target type (win) 384# 385#****************************************************************************** 386 387generate_binary_package() 388{ 389 # 390 # Parameter evaluation 391 # 392 if [ $1 == win ]; then 393 PACKAGE_NAME=Windows 394 PACKAGE_TYPE=Win 395 check_zip_utility_exists 396 397 else 398 usage "Invalid argument ($1)" 399 exit 1 400 fi 401 402 PACKAGE_FILENAME=$BINARY_PREFIX-$1-$PACKAGE_SUFFIX 403 banner "ACPICA - Generating $PACKAGE_NAME binary tools package ($PACKAGE_FILENAME)" 404 405 # 406 # Copy executables and documentation 407 # 408 mkdir $TEMP_DIR 409 cp -r documents/changes.txt $TEMP_DIR/changes.txt 410 cp libraries/acpibin.exe $TEMP_DIR 411 cp libraries/acpidump.exe $TEMP_DIR 412 cp libraries/acpiexec.exe $TEMP_DIR 413 cp libraries/acpihelp.exe $TEMP_DIR 414 cp libraries/acpisrc.exe $TEMP_DIR 415 cp libraries/acpixtract.exe $TEMP_DIR 416 cp libraries/iasl.exe $TEMP_DIR 417 cp tests/misc/badcode.asl $TEMP_DIR 418 419 build_windows_package 420 banner "ACPICA - Completed $PACKAGE_NAME binary tools package ($PACKAGE_FILENAME)" 421} 422 423 424#****************************************************************************** 425# 426# main 427# 428# Arguments: 429# $1 (package_type) is one of: 430# source - Build an ACPICA source package (core and all tools) 431# test - Build an ACPICA test suite package 432# binary - Build an ACPICA binary tools package 433# 434# $2 (target_type) is one of: 435# win - Generate Windows package (Intel license, CRLF line terminators) 436# unix - Generate Unix package (Intel license, LF line terminators) 437# unix2 - Generate Unix package (dual license, LF line terminators) 438# 439#****************************************************************************** 440 441set -e # Abort on any error 442 443if [ $NPARAM -ne 2 ]; then 444 usage "Wrong argument count ($NPARAM)" 445 exit 1 446fi 447 448# 449# cd from acpica/generate/release to acpica 450# 451cd ../.. 452 453# 454# Ensure that the temporary directory is created fresh 455# 456rm -rf $TEMP_DIR 457 458# 459# Parameter evaluation 460# 461if [ $1 == source ]; then 462 generate_source_package $2 463 464elif [ $1 == test ]; then 465 generate_test_package $2 466 467elif [ $1 == binary ]; then 468 generate_binary_package $2 469 470else 471 usage "Invalid argument ($1)" 472 exit 1 473fi 474 475# 476# Remove temporary directory 477# 478rm -rf $TEMP_DIR 479