samplecfg 8.3 KB

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