samplecfg 13 KB

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