samplecfg 8.7 KB

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