samplecfg 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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. powerpc|powerpc64)
  100. # Allow for the possibility of both 32 and 64 bit compilation on same system
  101. setgccdirarch cpupowerpc -m32
  102. GCCDIR4="$GCCDIR"
  103. setgccdirarch cpupowerpc64 -m64
  104. ;;
  105. # Add cases for other linux dual architectures here
  106. *) singlearch # Default
  107. ;;
  108. esac
  109. ;;
  110. *) singlearch
  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. #IFDEF FPCAPACHE_1_3
  268. -Fu$FPCPATH/units/\$fpctarget/httpd-1.3/
  269. #ELSE
  270. #IFDEF FPCAPACHE_2_0
  271. -Fu$FPCPATH/units/\$fpctarget/httpd-2.0
  272. #ELSE
  273. -Fu$FPCPATH/units/\$fpctarget/httpd-2.2
  274. #ENDIF
  275. #ENDIF
  276. # searchpath for units and other system dependent things
  277. -Fu$FPCPATH/units/\$fpctarget
  278. -Fu$FPCPATH/units/\$fpctarget/*
  279. -Fu$FPCPATH/units/\$fpctarget/rtl
  280. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  281. # searchpath for libraries
  282. $GCCDIR
  283. $GCCDIR2
  284. $GCCDIR3
  285. $GCCDIR4
  286. #-Fl/pp/lib
  287. #-Fl/lib;/usr/lib
  288. # -------------
  289. # Linking
  290. # -------------
  291. # generate always debugging information for GDB (slows down the compiling
  292. # process)
  293. # -gc generate checks for pointers
  294. # -gd use dbx
  295. # -gg use gsym
  296. # -gh use heap trace unit (for memory leak debugging)
  297. # -gl use line info unit to show more info for backtraces
  298. # -gv generates programs tracable with valgrind
  299. # -gw generate dwarf debugging info
  300. #
  301. # Enable debuginfo and use the line info unit by default
  302. #-gl
  303. # always pass an option to the linker
  304. #-k-s
  305. # Always strip debuginfo from the executable
  306. -Xs
  307. # -------------
  308. # Miscellaneous
  309. # -------------
  310. # Write always a nice FPC logo ;)
  311. -l
  312. # Verbosity
  313. # e : Show errors (default) d : Show debug info
  314. # w : Show warnings u : Show unit info
  315. # n : Show notes t : Show tried/used files
  316. # h : Show hints c : Show conditionals
  317. # i : Show general info d : Show debug info
  318. # l : Show linenumbers r : Rhide/GCC compatibility mode
  319. # a : Show everything x : Executable info (Win32 only)
  320. # b : Write file names messages with full path
  321. # v : write fpcdebug.txt with p : Write tree.log with parse tree
  322. # lots of debugging info
  323. #
  324. # Display Info, Warnings and Notes
  325. -viwn
  326. # If you don't want so much verbosity use
  327. #-vw
  328. #
  329. # That's all folks
  330. #
  331. EOFCFG