gen_sdk.sh 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444
  1. ##
  2. ## Copyright (c) 2014 Minoca Corp. All Rights Reserved.
  3. ##
  4. ## Script Name:
  5. ##
  6. ## gen_sdk.sh
  7. ##
  8. ## Abstract:
  9. ##
  10. ## This script generates the distributed image archive containing the
  11. ## Compilers, header, makefiles, and samples in the Minoca OS SDK.
  12. ##
  13. ## Author:
  14. ##
  15. ## Evan Green 18-Sep-2014
  16. ##
  17. ## Environment:
  18. ##
  19. ## Build
  20. ##
  21. set -e
  22. if test -z "$SRCROOT"; then
  23. echo "Error: SRCROOT must be set."
  24. exit 1
  25. fi
  26. if test -z "$ARCH"; then
  27. echo "Error: ARCH must be set."
  28. exit 1
  29. fi
  30. BINROOT="$SRCROOT/${ARCH}chk/bin"
  31. if ! test -d $BINROOT; then
  32. echo "Error: BINROOT '$BINROOT' does not exist."
  33. exit 1
  34. fi
  35. if ! test -f "$BINROOT/build-revision"; then
  36. echo "Error: '$BINROOT/build-revision' is missing."
  37. exit 1
  38. fi
  39. REVISION=`cat "$BINROOT/build-revision"`
  40. if test -z "$REVISION"; then
  41. echo "Error: $BINROOT/build-revision is empty."
  42. exit 1
  43. fi
  44. cd "$BINROOT"
  45. ARCHIVE_DIRECTORY="MinocaSDK-$REVISION"
  46. WORKING="$BINROOT/$ARCHIVE_DIRECTORY"
  47. if test -d "$WORKING"; then
  48. echo "Error: $WORKING already exists. Clean it up first."
  49. exit 1
  50. fi
  51. ARCHIVE="MinocaSDK-$REVISION.zip"
  52. if test -f "$ARCHIVE"; then
  53. echo "Error: '$ARCHIVE' already exists. Delete it first."
  54. exit 1
  55. fi
  56. mkdir -p "$WORKING"
  57. ##
  58. ## Copy the win32 tools.
  59. ##
  60. mkdir -p "$WORKING/tools/win32"
  61. cp -Rv "$SRCROOT/tools/win32/bin" "$WORKING/tools/win32"
  62. cp -Rv "$SRCROOT/tools/win32/scripts" "$WORKING/tools/win32"
  63. cp -Rv "$SRCROOT/tools/win32/swiss" "$WORKING/tools/win32"
  64. cp -Rv "$SRCROOT/tools/win32/MinGW" "$WORKING/tools/win32"
  65. ##
  66. ## Copy the headers.
  67. ##
  68. mkdir -p "$WORKING/os"
  69. cp -Rpv "$SRCROOT/os/include" "$WORKING/os"
  70. mkdir -p "$WORKING/os/apps"
  71. ##
  72. ## Copy the samples.
  73. ##
  74. mkdir -pv "$WORKING/os/drivers/usb/"
  75. cp -Rpv "$SRCROOT/os/drivers/null/" "$WORKING/os/drivers/"
  76. cp -Rpv "$SRCROOT/os/drivers/ramdisk/" "$WORKING/os/drivers/"
  77. cp -Rpv "$SRCROOT/os/drivers/usb/onering/" "$WORKING/os/drivers/usb/"
  78. mkdir -pv "$WORKING/os/drivers/net/ethernet"
  79. cp -Rpv "$SRCROOT/os/drivers/net/ethernet/e100/" \
  80. "$WORKING/os/drivers/net/ethernet"
  81. cp -Rpv "$SRCROOT/os/apps/mount/" "$WORKING/os/apps/"
  82. ##
  83. ## Copy the prebuilt binaries that the samples link against. Also copy the
  84. ## compilers and other tools.
  85. ##
  86. for iarch in x86 armv7 armv6; do
  87. WORKING_BINROOT="$WORKING/${iarch}$DEBUG/bin"
  88. IBINROOT="$SRCROOT/${iarch}$DEBUG/bin"
  89. mkdir -p "$WORKING_BINROOT"
  90. if test -r "$IBINROOT/kernel"; then
  91. cp -pv "$IBINROOT/kernel" "$WORKING_BINROOT"
  92. cp -pv "$IBINROOT/libc.so.1" "$WORKING_BINROOT"
  93. cp -pv "$IBINROOT/libminocaos.so.1" "$WORKING_BINROOT"
  94. cp -pv "$IBINROOT/netcore.drv" "$WORKING_BINROOT"
  95. cp -pv "$IBINROOT/usbcore.drv" "$WORKING_BINROOT"
  96. else
  97. echo "Warning: SDK binaries not found for $iarch"
  98. fi
  99. if test -d "$IBINROOT\tools"; then
  100. cp -Rpv "$IBINROOT\tools" "$WORKING_BINROOT"
  101. fi
  102. done
  103. ##
  104. ## Copy or create the makefiles.
  105. ##
  106. TODAY=`date "+%d-%b-%Y"`
  107. cp -pv "$SRCROOT/os/minoca.mk" "$WORKING/os"
  108. cat > "$WORKING/os/Makefile" <<_EOS
  109. ################################################################################
  110. #
  111. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  112. #
  113. # Module Name:
  114. #
  115. # Minoca OS SDK
  116. #
  117. # Abstract:
  118. #
  119. # This file builds the various samples available in the Minoca OS SDK.
  120. # Feel free to add your own directories here.
  121. #
  122. # Author:
  123. #
  124. # Automatically Generated $TODAY
  125. #
  126. # Environment:
  127. #
  128. # Build
  129. #
  130. ################################################################################
  131. ##
  132. ## Check for the necessary environment variables.
  133. ##
  134. ifndef SRCROOT
  135. \$(error Error: SRCROOT not set: Run setenv.cmd to set up the environment.)
  136. endif
  137. ifndef ARCH
  138. \$(error Error: ARCH not set: Run setenv.cmd to set up the environment.)
  139. endif
  140. ifndef DEBUG
  141. \$(error Error: DEBUG not set: Run setenv.cmd to set up the environment.)
  142. endif
  143. DIRS = apps \
  144. drivers \
  145. include \$(SRCROOT)/os/minoca.mk
  146. _EOS
  147. cat > "$WORKING/os/drivers/Makefile" <<_EOS
  148. ################################################################################
  149. #
  150. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  151. #
  152. # Module Name:
  153. #
  154. # Minoca OS SDK Drivers
  155. #
  156. # Abstract:
  157. #
  158. # This directory builds the sample drivers contained in the SDK.
  159. #
  160. # Author:
  161. #
  162. # Automatically Generated $TODAY
  163. #
  164. # Environment:
  165. #
  166. # Kernel
  167. #
  168. ################################################################################
  169. DIRS = null \
  170. ramdisk \
  171. usb \
  172. net \
  173. include \$(SRCROOT)/os/minoca.mk
  174. _EOS
  175. cat > "$WORKING/os/drivers/usb/Makefile" <<_EOS
  176. ################################################################################
  177. #
  178. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  179. #
  180. # Module Name:
  181. #
  182. # Minoca OS SDK USB Drivers
  183. #
  184. # Abstract:
  185. #
  186. # This directory builds the sample USB drivers contained in the SDK.
  187. #
  188. # Author:
  189. #
  190. # Automatically Generated $TODAY
  191. #
  192. # Environment:
  193. #
  194. # Kernel
  195. #
  196. ################################################################################
  197. DIRS = onering \
  198. include \$(SRCROOT)/os/minoca.mk
  199. _EOS
  200. cat > "$WORKING/os/drivers/net/Makefile" <<_EOS
  201. ################################################################################
  202. #
  203. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  204. #
  205. # Module Name:
  206. #
  207. # Minoca OS SDK Network Drivers
  208. #
  209. # Abstract:
  210. #
  211. # This directory builds the sample Network drivers contained in the SDK.
  212. #
  213. # Author:
  214. #
  215. # Automatically Generated $TODAY
  216. #
  217. # Environment:
  218. #
  219. # Kernel
  220. #
  221. ################################################################################
  222. DIRS = ethernet \
  223. include \$(SRCROOT)/os/minoca.mk
  224. _EOS
  225. cat > "$WORKING/os/drivers/net/ethernet/Makefile" <<_EOS
  226. ################################################################################
  227. #
  228. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  229. #
  230. # Module Name:
  231. #
  232. # Minoca OS SDK Ethernet Drivers
  233. #
  234. # Abstract:
  235. #
  236. # This directory builds the sample Ethernet drivers contained in the SDK.
  237. #
  238. # Author:
  239. #
  240. # Automatically Generated $TODAY
  241. #
  242. # Environment:
  243. #
  244. # Kernel
  245. #
  246. ################################################################################
  247. DIRS = e100 \
  248. include \$(SRCROOT)/os/minoca.mk
  249. _EOS
  250. cat > "$WORKING/os/apps/Makefile" <<_EOS
  251. ################################################################################
  252. #
  253. # Copyright (c) 2014 Minoca Corp. All Rights Reserved
  254. #
  255. # Module Name:
  256. #
  257. # Minoca OS SDK Applications
  258. #
  259. # Abstract:
  260. #
  261. # This directory builds the sample applications contained in the SDK.
  262. #
  263. # Author:
  264. #
  265. # Automatically Generated $TODAY
  266. #
  267. # Environment:
  268. #
  269. # User
  270. #
  271. ################################################################################
  272. DIRS = mount \
  273. include \$(SRCROOT)/os/minoca.mk
  274. _EOS
  275. ##
  276. ## Add the readme file.
  277. ##
  278. DATE=`date "+%B %d, %Y"`
  279. echo "Minoca OS SDK Revision $REVISION.
  280. Created: $DATE" > $WORKING/readme.txt
  281. cat >> $WORKING/readme.txt <<"_EOF"
  282. Website: www.minocacorp.com
  283. Contact Minoca Corp at: info@minocacorp.com
  284. Minoca OS is a leading-edge, highly customizable, general purpose operating
  285. system. It features application level functionality such as virtual memory,
  286. networking, and POSIX compatibility, but at a significantly reduced image and
  287. memory footprint. Unique development, debugging, and real-time profiling tools
  288. make getting to the bottom of issues straightforward and easy. Direct support
  289. from the development team behind Minoca OS simplifies the process of creating
  290. OS images tailored to your application, saving on engineering resources and
  291. development time. Minoca OS is a one-stop shop for systems-level design.
  292. For a more detailed getting started guide, head to
  293. http://www.minocacorp.com/documentation/
  294. This archive contains the Minoca OS SDK for Windows, which contains all the
  295. compilers, build utilities, and headers you need to cross compile applications
  296. and drivers for Minoca OS.
  297. Host System Requirements
  298. ========================
  299. Windows XP or later
  300. 512MB RAM
  301. 2GB Hard Disk space
  302. Target System Requirements
  303. ==========================
  304. Flexible. Functions best with at least 5MB RAM and 5MB disk space.
  305. License
  306. =======
  307. The source code presented in this archive is licensed under the Creative
  308. Commons Attribution license, which can be found at
  309. http://creativecommons.org/licenses/by/4.0/
  310. Installation
  311. ============
  312. This archive requires no installation. Extract the contents of the downloaded
  313. zip archive to the directory of your choice. Ideally this directory would be
  314. near the root of the drive and contain no spaces in the path.
  315. Environment
  316. ===========
  317. The SDK environment builds from the command line. Double click one of the
  318. run_x86.bat, run_armv7.bat, or run_armv6.bat files, which will set a few
  319. environment variables and drop you into a Bourne shell. The environment is based
  320. around three environment variables:
  321. * SRCROOT -- Defines the root of the source tree. The setenv.cmd script
  322. determines this based on its own path.
  323. * ARCH -- Defines the architecture to build for. This is either set to x86,
  324. armv6 or armv7 depending on .bat file used.
  325. * DEBUG -- Defines whether to compile with debugging checks ("chk"), or
  326. without debugging checks ("fre"). This is set to "chk", as it matches with
  327. the free edition binaries.
  328. The various scripts make certain assumptions about the layout of directories
  329. underneath SRCROOT. They assume that the following directories exist underneath
  330. it:
  331. * tools -- Contains the compilers, build utilities (such as the shell and
  332. other core utilities), and other pieces of support infrastructure.
  333. * os -- Contains the SDK source.
  334. * third-party (optional) -- Contains the third party source packages not
  335. authored by Minoca.
  336. * x86chk, x86qchk, armv7chk, armv6chk -- These are actually
  337. $ARCH$VARIANT$DEBUG, and contain the build output. Each directory is
  338. created automatically when a build for its particular architecture is
  339. initiated. Notable directories inside of these include obj, the directory
  340. where object files, libraries, and executables are built, and bin, the
  341. directory where "final product" binaries are placed.
  342. Building
  343. ========
  344. When you double click one of the run_<arch>.bat, you're dropped into the source
  345. root (SRCROOT). To build the samples, "cd" into the os directory, and run
  346. "make". The application and driver samples should build. The final output
  347. binaries will be located in "$SRCROOT/$ARCH$VARIANT$DEBUG/bin". There's a handy
  348. alias installed, you can simply type "bin" to change to this directory.
  349. You can build inside a specific directory by "cd"ing into it and running make
  350. there (ie os/drivers/usb/onering). You can also run "make clean" from somewhere
  351. inside os, which will remove the obj files for the directory you're in. The
  352. contents of the "bin" directory are not cleared, though if you were to run a
  353. subsequent "make", they would be updated.
  354. _EOF
  355. ##
  356. ## Add the one-click scripts.
  357. ##
  358. for iarch in x86 armv7 armv6; do
  359. cat > $WORKING/run_$iarch.bat <<_EOF
  360. @ECHO OFF
  361. set REVISION=$REVISION
  362. cmd.exe /k .\\tools\\win32\\scripts\\setenv.cmd $iarch chk
  363. _EOF
  364. done
  365. ##
  366. ## Add the files to the archive.
  367. ##
  368. echo "Creating archive..."
  369. 7za a -tzip -mmt -mx9 -mtc "$ARCHIVE" "$ARCHIVE_DIRECTORY"
  370. echo "Successfully created $ARCHIVE"
  371. rm -rf "$ARCHIVE_DIRECTORY"