samplecfg 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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. function setgccdir() {
  8. # Find path to libgcc.a
  9. GCCSPEC=`(gcc -v $@ 2>&1)| head -n 1| awk '{ print $4 } '`
  10. if [ -z "$GCCSPEC" ] ; then
  11. GCCSPEC=`gcc -print-libgcc-file-name $@ 2>/dev/null`
  12. fi
  13. GCCDIR=`dirname $GCCSPEC`
  14. }
  15. function setgccdirarch() {
  16. # Find path to libgcc.a
  17. GCCSPEC=`(gcc -v -arch $1 2>&1)| head -n 1| awk '{ print $4 } '`
  18. if [ -z "$GCCSPEC" ] ; then
  19. GCCSPEC=`gcc -print-libgcc-file-name -arch $1`
  20. fi
  21. GCCDIR=`dirname $GCCSPEC`
  22. if [ -z "$GCCDIR" ] ; then
  23. return
  24. fi
  25. case $1 in
  26. ppc)
  27. GCCDIR="#ifdef cpupowerpc
  28. -Fl$GCCDIR
  29. #endif"
  30. ;;
  31. ppc64)
  32. GCCDIR="#ifdef cpupowerpc64
  33. -Fl$GCCDIR
  34. #endif"
  35. ;;
  36. i386)
  37. GCCDIR="#ifdef cpui386
  38. -Fl$GCCDIR
  39. #endif"
  40. ;;
  41. x86_64)
  42. GCCDIR="#ifdef cpux86_64
  43. -Fl$GCCDIR
  44. #endif"
  45. ;;
  46. esac
  47. }
  48. HOSTOS=`uname -s | tr A-Z a-z`
  49. echo Running on $HOSTOS
  50. if [ $# = 0 ]; then
  51. echo 'Usage :'
  52. echo 'samplecfg fpcdir confdir'
  53. echo 'fpcdir = Path where FPC is installed'
  54. echo 'confdir = Path to /etc'
  55. exit 1
  56. fi
  57. if [ $2 ]; then
  58. sysdir=$2
  59. [ -d $sysdir ] || mkdir $sysdir
  60. else
  61. sysdir=/etc
  62. fi
  63. # Detect if we have write permission in root.
  64. if [ -w $sysdir ] ; then
  65. echo Write permission in $sysdir.
  66. thefile=$sysdir/fpc.cfg
  67. else
  68. echo No write premission in $sysdir.
  69. thefile=$HOME/.fpc.cfg
  70. fi
  71. #
  72. if [ -f $thefile ] ; then
  73. mv $thefile $thefile.orig >/dev/null 2>&1
  74. if [ $? = 0 ]; then
  75. echo Saved old config to $thefile.orig
  76. else
  77. echo Could not save old config. Bailing out...
  78. exit
  79. fi
  80. fi
  81. setgccdir
  82. GCCDIR2=""
  83. GCCDIR3=""
  84. GCCDIR4=""
  85. # include ports tree dir for FreeBSDers.
  86. case $HOSTOS in
  87. freebsd)
  88. GCCDIR=-Fl/usr/local/lib
  89. ;;
  90. openbsd)
  91. GCCDIR=-Fl/usr/local/lib
  92. ;;
  93. netbsd)
  94. GCCDIR=-Fl/usr/pkg/lib
  95. ;;
  96. darwin)
  97. setgccdirarch ppc
  98. GCCDIR2=$GCCDIR
  99. setgccdirarch ppc64
  100. GCCDIR3=$GCCDIR
  101. setgccdirarch i386
  102. GCCDIR4=$GCCDIR
  103. setgccdirarch x86_64
  104. ;;
  105. *)
  106. if [ -d $GCCDIR ]; then
  107. echo Found libgcc.a in $GCCDIR
  108. GCCDIR=-Fl$GCCDIR
  109. fi
  110. ;;
  111. esac
  112. # set right path to FPC with $fpcversion
  113. FPCPATH=`dirname "$1"`/\$fpcversion
  114. # Write the file
  115. echo Writing sample configuration file to $thefile
  116. cat <<EOFCFG > $thefile
  117. #
  118. # Example fpc.cfg for Free Pascal Compiler
  119. #
  120. # ----------------------
  121. # Defines (preprocessor)
  122. # ----------------------
  123. #
  124. # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
  125. #
  126. # -d is the same as #DEFINE
  127. # -u is the same as #UNDEF
  128. #
  129. #
  130. # Some examples (for switches see below, and the -? helppages)
  131. #
  132. # Try compiling with the -dRELEASE or -dDEBUG on the commandline
  133. #
  134. # For a release compile with optimizes and strip debuginfo
  135. #IFDEF RELEASE
  136. -OG2p3
  137. -Xs
  138. #WRITE Compiling Release Version
  139. #ENDIF
  140. # For a debug version compile with debuginfo and all codegeneration checks on
  141. #IFDEF DEBUG
  142. -g
  143. -Crtoi
  144. #WRITE Compiling Debug Version
  145. #ENDIF
  146. # set binutils prefix
  147. #IFDEF FPC_CROSSCOMPILING
  148. -XP\$fpctarget-
  149. #ENDIF
  150. # ----------------
  151. # Parsing switches
  152. # ----------------
  153. # Pascal language mode
  154. # -Mfpc free pascal dialect (default)
  155. # -Mobjfpc switch some Delphi 2 extensions on
  156. # -Mdelphi tries to be Delphi compatible
  157. # -Mtp tries to be TP/BP 7.0 compatible
  158. # -Mgpc tries to be gpc compatible
  159. # -Mmacpas tries to be compatible to the macintosh pascal dialects
  160. #
  161. # Turn on Object Pascal extensions by default
  162. #-Mobjfpc
  163. # Assembler reader mode
  164. # -Rdefault use default assembler
  165. # -Ratt read AT&T style assembler
  166. # -Rintel read Intel style assembler
  167. #
  168. # All assembler blocks are AT&T styled by default
  169. #-Ratt
  170. # Semantic checking
  171. # -S2 same as -Mobjfpc
  172. # -Sc supports operators like C (*=,+=,/= and -=)
  173. # -Sa include assertion code.
  174. # -Sd same as -Mdelphi
  175. # -Se<x> compiler stops after the <x> errors (default is 1)
  176. # -Sg allow LABEL and GOTO
  177. # -Sh Use ansistrings
  178. # -Si support C++ styled INLINE
  179. # -SI<x> set interface style to <x>
  180. # -SIcomCOM compatible interface (default)
  181. # -SIcorbaCORBA compatible interface
  182. # -Sm support macros like C (global)
  183. # -So same as -Mtp
  184. # -Sp same as -Mgpc
  185. # -Ss constructor name must be init (destructor must be done)
  186. # -St allow static keyword in objects
  187. #
  188. # Allow goto, inline, C-operators, C-vars
  189. -Sgic
  190. # ---------------
  191. # Code generation
  192. # ---------------
  193. # Uncomment the next line if you always want static/dynamic units by default
  194. # (can be overruled with -CD, -CS at the commandline)
  195. #-CS
  196. #-CD
  197. # Set the default heapsize to 8Mb
  198. #-Ch8000000
  199. # Set default codegeneration checks (iocheck, overflow, range, stack)
  200. #-Ci
  201. #-Co
  202. #-Cr
  203. #-Ct
  204. # Optimizer switches for i386 compiler
  205. # -Og generate smaller code
  206. # -OG generate faster code (default)
  207. # -Or keep certain variables in registers (still BUGGY!!!)
  208. # -Ou enable uncertain optimizations (see docs)
  209. # -O1 level 1 optimizations (quick optimizations)
  210. # -O2 level 2 optimizations (-O1 + slower optimizations)
  211. # -O3 level 3 optimizations (same as -O2u)
  212. # -Op target processor
  213. # -Op1 set target processor to 386/486
  214. # -Op2 set target processor to Pentium/PentiumMMX (tm)
  215. # -Op3 set target processor to PPro/PII/c6x86/K6 (tm)
  216. # Optimize always for Size and PII
  217. #-OG2p3
  218. # -----------------------
  219. # Set Filenames and Paths
  220. # -----------------------
  221. # Slashes are also allowed under dos
  222. # path to the messagefile, not necessary anymore but can be used to override
  223. # the default language
  224. #-Fr$FPCPATH/msg/errore.msg
  225. #-Fr$FPCPATH/msg/errorn.msg
  226. # searchpath for includefiles
  227. #-Fi/pp/inc;/pp/rtl/inc
  228. # searchpath for units and other system dependent things
  229. -Fu$FPCPATH/units/\$fpctarget
  230. -Fu$FPCPATH/units/\$fpctarget/*
  231. -Fu$FPCPATH/units/\$fpctarget/rtl
  232. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  233. # searchpath for libraries
  234. $GCCDIR
  235. $GCCDIR2
  236. $GCCDIR3
  237. $GCCDIR4
  238. #-Fl/pp/lib
  239. #-Fl/lib;/usr/lib
  240. # -------------
  241. # Linking
  242. # -------------
  243. # generate always debugging information for GDB (slows down the compiling
  244. # process)
  245. # -gc generate checks for pointers
  246. # -gd use dbx
  247. # -gg use gsym
  248. # -gh use heap trace unit (for memory leak debugging)
  249. # -gl use line info unit to show more info for backtraces
  250. # -gv generates programs tracable with valgrind
  251. # -gw generate dwarf debugging info
  252. #
  253. # Enable debuginfo and use the line info unit by default
  254. #-gl
  255. # always pass an option to the linker
  256. #-k-s
  257. # Always strip debuginfo from the executable
  258. -Xs
  259. # -------------
  260. # Miscellaneous
  261. # -------------
  262. # Write always a nice FPC logo ;)
  263. -l
  264. # Verbosity
  265. # e : Show errors (default) d : Show debug info
  266. # w : Show warnings u : Show unit info
  267. # n : Show notes t : Show tried/used files
  268. # h : Show hints m : Show defined macros
  269. # i : Show general info p : Show compiled procedures
  270. # l : Show linenumbers c : Show conditionals
  271. # a : Show everything 0 : Show nothing (except errors)
  272. # b : Show all procedure r : Rhide/GCC compatibility mode
  273. # declarations if an error x : Executable info (Win32 only)
  274. # occurs
  275. #
  276. # Display Info, Warnings, Notes and Hints
  277. -viwn
  278. # If you don't want so much verbosity use
  279. #-vw
  280. #
  281. # That's all folks
  282. #
  283. EOFCFG