samplecfg 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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. FPBIN=`dirname "$1"`/../../bin/fp
  44. sysfpdirbase=`dirname "$1"`/`"$FPCBIN" -iV`
  45. sysfpdirbase2=$sysfpdirbase/ide
  46. sysfpdir=$sysfpdirbase2/text
  47. fpctargetos=`"$FPCBIN" -iTO`
  48. # Detect if we have write permission in sysdir.
  49. if [ -w "$sysdir" ] ; then
  50. echo Write permission in $sysdir.
  51. fpccfgfile="$sysdir"/fpc.cfg
  52. else
  53. echo No write premission in $sysdir.
  54. fpccfgfile="$HOME"/.fpc.cfg
  55. fi
  56. #
  57. # Don't mess with IDE configuration if fp binary does not exist
  58. if [ -f "$FPBIN" ] ; then
  59. # Assume local FP IDE configuration unless writing system-wide version possible
  60. fpinifile="$HOME"/.fp/fp.ini
  61. fpcfgfile="$HOME"/.fp/fp.cfg
  62. # Detect if we have write permission in sysfpdirbase.
  63. if [ -w "$sysfpdirbase" ] ; then
  64. echo Write permission in $sysfpdirbase.
  65. if ! [ -d "$sysfpdirbase2" ] ; then
  66. echo Directory $sysfpdirbase2 did not exist, attempting to create it now
  67. mkdir $sysfpdirbase2 >/dev/null 2>&1
  68. echo Attempting to create directory $sysfpdir
  69. mkdir $sysfpdir >/dev/null 2>&1
  70. elif ! [ -d "$sysfpdir" ] ; then
  71. echo Directory $sysfpdir did not exist, attempting to create it now
  72. mkdir $sysfpdir >/dev/null 2>&1
  73. fi
  74. if [ -w "$sysfpdir" ] ; then
  75. fpinifile="$sysfpdir"/fp.ini
  76. fpcfgfile="$sysfpdir"/fp.cfg
  77. fi
  78. fi
  79. #
  80. # When the local FP IDE configuration is used, check if the directory exists
  81. if [ $fpcfgfile = "$HOME"/.fp/fp.cfg -a ! -d "$HOME"/.fp ] ; then
  82. echo Directory $HOME/.fp did not exist, attempting to create it now
  83. mkdir "$HOME"/.fp >/dev/null 2>&1
  84. fi
  85. fi
  86. #
  87. if [ -f "$fpccfgfile" ] ; then
  88. mv "$fpccfgfile" "$fpccfgfile.orig" >/dev/null 2>&1
  89. if [ $? = 0 ]; then
  90. echo Saved old compiler config to $fpccfgfile.orig
  91. else
  92. echo Could not save old compiler config. Bailing out...
  93. exit
  94. fi
  95. fi
  96. if [ -f "$FPBIN" ] ; then
  97. if [ -f "$fpinifile" ] ; then
  98. mv "$fpinifile" "$fpinifile.orig" >/dev/null 2>&1
  99. if [ $? = 0 ]; then
  100. echo Saved old fp.ini to $fpinifile.orig
  101. else
  102. echo Could not save old fp.ini. Bailing out...
  103. exit
  104. fi
  105. fi
  106. if [ -f "$fpcfgfile" ] ; then
  107. mv "$fpcfgfile" "$fpcfgfile.orig" >/dev/null 2>&1
  108. if [ $? = 0 ]; then
  109. echo Saved old fp.cfg to $fpcfgfile.orig
  110. else
  111. echo Could not save old fp.cfg. Bailing out...
  112. exit
  113. fi
  114. fi
  115. fi
  116. setgccdir
  117. GCCDIR2=""
  118. GCCDIR3=""
  119. GCCDIR4=""
  120. singlearch() {
  121. if [ -d "$GCCDIR" ]; then
  122. echo Found libgcc.a in "$GCCDIR"
  123. GCCDIR=-Fl$GCCDIR
  124. fi
  125. }
  126. # include ports tree dir for FreeBSDers.
  127. case "$HOSTOS" in
  128. freebsd)
  129. GCCDIR=-Fl/usr/local/lib
  130. ;;
  131. openbsd)
  132. GCCDIR=-Fl/usr/local/lib
  133. ;;
  134. netbsd)
  135. GCCDIR=-Fl/usr/pkg/lib
  136. ;;
  137. darwin)
  138. setgccdirarch cpupowerpc -arch ppc
  139. GCCDIR2="$GCCDIR"
  140. setgccdirarch cpupowerpc64 -arch ppc64
  141. GCCDIR3="$GCCDIR"
  142. setgccdirarch cpui386 -arch i386
  143. GCCDIR4="$GCCDIR"
  144. setgccdirarch cpux86_64 -arch x86_64
  145. ;;
  146. linux)
  147. case `"$FPCBIN" -PP` in
  148. i?86|x86_64|amd64)
  149. # Allow for the possibility of both 32 and 64 bit compilation on same system
  150. setgccdirarch cpui386 -m32
  151. GCCDIR4="$GCCDIR"
  152. setgccdirarch cpux86_64 -m64
  153. ;;
  154. powerpc|powerpc64)
  155. # Allow for the possibility of both 32 and 64 bit compilation on same system
  156. setgccdirarch cpupowerpc -m32
  157. GCCDIR4="$GCCDIR"
  158. setgccdirarch cpupowerpc64 -m64
  159. ;;
  160. # Add cases for other linux dual architectures here
  161. *) singlearch # Default
  162. ;;
  163. esac
  164. ;;
  165. *) singlearch
  166. ;;
  167. esac
  168. CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
  169. CPUCROSSIFDEF2=""
  170. case `"$FPCBIN" -PP` in
  171. i?86|x86_64|amd64)
  172. # Cross-binutils are not needed to compile for i386 on an x86_64 system
  173. CPUCROSSIFDEF1="
  174. #IFNDEF CPUI386
  175. #IFNDEF CPUAMD64
  176. #DEFINE NEEDCROSSBINUTILS
  177. #ENDIF
  178. #ENDIF
  179. "
  180. CPUCROSSIFDEF2="
  181. #IFNDEF $HOSTOS
  182. #DEFINE NEEDCROSSBINUTILS
  183. #ENDIF
  184. "
  185. ;;
  186. *)
  187. CPUCROSSIFDEF1="#DEFINE NEEDCROSSBINUTILS"
  188. CPUCROSSIFDEF2=""
  189. ;;
  190. esac
  191. # darwin->darwin does not need cross binutils
  192. case "$HOSTOS" in
  193. darwin)
  194. CPUCROSSIFDEF2="
  195. #ifdef darwin
  196. #undef NEEDCROSSBINUTILS
  197. #endif
  198. "
  199. ;;
  200. esac
  201. # set right path to FPC with $fpcversion
  202. FPCPATH=`dirname "$1"`/\$fpcversion
  203. # Write (.)fpc.cfg
  204. echo Writing sample configuration file to $fpccfgfile
  205. cat <<EOFCFG > $fpccfgfile
  206. #
  207. # Example fpc.cfg for Free Pascal Compiler
  208. #
  209. # ----------------------
  210. # Defines (preprocessor)
  211. # ----------------------
  212. #
  213. # nested #IFNDEF, #IFDEF, #ENDIF, #ELSE, #DEFINE, #UNDEF are allowed
  214. #
  215. # -d is the same as #DEFINE
  216. # -u is the same as #UNDEF
  217. #
  218. #
  219. # Some examples (for switches see below, and the -? helppages)
  220. #
  221. # Try compiling with the -dRELEASE or -dDEBUG on the commandline
  222. #
  223. # For a release compile with optimizes and strip debuginfo
  224. #IFDEF RELEASE
  225. -O2
  226. -Xs
  227. #WRITE Compiling Release Version
  228. #ENDIF
  229. # For a debug version compile with debuginfo and all codegeneration checks on
  230. #IFDEF DEBUG
  231. -g
  232. -Crtoi
  233. #WRITE Compiling Debug Version
  234. #ENDIF
  235. # set binutils prefix
  236. $CPUCROSSIFDEF1
  237. $CPUCROSSIFDEF2
  238. #IFDEF FPC_CROSSCOMPILING
  239. #IFDEF NEEDCROSSBINUTILS
  240. -XP\$fpctarget-
  241. #ENDIF NEEDCROSSBINUTILS
  242. #ENDIF
  243. # assembling
  244. #ifdef darwin
  245. # use pipes instead of temporary files for assembling
  246. -ap
  247. #endif
  248. # ----------------
  249. # Parsing switches
  250. # ----------------
  251. # Pascal language mode
  252. # -Mfpc free pascal dialect (default)
  253. # -Mobjfpc switch some Delphi 2 extensions on
  254. # -Mdelphi tries to be Delphi compatible
  255. # -Mtp tries to be TP/BP 7.0 compatible
  256. # -Mgpc tries to be gpc compatible
  257. # -Mmacpas tries to be compatible to the macintosh pascal dialects
  258. #
  259. # Turn on Object Pascal extensions by default
  260. #-Mobjfpc
  261. # Assembler reader mode
  262. # -Rdefault use default assembler
  263. # -Ratt read AT&T style assembler
  264. # -Rintel read Intel style assembler
  265. #
  266. # All assembler blocks are AT&T styled by default
  267. #-Ratt
  268. # Semantic checking
  269. # -S2 same as -Mobjfpc
  270. # -Sc supports operators like C (*=,+=,/= and -=)
  271. # -Sa include assertion code.
  272. # -Sd same as -Mdelphi
  273. # -Se<x> error options. <x> is a combination of the following:
  274. # <n> : compiler stops after the <n> errors (default is 1)
  275. # w : compiler stops also after warnings
  276. # n : compiler stops also after notes
  277. # h : compiler stops also after hints
  278. # -Sg allow LABEL and GOTO
  279. # -Sh Use ansistrings
  280. # -Si support C++ styled INLINE
  281. # -Sk load fpcylix unit
  282. # -SI<x> set interface style to <x>
  283. # -SIcom COM compatible interface (default)
  284. # -SIcorba CORBA compatible interface
  285. # -Sm support macros like C (global)
  286. # -So same as -Mtp
  287. # -Sp same as -Mgpc
  288. # -Ss constructor name must be init (destructor must be done)
  289. # -St allow static keyword in objects
  290. # -Sx enable exception keywords (default in Delphi/ObjFPC modes)
  291. #
  292. # Allow goto, inline, C-operators, C-vars
  293. -Sgic
  294. # ---------------
  295. # Code generation
  296. # ---------------
  297. # Uncomment the next line if you always want static/dynamic units by default
  298. # (can be overruled with -CD, -CS at the commandline)
  299. #-CS
  300. #-CD
  301. # Set the default heapsize to 8Mb
  302. #-Ch8000000
  303. # Set default codegeneration checks (iocheck, overflow, range, stack)
  304. #-Ci
  305. #-Co
  306. #-Cr
  307. #-Ct
  308. # Optimizer switches
  309. # -Os generate smaller code
  310. # -O1 level 1 optimizations (quick optimizations, debuggable)
  311. # -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
  312. # -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
  313. # -Op<x> set target cpu for optimizing, see fpc -i for possible values
  314. #
  315. # See "fpc -i" also for more fine-grained control over which optimizations
  316. # to perform
  317. #ifdef darwin
  318. #ifdef cpui386
  319. -Cppentiumm
  320. -Oppentiumm
  321. #endif
  322. #endif
  323. # -----------------------
  324. # Set Filenames and Paths
  325. # -----------------------
  326. # Slashes are also allowed under dos
  327. # path to the messagefile, not necessary anymore but can be used to override
  328. # the default language
  329. #-Fr$FPCPATH/msg/errore.msg
  330. #-Fr$FPCPATH/msg/errorn.msg
  331. # searchpath for includefiles
  332. #-Fi/pp/inc;/pp/rtl/inc
  333. #IFDEF FPCAPACHE_1_3
  334. -Fu$FPCPATH/units/\$fpctarget/httpd13/
  335. #ELSE
  336. #IFDEF FPCAPACHE_2_0
  337. -Fu$FPCPATH/units/\$fpctarget/httpd20
  338. #ELSE
  339. -Fu$FPCPATH/units/\$fpctarget/httpd22
  340. #ENDIF
  341. #ENDIF
  342. # searchpath for units and other system dependent things
  343. -Fu$FPCPATH/units/\$fpctarget
  344. -Fu$FPCPATH/units/\$fpctarget/*
  345. -Fu$FPCPATH/units/\$fpctarget/rtl
  346. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  347. # searchpath for libraries
  348. $GCCDIR
  349. $GCCDIR2
  350. $GCCDIR3
  351. $GCCDIR4
  352. #-Fl/pp/lib
  353. #-Fl/lib;/usr/lib
  354. # -------------
  355. # Linking
  356. # -------------
  357. # generate always debugging information for GDB (slows down the compiling
  358. # process)
  359. # -gc generate checks for pointers
  360. # -gd use dbx
  361. # -gg use gsym
  362. # -gh use heap trace unit (for memory leak debugging)
  363. # -gl use line info unit to show more info for backtraces
  364. # -gv generates programs tracable with valgrind
  365. # -gw generate dwarf debugging info
  366. #
  367. # Enable debuginfo and use the line info unit by default
  368. #-gl
  369. # always pass an option to the linker
  370. #-k-s
  371. # Always strip debuginfo from the executable
  372. -Xs
  373. # -------------
  374. # Miscellaneous
  375. # -------------
  376. # Write always a nice FPC logo ;)
  377. -l
  378. # Verbosity
  379. # e : Show errors (default) d : Show debug info
  380. # w : Show warnings u : Show unit info
  381. # n : Show notes t : Show tried/used files
  382. # h : Show hints c : Show conditionals
  383. # i : Show general info d : Show debug info
  384. # l : Show linenumbers r : Rhide/GCC compatibility mode
  385. # a : Show everything x : Executable info (Win32 only)
  386. # b : Write file names messages with full path
  387. # v : write fpcdebug.txt with p : Write tree.log with parse tree
  388. # lots of debugging info
  389. #
  390. # Display Info, Warnings and Notes
  391. -viwn
  392. # If you don't want so much verbosity use
  393. #-vw
  394. #
  395. # That's all folks
  396. #
  397. EOFCFG
  398. if ! [ -f "$FPBIN" ] ; then
  399. exit
  400. fi
  401. # Write fp.cfg
  402. echo Writing sample configuration file to $fpcfgfile
  403. cat <<EOFFPCFG > $fpcfgfile
  404. #IFDEF NORMAL
  405. -Ci
  406. -XS
  407. -T$fpctargetos
  408. -Sg
  409. -O1
  410. -Fu$FPCPATH/units/\$fpctarget
  411. -Fu$FPCPATH/units/\$fpctarget\*
  412. -Fu$FPCPATH/units/\$fpctarget\rtl
  413. $GCCDIR
  414. $GCCDIR2
  415. $GCCDIR3
  416. $GCCDIR4
  417. -g-
  418. -p-
  419. -b-
  420. #ENDIF
  421. #IFDEF DEBUG
  422. -Ci
  423. -XS
  424. -T$fpctargetos
  425. -Sg
  426. -Cr
  427. -Co
  428. -Fu$FPCPATH/units/\$fpctarget
  429. -Fu$FPCPATH/units/\$fpctarget\*
  430. -Fu$FPCPATH/units/\$fpctarget\rtl
  431. $GCCDIR
  432. $GCCDIR2
  433. $GCCDIR3
  434. $GCCDIR4
  435. -g
  436. -p-
  437. -b-
  438. #ENDIF
  439. #IFDEF RELEASE
  440. -XS
  441. -T$fpctargetos
  442. -Sg
  443. -O2
  444. -Fu$FPCPATH/units/\$fpctarget
  445. -Fu$FPCPATH/units/\$fpctarget\*
  446. -Fu$FPCPATH/units/\$fpctarget\rtl
  447. $GCCDIR
  448. $GCCDIR2
  449. $GCCDIR3
  450. $GCCDIR4
  451. -g-
  452. -p-
  453. -b-
  454. #ENDIF
  455. EOFFPCFG
  456. # Write fp.ini
  457. echo Writing sample configuration file to $fpinifile
  458. cat <<EOFFPINI > $fpinifile
  459. [Compile]
  460. CompileMode=DEBUG
  461. [Editor]
  462. DefaultTabSize=8
  463. DefaultFlags=20599
  464. DefaultSaveExt=.pas
  465. DefaultIndentSize=1
  466. [Highlight]
  467. Exts="*.pas;*.pp;*.inc"
  468. NeedsTabs="make*;make*.*"
  469. [SourcePath]
  470. SourceList=""
  471. [Mouse]
  472. DoubleDelay=8
  473. ReverseButtons=0
  474. AltClickAction=6
  475. CtrlClickAction=1
  476. [Search]
  477. FindFlags=4
  478. [Breakpoints]
  479. Count=0
  480. [Watches]
  481. Count=0
  482. [Preferences]
  483. DesktopFileFlags=209
  484. CenterCurrentLineWhileDebugging=1
  485. AutoSaveFlags=7
  486. MiscOptions=6
  487. DesktopLocation=1
  488. [Misc]
  489. ShowReadme=1
  490. [Files]
  491. OpenExts="*.pas;*.pp;*.inc"
  492. [Tools]
  493. Title1="svn ~u~p (curr. dir)"
  494. Program1="svn"
  495. Params1="up \$CAP_MSG()"
  496. HotKey1=23296
  497. Title2="svn c~i~ (curr. dir)"
  498. Program2="svn"
  499. Params2="ci \$CAP_MSG()"
  500. HotKey2=23552
  501. Title3="svn ~d~iff"
  502. Program3="svn"
  503. Params3="diff \$CAP_MSG() \$EDNAME"
  504. HotKey3=23808
  505. Title4="svn ~l~og"
  506. Program4="svn"
  507. Params4="log \$CAP_MSG() \$EDNAME"
  508. HotKey4=34560
  509. Title5="svn ~b~lame"
  510. Program5="svn"
  511. Params5="blame \$CAP_MSG() \$EDNAME"
  512. HotKey5=34816
  513. Title6="svn ~a~dd"
  514. Program6="svn"
  515. Params6="add \$CAP_MSG() \$EDNAME"
  516. HotKey6=0'
  517. EOFFPINI