samplecfg 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. 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. 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. -O2
  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> error options. <x> is a combination of the following:
  176. # <n> : compiler stops after the <n> errors (default is 1)
  177. # w : compiler stops also after warnings
  178. # n : compiler stops also after notes
  179. # h : compiler stops also after hints
  180. # -Sg allow LABEL and GOTO
  181. # -Sh Use ansistrings
  182. # -Si support C++ styled INLINE
  183. # -Sk load fpcylix unit
  184. # -SI<x> set interface style to <x>
  185. # -SIcom COM compatible interface (default)
  186. # -SIcorba CORBA compatible interface
  187. # -Sm support macros like C (global)
  188. # -So same as -Mtp
  189. # -Sp same as -Mgpc
  190. # -Ss constructor name must be init (destructor must be done)
  191. # -St allow static keyword in objects
  192. # -Sx enable exception keywords (default in Delphi/ObjFPC modes)
  193. #
  194. # Allow goto, inline, C-operators, C-vars
  195. -Sgic
  196. # ---------------
  197. # Code generation
  198. # ---------------
  199. # Uncomment the next line if you always want static/dynamic units by default
  200. # (can be overruled with -CD, -CS at the commandline)
  201. #-CS
  202. #-CD
  203. # Set the default heapsize to 8Mb
  204. #-Ch8000000
  205. # Set default codegeneration checks (iocheck, overflow, range, stack)
  206. #-Ci
  207. #-Co
  208. #-Cr
  209. #-Ct
  210. # Optimizer switches
  211. # -Os generate smaller code
  212. # -O1 level 1 optimizations (quick optimizations, debuggable)
  213. # -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
  214. # -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
  215. # -Op<x> set target cpu for optimizing, see fpc -i for possible values
  216. #
  217. # See "fpc -i" also for more fine-grained control over which optimizations
  218. # to perform
  219. # -----------------------
  220. # Set Filenames and Paths
  221. # -----------------------
  222. # Slashes are also allowed under dos
  223. # path to the messagefile, not necessary anymore but can be used to override
  224. # the default language
  225. #-Fr$FPCPATH/msg/errore.msg
  226. #-Fr$FPCPATH/msg/errorn.msg
  227. # searchpath for includefiles
  228. #-Fi/pp/inc;/pp/rtl/inc
  229. # searchpath for units and other system dependent things
  230. -Fu$FPCPATH/units/\$fpctarget
  231. -Fu$FPCPATH/units/\$fpctarget/*
  232. -Fu$FPCPATH/units/\$fpctarget/rtl
  233. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  234. # searchpath for libraries
  235. $GCCDIR
  236. $GCCDIR2
  237. $GCCDIR3
  238. $GCCDIR4
  239. #-Fl/pp/lib
  240. #-Fl/lib;/usr/lib
  241. # -------------
  242. # Linking
  243. # -------------
  244. # generate always debugging information for GDB (slows down the compiling
  245. # process)
  246. # -gc generate checks for pointers
  247. # -gd use dbx
  248. # -gg use gsym
  249. # -gh use heap trace unit (for memory leak debugging)
  250. # -gl use line info unit to show more info for backtraces
  251. # -gv generates programs tracable with valgrind
  252. # -gw generate dwarf debugging info
  253. #
  254. # Enable debuginfo and use the line info unit by default
  255. #-gl
  256. # always pass an option to the linker
  257. #-k-s
  258. # Always strip debuginfo from the executable
  259. -Xs
  260. # -------------
  261. # Miscellaneous
  262. # -------------
  263. # Write always a nice FPC logo ;)
  264. -l
  265. # Verbosity
  266. # e : Show errors (default) d : Show debug info
  267. # w : Show warnings u : Show unit info
  268. # n : Show notes t : Show tried/used files
  269. # h : Show hints c : Show conditionals
  270. # i : Show general info d : Show debug info
  271. # l : Show linenumbers r : Rhide/GCC compatibility mode
  272. # a : Show everything x : Executable info (Win32 only)
  273. # b : Write file names messages with full path
  274. # v : write fpcdebug.txt with p : Write tree.log with parse tree
  275. # lots of debugging info
  276. #
  277. # Display Info, Warnings and Notes
  278. -viwn
  279. # If you don't want so much verbosity use
  280. #-vw
  281. #
  282. # That's all folks
  283. #
  284. EOFCFG