samplecfg 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371
  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. CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
  113. CPUCROSSIFDEF2=""
  114. case `fpc -PP` in
  115. i?86|x86_64|amd64)
  116. # Cross-binutils are not needed to compile for i386 on an x86_64 system
  117. CPUCROSSIFDEF1="
  118. #IFNDEF CPUI386
  119. #IFNDEF CPUAMD64
  120. #DEFINE NEEDCROSSBINUTILS
  121. #ENDIF
  122. #ENDIF
  123. "
  124. CPUCROSSIFDEF2="
  125. #IFNDEF $HOSTOS
  126. #DEFINE NEEDCROSSBINUTILS
  127. #ENDIF
  128. "
  129. ;;
  130. *)
  131. CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
  132. CPUCROSSIFDEF2=""
  133. ;;
  134. esac
  135. # darwin->darwin does not need cross binutils
  136. case $HOSTOS in
  137. darwin)
  138. CPUCROSSIFDEF2="
  139. #ifdef darwin
  140. #undef NEEDCROSSBINUTILS
  141. #endif
  142. "
  143. ;;
  144. esac
  145. # set right path to FPC with $fpcversion
  146. FPCPATH=`dirname "$1"`/\$fpcversion
  147. # Write the file
  148. echo Writing sample configuration file to $thefile
  149. cat <<EOFCFG > $thefile
  150. #
  151. # Example fpc.cfg for Free Pascal Compiler
  152. #
  153. # ----------------------
  154. # Defines (preprocessor)
  155. # ----------------------
  156. #
  157. # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
  158. #
  159. # -d is the same as #DEFINE
  160. # -u is the same as #UNDEF
  161. #
  162. #
  163. # Some examples (for switches see below, and the -? helppages)
  164. #
  165. # Try compiling with the -dRELEASE or -dDEBUG on the commandline
  166. #
  167. # For a release compile with optimizes and strip debuginfo
  168. #IFDEF RELEASE
  169. -O2
  170. -Xs
  171. #WRITE Compiling Release Version
  172. #ENDIF
  173. # For a debug version compile with debuginfo and all codegeneration checks on
  174. #IFDEF DEBUG
  175. -g
  176. -Crtoi
  177. #WRITE Compiling Debug Version
  178. #ENDIF
  179. # set binutils prefix
  180. $CPUCROSSIFDEF1
  181. $CPUCROSSIFDEF2
  182. #IFDEF FPC_CROSSCOMPILING
  183. #IFDEF NEEDCROSSBINUTILS
  184. -XP\$fpctarget-
  185. #ENDIF NEEDCROSSBINUTILS
  186. #ENDIF
  187. # ----------------
  188. # Parsing switches
  189. # ----------------
  190. # Pascal language mode
  191. # -Mfpc free pascal dialect (default)
  192. # -Mobjfpc switch some Delphi 2 extensions on
  193. # -Mdelphi tries to be Delphi compatible
  194. # -Mtp tries to be TP/BP 7.0 compatible
  195. # -Mgpc tries to be gpc compatible
  196. # -Mmacpas tries to be compatible to the macintosh pascal dialects
  197. #
  198. # Turn on Object Pascal extensions by default
  199. #-Mobjfpc
  200. # Assembler reader mode
  201. # -Rdefault use default assembler
  202. # -Ratt read AT&T style assembler
  203. # -Rintel read Intel style assembler
  204. #
  205. # All assembler blocks are AT&T styled by default
  206. #-Ratt
  207. # Semantic checking
  208. # -S2 same as -Mobjfpc
  209. # -Sc supports operators like C (*=,+=,/= and -=)
  210. # -Sa include assertion code.
  211. # -Sd same as -Mdelphi
  212. # -Se<x> error options. <x> is a combination of the following:
  213. # <n> : compiler stops after the <n> errors (default is 1)
  214. # w : compiler stops also after warnings
  215. # n : compiler stops also after notes
  216. # h : compiler stops also after hints
  217. # -Sg allow LABEL and GOTO
  218. # -Sh Use ansistrings
  219. # -Si support C++ styled INLINE
  220. # -Sk load fpcylix unit
  221. # -SI<x> set interface style to <x>
  222. # -SIcom COM compatible interface (default)
  223. # -SIcorba CORBA compatible interface
  224. # -Sm support macros like C (global)
  225. # -So same as -Mtp
  226. # -Sp same as -Mgpc
  227. # -Ss constructor name must be init (destructor must be done)
  228. # -St allow static keyword in objects
  229. # -Sx enable exception keywords (default in Delphi/ObjFPC modes)
  230. #
  231. # Allow goto, inline, C-operators, C-vars
  232. -Sgic
  233. # ---------------
  234. # Code generation
  235. # ---------------
  236. # Uncomment the next line if you always want static/dynamic units by default
  237. # (can be overruled with -CD, -CS at the commandline)
  238. #-CS
  239. #-CD
  240. # Set the default heapsize to 8Mb
  241. #-Ch8000000
  242. # Set default codegeneration checks (iocheck, overflow, range, stack)
  243. #-Ci
  244. #-Co
  245. #-Cr
  246. #-Ct
  247. # Optimizer switches
  248. # -Os generate smaller code
  249. # -O1 level 1 optimizations (quick optimizations, debuggable)
  250. # -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
  251. # -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
  252. # -Op<x> set target cpu for optimizing, see fpc -i for possible values
  253. #
  254. # See "fpc -i" also for more fine-grained control over which optimizations
  255. # to perform
  256. # -----------------------
  257. # Set Filenames and Paths
  258. # -----------------------
  259. # Slashes are also allowed under dos
  260. # path to the messagefile, not necessary anymore but can be used to override
  261. # the default language
  262. #-Fr$FPCPATH/msg/errore.msg
  263. #-Fr$FPCPATH/msg/errorn.msg
  264. # searchpath for includefiles
  265. #-Fi/pp/inc;/pp/rtl/inc
  266. # searchpath for units and other system dependent things
  267. -Fu$FPCPATH/units/\$fpctarget
  268. -Fu$FPCPATH/units/\$fpctarget/*
  269. -Fu$FPCPATH/units/\$fpctarget/rtl
  270. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  271. # searchpath for libraries
  272. $GCCDIR
  273. $GCCDIR2
  274. $GCCDIR3
  275. $GCCDIR4
  276. #-Fl/pp/lib
  277. #-Fl/lib;/usr/lib
  278. # -------------
  279. # Linking
  280. # -------------
  281. # generate always debugging information for GDB (slows down the compiling
  282. # process)
  283. # -gc generate checks for pointers
  284. # -gd use dbx
  285. # -gg use gsym
  286. # -gh use heap trace unit (for memory leak debugging)
  287. # -gl use line info unit to show more info for backtraces
  288. # -gv generates programs tracable with valgrind
  289. # -gw generate dwarf debugging info
  290. #
  291. # Enable debuginfo and use the line info unit by default
  292. #-gl
  293. # always pass an option to the linker
  294. #-k-s
  295. # Always strip debuginfo from the executable
  296. -Xs
  297. # -------------
  298. # Miscellaneous
  299. # -------------
  300. # Write always a nice FPC logo ;)
  301. -l
  302. # Verbosity
  303. # e : Show errors (default) d : Show debug info
  304. # w : Show warnings u : Show unit info
  305. # n : Show notes t : Show tried/used files
  306. # h : Show hints c : Show conditionals
  307. # i : Show general info d : Show debug info
  308. # l : Show linenumbers r : Rhide/GCC compatibility mode
  309. # a : Show everything x : Executable info (Win32 only)
  310. # b : Write file names messages with full path
  311. # v : write fpcdebug.txt with p : Write tree.log with parse tree
  312. # lots of debugging info
  313. #
  314. # Display Info, Warnings and Notes
  315. -viwn
  316. # If you don't want so much verbosity use
  317. #-vw
  318. #
  319. # That's all folks
  320. #
  321. EOFCFG