configure 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. #!/bin/sh
  2. #
  3. # Configure script for OS/161 tree.
  4. # This generates the file "defs.mk" at the top level of the tree.
  5. #
  6. # Usage: ./configure [options]
  7. # where you can get a list of the options by doing ./configure --help.
  8. #
  9. # Must be run with the top of the OS/161 tree as its current directory.
  10. #
  11. # Note: while this superficially acts like a GNU Autoconf configure
  12. # script, it was not generated by autoconf. Scripts generated by
  13. # autoconf are much harder to read. :-)
  14. #
  15. # If this script bombs out, you can create defs.mk by hand based on
  16. # the comments in mk/os161.config.mk.
  17. #
  18. # Target hardware platform and machine type.
  19. PLATFORM='sys161'
  20. MACHINE='mips'
  21. # Default optimize/debug flag: optimize.
  22. DEBUG='-O2'
  23. # Default location of the root of the installed system.
  24. # Note that we quote it such that the reference to the home directory
  25. # is a make variable, not a shell variable. This means it gets expanded
  26. # when make runs rather than when this script runs.
  27. OSTREE='$(HOME)/cs350-os161/root'
  28. # Assume this
  29. HOST_CC=gcc
  30. ##################################################
  31. #
  32. # Check to make sure we're in the right place.
  33. if [ ! -d kern/startup ]; then
  34. echo 'Please run configure from the top of the OS/161 tree.'
  35. exit 1
  36. fi
  37. # UW Mod
  38. # Default toolchain name.
  39. TOOLPREFIX="cs350-"
  40. #
  41. # Process the command-line options.
  42. while [ "x$1" != x ]; do
  43. case "$1" in
  44. --debug) DEBUG='-g';;
  45. --ostree=*) OSTREE=`echo $1 | sed 's,^[^=]*=,,'`;;
  46. # UW Mod
  47. --toolprefix=*) TOOLPREFIX=`echo $1 | sed 's,^[^=]*=,,'`;;
  48. --help|*)
  49. more <<EOF
  50. Usage: ./configure [options]
  51. where the options are:
  52. --help Print this message.
  53. --debug Compile the user-level programs with debug info.
  54. This is disabled by default because there's no
  55. support for userlevel source debugging in OS/161.
  56. (Note: debug info in the kernel is controlled by
  57. the kernel config file.)
  58. --ostree=PATH Install the compiled system in a directory tree
  59. rooted at PATH. Default is \$HOME/cs161/root.
  60. --toolprefix=NAME Set up to use compiler and tools named with a
  61. prefix of NAME. The default is "cs350-", so the
  62. tools used are called cs350-gcc, cs350-ld, etc.
  63. The directory with these tools should be on your
  64. shell's search path.
  65. EOF
  66. exit
  67. ;;
  68. esac
  69. shift
  70. done
  71. # Check if the host system supports 4.4BSD <err.h>.
  72. echo -n "Checking for <err.h>... "
  73. cat > __conftest.c <<EOF
  74. #include <err.h>
  75. int
  76. main()
  77. {
  78. err(0, "works");
  79. return 1;
  80. }
  81. EOF
  82. OK=0
  83. if $HOST_CC __conftest.c -o __conftest >/dev/null 2>&1; then
  84. if ./__conftest >/dev/null 2>&1; then
  85. OK=1
  86. fi
  87. fi
  88. rm -f __conf*
  89. if [ $OK = 1 ]; then
  90. echo 'yes'
  91. else
  92. echo 'no'
  93. COMPAT_CFLAGS="${COMPATCFLAGS} -DNEED_ERR"
  94. COMPAT_TARGETS="${HOSTTARGETS} install-errh"
  95. fi
  96. ####################
  97. # Now generate defs.mk.
  98. echo 'Generating defs.mk.'
  99. (
  100. # First, put an explanatory comment at the top.
  101. cat <<EOF
  102. # This file was generated by configure. Edits will disappear if you rerun
  103. # configure. If you find that you need to edit this file to make things
  104. # work, let the course staff know and we'll try to fix the configure script.
  105. #
  106. # The purpose of this file is to hold all the makefile definitions
  107. # needed to adjust the OS/161 build process to any particular
  108. # environment. If I've done it right, all you need to do is rerun the
  109. # configure script and make clean if you start working on a different
  110. # host OS. If I've done it mostly right, you may need to edit this
  111. # file but you still hopefully won't need to edit any of the
  112. # makefiles.
  113. #
  114. # The things that can be set here are documented in mk/os161.config.mk.
  115. #
  116. EOF
  117. echo "OSTREE=${OSTREE}"
  118. echo "PLATFORM=${PLATFORM}"
  119. echo "MACHINE=${MACHINE}"
  120. echo "COMPAT_CFLAGS=${COMPAT_CFLAGS}"
  121. echo "COMPAT_TARGETS=${COMPAT_TARGETS}"
  122. # UW Mod
  123. echo "TOOLPREFIX=${TOOLPREFIX}"
  124. ) > defs.mk