samplecfg 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  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. # ----------------
  244. # Parsing switches
  245. # ----------------
  246. # Pascal language mode
  247. # -Mfpc free pascal dialect (default)
  248. # -Mobjfpc switch some Delphi 2 extensions on
  249. # -Mdelphi tries to be Delphi compatible
  250. # -Mtp tries to be TP/BP 7.0 compatible
  251. # -Mgpc tries to be gpc compatible
  252. # -Mmacpas tries to be compatible to the macintosh pascal dialects
  253. #
  254. # Turn on Object Pascal extensions by default
  255. #-Mobjfpc
  256. # Assembler reader mode
  257. # -Rdefault use default assembler
  258. # -Ratt read AT&T style assembler
  259. # -Rintel read Intel style assembler
  260. #
  261. # All assembler blocks are AT&T styled by default
  262. #-Ratt
  263. # Semantic checking
  264. # -S2 same as -Mobjfpc
  265. # -Sc supports operators like C (*=,+=,/= and -=)
  266. # -Sa include assertion code.
  267. # -Sd same as -Mdelphi
  268. # -Se<x> error options. <x> is a combination of the following:
  269. # <n> : compiler stops after the <n> errors (default is 1)
  270. # w : compiler stops also after warnings
  271. # n : compiler stops also after notes
  272. # h : compiler stops also after hints
  273. # -Sg allow LABEL and GOTO
  274. # -Sh Use ansistrings
  275. # -Si support C++ styled INLINE
  276. # -Sk load fpcylix unit
  277. # -SI<x> set interface style to <x>
  278. # -SIcom COM compatible interface (default)
  279. # -SIcorba CORBA compatible interface
  280. # -Sm support macros like C (global)
  281. # -So same as -Mtp
  282. # -Sp same as -Mgpc
  283. # -Ss constructor name must be init (destructor must be done)
  284. # -St allow static keyword in objects
  285. # -Sx enable exception keywords (default in Delphi/ObjFPC modes)
  286. #
  287. # Allow goto, inline, C-operators, C-vars
  288. -Sgic
  289. # ---------------
  290. # Code generation
  291. # ---------------
  292. # Uncomment the next line if you always want static/dynamic units by default
  293. # (can be overruled with -CD, -CS at the commandline)
  294. #-CS
  295. #-CD
  296. # Set the default heapsize to 8Mb
  297. #-Ch8000000
  298. # Set default codegeneration checks (iocheck, overflow, range, stack)
  299. #-Ci
  300. #-Co
  301. #-Cr
  302. #-Ct
  303. # Optimizer switches
  304. # -Os generate smaller code
  305. # -O1 level 1 optimizations (quick optimizations, debuggable)
  306. # -O2 level 2 optimizations (-O1 + optimizations which make debugging more difficult)
  307. # -O3 level 3 optimizations (-O2 + optimizations which also may make the program slower rather than faster)
  308. # -Op<x> set target cpu for optimizing, see fpc -i for possible values
  309. #
  310. # See "fpc -i" also for more fine-grained control over which optimizations
  311. # to perform
  312. # -----------------------
  313. # Set Filenames and Paths
  314. # -----------------------
  315. # Slashes are also allowed under dos
  316. # path to the messagefile, not necessary anymore but can be used to override
  317. # the default language
  318. #-Fr$FPCPATH/msg/errore.msg
  319. #-Fr$FPCPATH/msg/errorn.msg
  320. # searchpath for includefiles
  321. #-Fi/pp/inc;/pp/rtl/inc
  322. #IFDEF FPCAPACHE_1_3
  323. -Fu$FPCPATH/units/\$fpctarget/httpd13/
  324. #ELSE
  325. #IFDEF FPCAPACHE_2_0
  326. -Fu$FPCPATH/units/\$fpctarget/httpd20
  327. #ELSE
  328. -Fu$FPCPATH/units/\$fpctarget/httpd22
  329. #ENDIF
  330. #ENDIF
  331. # searchpath for units and other system dependent things
  332. -Fu$FPCPATH/units/\$fpctarget
  333. -Fu$FPCPATH/units/\$fpctarget/*
  334. -Fu$FPCPATH/units/\$fpctarget/rtl
  335. #-Fu~/fpc/packages/base/*/units/$fpctarget;~/fpc/fcl/units/$fpctarget;~/fpc/rtl/units/$fpctarget
  336. # searchpath for libraries
  337. $GCCDIR
  338. $GCCDIR2
  339. $GCCDIR3
  340. $GCCDIR4
  341. #-Fl/pp/lib
  342. #-Fl/lib;/usr/lib
  343. # -------------
  344. # Linking
  345. # -------------
  346. # generate always debugging information for GDB (slows down the compiling
  347. # process)
  348. # -gc generate checks for pointers
  349. # -gd use dbx
  350. # -gg use gsym
  351. # -gh use heap trace unit (for memory leak debugging)
  352. # -gl use line info unit to show more info for backtraces
  353. # -gv generates programs tracable with valgrind
  354. # -gw generate dwarf debugging info
  355. #
  356. # Enable debuginfo and use the line info unit by default
  357. #-gl
  358. # always pass an option to the linker
  359. #-k-s
  360. # Always strip debuginfo from the executable
  361. -Xs
  362. # -------------
  363. # Miscellaneous
  364. # -------------
  365. # Write always a nice FPC logo ;)
  366. -l
  367. # Verbosity
  368. # e : Show errors (default) d : Show debug info
  369. # w : Show warnings u : Show unit info
  370. # n : Show notes t : Show tried/used files
  371. # h : Show hints c : Show conditionals
  372. # i : Show general info d : Show debug info
  373. # l : Show linenumbers r : Rhide/GCC compatibility mode
  374. # a : Show everything x : Executable info (Win32 only)
  375. # b : Write file names messages with full path
  376. # v : write fpcdebug.txt with p : Write tree.log with parse tree
  377. # lots of debugging info
  378. #
  379. # Display Info, Warnings and Notes
  380. -viwn
  381. # If you don't want so much verbosity use
  382. #-vw
  383. #
  384. # That's all folks
  385. #
  386. EOFCFG
  387. if ! [ -f "$FPBIN" ] ; then
  388. exit
  389. fi
  390. # Write fp.cfg
  391. echo Writing sample configuration file to $fpcfgfile
  392. cat <<EOFFPCFG > $fpcfgfile
  393. #IFDEF NORMAL
  394. -Ci
  395. -XS
  396. -T$fpctargetos
  397. -Sg
  398. -O1
  399. -Fu$FPCPATH/units/\$fpctarget
  400. -Fu$FPCPATH/units/\$fpctarget\*
  401. -Fu$FPCPATH/units/\$fpctarget\rtl
  402. $GCCDIR
  403. $GCCDIR2
  404. $GCCDIR3
  405. $GCCDIR4
  406. -g-
  407. -p-
  408. -b-
  409. #ENDIF
  410. #IFDEF DEBUG
  411. -Ci
  412. -XS
  413. -T$fpctargetos
  414. -Sg
  415. -Cr
  416. -Co
  417. -Fu$FPCPATH/units/\$fpctarget
  418. -Fu$FPCPATH/units/\$fpctarget\*
  419. -Fu$FPCPATH/units/\$fpctarget\rtl
  420. $GCCDIR
  421. $GCCDIR2
  422. $GCCDIR3
  423. $GCCDIR4
  424. -g
  425. -p-
  426. -b-
  427. #ENDIF
  428. #IFDEF RELEASE
  429. -XS
  430. -T$fpctargetos
  431. -Sg
  432. -O2
  433. -Fu$FPCPATH/units/\$fpctarget
  434. -Fu$FPCPATH/units/\$fpctarget\*
  435. -Fu$FPCPATH/units/\$fpctarget\rtl
  436. $GCCDIR
  437. $GCCDIR2
  438. $GCCDIR3
  439. $GCCDIR4
  440. -g-
  441. -p-
  442. -b-
  443. #ENDIF
  444. EOFFPCFG
  445. # Write fp.ini
  446. echo Writing sample configuration file to $fpinifile
  447. cat <<EOFFPINI > $fpinifile
  448. [Compile]
  449. CompileMode=DEBUG
  450. [Editor]
  451. DefaultTabSize=8
  452. DefaultFlags=20599
  453. DefaultSaveExt=.pas
  454. DefaultIndentSize=1
  455. [Highlight]
  456. Exts="*.pas;*.pp;*.inc"
  457. NeedsTabs="make*;make*.*"
  458. [SourcePath]
  459. SourceList=""
  460. [Mouse]
  461. DoubleDelay=8
  462. ReverseButtons=0
  463. AltClickAction=6
  464. CtrlClickAction=1
  465. [Search]
  466. FindFlags=4
  467. [Breakpoints]
  468. Count=0
  469. [Watches]
  470. Count=0
  471. [Preferences]
  472. DesktopFileFlags=209
  473. CenterCurrentLineWhileDebugging=1
  474. AutoSaveFlags=7
  475. MiscOptions=6
  476. DesktopLocation=1
  477. [Misc]
  478. ShowReadme=1
  479. [Files]
  480. OpenExts="*.pas;*.pp;*.inc"
  481. [Tools]
  482. Title1="svn ~u~p (curr. dir)"
  483. Program1="svn"
  484. Params1="up \$CAP_MSG()"
  485. HotKey1=23296
  486. Title2="svn c~i~ (curr. dir)"
  487. Program2="svn"
  488. Params2="ci \$CAP_MSG()"
  489. HotKey2=23552
  490. Title3="svn ~d~iff"
  491. Program3="svn"
  492. Params3="diff \$CAP_MSG() \$EDNAME"
  493. HotKey3=23808
  494. Title4="svn ~l~og"
  495. Program4="svn"
  496. Params4="log \$CAP_MSG() \$EDNAME"
  497. HotKey4=34560
  498. Title5="svn ~b~lame"
  499. Program5="svn"
  500. Params5="blame \$CAP_MSG() \$EDNAME"
  501. HotKey5=34816
  502. Title6="svn ~a~dd"
  503. Program6="svn"
  504. Params6="add \$CAP_MSG() \$EDNAME"
  505. HotKey6=0'
  506. EOFFPINI