samplecfg 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #!/bin/sh
  2. #
  3. # $Id: samplecfg,v 1.13 2005/02/19 18:50:20 florian Exp $
  4. #
  5. # Generate Sample Free Pascal configuration file
  6. #
  7. HOSTOS=`uname -s | tr A-Z a-z`
  8. echo Running on $HOSTOS
  9. if [ $# = 0 ]; then
  10. echo 'Usage :'
  11. echo 'samplecfg fpcdir confdir'
  12. echo 'fpcdir = Path where FPC is installed'
  13. echo 'confdir = Path to /etc'
  14. exit 1
  15. fi
  16. if [ "$2" ]; then
  17. sysdir="$2"
  18. [ -d "$sysdir" ] || mkdir "$sysdir"
  19. else
  20. sysdir=/etc
  21. fi
  22. FPCBIN=`dirname "$1"`/../../bin/fpc
  23. FPBIN=`dirname "$1"`/../../bin/fp
  24. sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
  25. sysfpdirbase2=$sysfpdirbase/ide
  26. sysfpdir=$sysfpdirbase2/text
  27. # Detect if we have write permission in sysdir.
  28. if [ -w "$sysdir" ] ; then
  29. echo Write permission in $sysdir.
  30. fpccfgfile="$sysdir"/fpc.cfg
  31. else
  32. echo No write premission in $sysdir.
  33. fpccfgfile="$HOME"/.fpc.cfg
  34. fi
  35. #
  36. # Don't mess with IDE configuration if fp binary does not exist
  37. if [ -f "$FPBIN" ] ; then
  38. # Assume local FP IDE configuration unless writing system-wide version possible
  39. fpinifile="$HOME"/.fp/fp.ini
  40. fpcfgfile="$HOME"/.fp/fp.cfg
  41. # Detect if we have write permission in sysfpdirbase.
  42. if [ -w "$sysfpdirbase" ] ; then
  43. echo Write permission in $sysfpdirbase.
  44. if ! [ -d "$sysfpdirbase2" ] ; then
  45. echo Directory $sysfpdirbase2 did not exist, attempting to create it now
  46. mkdir $sysfpdirbase2 >/dev/null 2>&1
  47. echo Attempting to create directory $sysfpdir
  48. mkdir $sysfpdir >/dev/null 2>&1
  49. elif ! [ -d "$sysfpdir" ] ; then
  50. echo Directory $sysfpdir did not exist, attempting to create it now
  51. mkdir $sysfpdir >/dev/null 2>&1
  52. fi
  53. if [ -w "$sysfpdir" ] ; then
  54. fpinifile="$sysfpdir"/fp.ini
  55. fpcfgfile="$sysfpdir"/fp.cfg
  56. fi
  57. fi
  58. #
  59. # When the local FP IDE configuration is used, check if the directory exists
  60. if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then
  61. echo Directory $HOME/.fp did not exist, attempting to create it now
  62. mkdir "$HOME"/.fp >/dev/null 2>&1
  63. fi
  64. fi
  65. #
  66. if [ -f "$fpccfgfile" ] ; then
  67. mv "$fpccfgfile" "$fpccfgfile.orig" >/dev/null 2>&1
  68. if [ $? = 0 ]; then
  69. echo Saved old compiler config to $fpccfgfile.orig
  70. else
  71. echo Could not save old compiler config. Bailing out...
  72. exit
  73. fi
  74. fi
  75. if [ -f "$FPBIN" ] ; then
  76. if [ -f "$fpinifile" ] ; then
  77. mv "$fpinifile" "$fpinifile.orig" >/dev/null 2>&1
  78. if [ $? = 0 ]; then
  79. echo Saved old fp.ini to $fpinifile.orig
  80. else
  81. echo Could not save old fp.ini. Bailing out...
  82. exit
  83. fi
  84. fi
  85. if [ -f "$fpcfgfile" ] ; then
  86. mv "$fpcfgfile" "$fpcfgfile.orig" >/dev/null 2>&1
  87. if [ $? = 0 ]; then
  88. echo Saved old fp.cfg to $fpcfgfile.orig
  89. else
  90. echo Could not save old fp.cfg. Bailing out...
  91. exit
  92. fi
  93. fi
  94. fi
  95. # set right path to FPC with $fpcversion
  96. FPCPATH=`dirname "$1"`/\$fpcversion
  97. # Write (.)fpc.cfg
  98. echo Writing sample configuration file to $fpccfgfile
  99. fpcmkcfg -d "basepath=$FPCPATH" -o $fpccfgfile
  100. if ! [ -f "$FPBIN" ] ; then
  101. exit
  102. fi
  103. # Write fp.cfg
  104. echo Writing sample configuration file to $fpcfgfile
  105. fpcmkcfg -1 -d "basepath=$FPCPATH" -o $fpcfgfile
  106. # Write fp.ini
  107. echo Writing sample configuration file to $fpinifile
  108. fpcmkcfg -2 -o $fpinifile