samplecfg 13 KB

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