fpcmake.pp 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720
  1. {
  2. $Id$
  3. Copyright (c) 1999 by Peter Vreman
  4. Convert Makefile.fpc to Makefile
  5. See the file COPYING.FPC, included in this distribution,
  6. for details about the copyright.
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. **********************************************************************}
  11. {$ifdef fpc}{$mode objfpc}{$endif}
  12. {$H+}
  13. program fpcmake;
  14. uses
  15. {$ifdef go32v2}
  16. dpmiexcp,
  17. {$endif}
  18. dos,
  19. sysutils,classes,inifiles;
  20. { Include default fpcmake.ini }
  21. {$i fpcmake.inc}
  22. const
  23. Version='v0.99.13';
  24. Title='fpcmake '+Version;
  25. EnvVar='FPCMAKEINI'; { should be FPCMAKE in the future }
  26. TimeFormat='yyyy/mm/dd hh:nn';
  27. targets=4;
  28. targetstr : array[1..targets] of string=(
  29. 'linux','go32v2','win32','os2'
  30. );
  31. { Sections in Makefile.fpc }
  32. sec_sections='sections';
  33. sec_install='install';
  34. sec_clean='clean';
  35. sec_dirs='dirs';
  36. sec_packages='packages';
  37. sec_libs='libs';
  38. sec_targets='targets';
  39. sec_info='info';
  40. sec_defaults='defaults';
  41. sec_tools='tools';
  42. type
  43. TTargetsString=array[0..targets] of string;
  44. TFpcMake=record
  45. TargetLoaders,
  46. TargetUnits,
  47. TargetPrograms,
  48. InstallUnits,
  49. InstallFiles,
  50. CleanUnits,
  51. CleanFiles : TTargetsString;
  52. DefaultUnits : boolean;
  53. DefaultRule,
  54. DefaultTarget,
  55. DefaultCPU,
  56. DefaultOptions : string;
  57. DirFpc,
  58. DirPackage,
  59. DirUnit,
  60. DirLib,
  61. DirObj,
  62. DirTarget,
  63. DirUnitTarget,
  64. DirInc : string;
  65. PackageFCL : boolean;
  66. Packages : string;
  67. LibName,
  68. LibUnits : string;
  69. LibGCC,
  70. LibOther : boolean;
  71. InfoCfg,
  72. InfoDirs,
  73. InfoTools,
  74. InfoInstall,
  75. InfoObjects : boolean;
  76. SectionNone,
  77. SectionCompile,
  78. SectionDepend,
  79. SectionInstall,
  80. SectionZipInstall,
  81. SectionClean,
  82. SectionLibs,
  83. SectionCommand,
  84. SectionExts,
  85. SectionDirs,
  86. SectionTools,
  87. SectionInfo : boolean;
  88. ToolsPPDep,
  89. ToolsPPUMove,
  90. ToolsPPUFiles,
  91. ToolsData2Inc,
  92. ToolsSed,
  93. ToolsDiff,
  94. ToolsCmp,
  95. ToolsUpx,
  96. ToolsDate,
  97. ToolsZip : boolean;
  98. PreSettings,
  99. PostSettings,
  100. Rules : TStringList;
  101. end;
  102. TMyMemoryStream=class(TMemoryStream)
  103. public
  104. constructor Create(p:pointer;mysize:integer);
  105. end;
  106. var
  107. userini : TFpcMake;
  108. fpcini : TIniFile;
  109. IniStream : TMyMemoryStream;
  110. {*****************************************************************************
  111. Helpers
  112. *****************************************************************************}
  113. procedure Verbose(s:string);
  114. begin
  115. writeln(s);
  116. end;
  117. procedure Error(s:string);
  118. begin
  119. Writeln(s);
  120. Halt(1);
  121. end;
  122. {*****************************************************************************
  123. TMyMemoryStream
  124. *****************************************************************************}
  125. constructor TMyMemoryStream.Create(p:pointer;mysize:integer);
  126. begin
  127. inherited Create;
  128. SetPointer(p,mysize);
  129. end;
  130. {*****************************************************************************
  131. Makefile.fpc reading
  132. *****************************************************************************}
  133. function ReadMakefilefpc:boolean;
  134. var
  135. fn : string;
  136. ini : TIniFile;
  137. procedure ReadTargetsString(var t:Ttargetsstring;const sec,name,def:string);
  138. var
  139. i : integer;
  140. begin
  141. t[0]:=ini.ReadString(sec,name,def);
  142. for i:=1 to targets do
  143. t[i]:=ini.ReadString(sec,name+'_'+targetstr[i],'');
  144. end;
  145. begin
  146. ReadMakefilefpc:=false;
  147. if FileExists('Makefile.fpc') then
  148. fn:='Makefile.fpc'
  149. else
  150. if FileExists('makefile.fpc') then
  151. fn:='makefile.fpc'
  152. else
  153. exit;
  154. Verbose('Reading '+fn);
  155. ini:=TIniFile.Create(fn);
  156. with userini,ini do
  157. begin
  158. { targets }
  159. ReadTargetsString(TargetLoaders,sec_targets,'loaders','');
  160. ReadTargetsString(TargetUnits,sec_targets,'units','');
  161. ReadTargetsString(TargetPrograms,sec_targets,'programs','');
  162. { clean }
  163. ReadTargetsString(CleanUnits,sec_clean,'units','');
  164. ReadTargetsString(CleanFiles,sec_clean,'files','');
  165. { install }
  166. ReadTargetsString(InstallUnits,sec_install,'units','');
  167. ReadTargetsString(InstallFiles,sec_install,'files','');
  168. { defaults }
  169. DefaultUnits:=ReadBool(sec_defaults,'defaultunits',false);
  170. DefaultRule:=ReadString(sec_defaults,'defaultrule','all');
  171. DefaultTarget:=ReadString(sec_defaults,'defaulttarget','');
  172. DefaultCPU:=ReadString(sec_defaults,'defaultcpu','');
  173. DefaultOptions:=ReadString(sec_defaults,'defaultoptions','');
  174. { packages }
  175. Packages:=Readstring(sec_packages,'packages','');
  176. PackageFCL:=ReadBool(sec_packages,'fcl',false);
  177. { dirs }
  178. DirFpc:=ReadString(sec_dirs,'fpcdir','');
  179. DirPackage:=ReadString(sec_dirs,'packagedir','$(FPCDIR)/packages');
  180. DirUnit:=ReadString(sec_dirs,'unitdir','');
  181. DirLib:=ReadString(sec_dirs,'libdir','');
  182. DirObj:=ReadString(sec_dirs,'objdir','');
  183. DirTarget:=ReadString(sec_dirs,'targetdir','');
  184. DirUnitTarget:=ReadString(sec_dirs,'unittargetdir','');
  185. DirInc:=ReadString(sec_dirs,'incdir','');
  186. { libs }
  187. LibName:=ReadString(sec_libs,'libname','');
  188. LibUnits:=ReadString(sec_libs,'libunits','');
  189. LibGcc:=ReadBool(sec_libs,'libgcc',false);
  190. LibOther:=ReadBool(sec_libs,'libother',false);
  191. { tools }
  192. ToolsPPDep:=ReadBool(sec_tools,'toolppdep',true);
  193. ToolsPPUMove:=ReadBool(sec_tools,'toolppumove',true);
  194. ToolsPPUFiles:=ReadBool(sec_tools,'toolppufiles',true);
  195. ToolsSed:=ReadBool(sec_tools,'toolsed',false);
  196. ToolsData2Inc:=ReadBool(sec_tools,'tooldata2inc',false);
  197. ToolsDiff:=ReadBool(sec_tools,'tooldiff',false);
  198. ToolsCmp:=ReadBool(sec_tools,'toolcmp',false);
  199. ToolsUpx:=ReadBool(sec_tools,'toolupx',true);
  200. ToolsDate:=ReadBool(sec_tools,'tooldate',true);
  201. ToolsZip:=ReadBool(sec_tools,'toolzip',true);
  202. { sections }
  203. SectionInstall:=ReadBool(sec_sections,'install',true);
  204. SectionZipInstall:=ReadBool(sec_sections,'zipinstall',true);
  205. SectionClean:=ReadBool(sec_sections,'clean',true);
  206. SectionInfo:=ReadBool(sec_sections,'info',true);
  207. SectionTools:=ReadBool(sec_sections,'tools',true);
  208. SectionLibs:=ReadBool(sec_sections,'libs',true);
  209. SectionExts:=ReadBool(sec_sections,'exts',true);
  210. SectionDirs:=ReadBool(sec_sections,'dirs',true);
  211. SectionCompile:=ReadBool(sec_sections,'compile',true);
  212. SectionDepend:=ReadBool(sec_sections,'depend',true);
  213. SectionCommand:=ReadBool(sec_sections,'command',true);
  214. SectionNone:=ReadBool(sec_sections,'none',false);
  215. if SectionNone then
  216. begin
  217. SectionInstall:=false;
  218. SectionZipInstall:=false;
  219. SectionClean:=false;
  220. SectionInfo:=false;
  221. SectionTools:=false;
  222. SectionLibs:=false;
  223. SectionExts:=false;
  224. SectionDirs:=false;
  225. SectionCompile:=false;
  226. SectionDepend:=false;
  227. SectionCommand:=false;
  228. end;
  229. { info }
  230. InfoCfg:=ReadBool(sec_info,'infoconfig',true);
  231. InfoDirs:=ReadBool(sec_info,'infodirs',false);
  232. InfoTools:=ReadBool(sec_info,'infotools',false);
  233. InfoInstall:=ReadBool(sec_info,'infoinstall',true);
  234. InfoObjects:=ReadBool(sec_info,'infoobjects',true);
  235. { rules }
  236. PreSettings:=TStringList.Create;
  237. ReadSectionRaw('presettings',PreSettings);
  238. { rules }
  239. PostSettings:=TStringList.Create;
  240. ReadSectionRaw('postsettings',PostSettings);
  241. { rules }
  242. rules:=TStringList.Create;
  243. ReadSectionRaw('rules',rules);
  244. end;
  245. ini.Destroy;
  246. ReadMakefilefpc:=true;
  247. end;
  248. {*****************************************************************************
  249. userini.ini loading
  250. *****************************************************************************}
  251. function ReadFpcMakeIni:TIniFile;
  252. var
  253. fn : string;
  254. begin
  255. ReadFpcMakeIni:=nil;
  256. if FileExists('fpcmake.ini') then
  257. fn:='fpcmake.ini'
  258. else
  259. if (FileExists(GetEnv(envvar))) then
  260. fn:=GetEnv(envvar)
  261. else
  262. {$ifdef linux}
  263. if FileExists('/usr/lib/fpc/fpcmake.ini') then
  264. fn:='/usr/lib/fpc/fpcmake.ini'
  265. {$else}
  266. if FileExists(ChangeFileExt(paramstr(0),'.ini')) then
  267. fn:=ChangeFileExt(paramstr(0),'.ini')
  268. {$endif}
  269. else
  270. fn:='';
  271. if fn='' then
  272. begin
  273. Verbose('Opening internal ini');
  274. IniStream:=TMyMemoryStream.Create(@fpcmakeini,sizeof(fpcmakeini));
  275. result:=TIniFile.Create(IniStream);
  276. end
  277. else
  278. begin
  279. Verbose('Opening '+fn);
  280. result:=TIniFile.Create(fn);
  281. end;
  282. end;
  283. {*****************************************************************************
  284. Makefile writing
  285. *****************************************************************************}
  286. function WriteMakefile:boolean;
  287. var
  288. mf : TStringList;
  289. ss : TStringList;
  290. procedure FixTab(sl:TStringList);
  291. var
  292. i,j,k : integer;
  293. s,s2 : string;
  294. begin
  295. i:=0;
  296. while (i<sl.Count) do
  297. begin
  298. if (sl[i]<>'') and (sl[i][1] in [' ',#9]) then
  299. begin
  300. s:=sl[i];
  301. k:=0;
  302. j:=0;
  303. repeat
  304. inc(j);
  305. case s[j] of
  306. ' ' :
  307. inc(k);
  308. #9 :
  309. k:=(k+7) and not(7);
  310. else
  311. break;
  312. end;
  313. until (j=length(s));
  314. if k>7 then
  315. begin
  316. s2:='';
  317. Delete(s,1,j-1);
  318. while (k>7) do
  319. begin
  320. s2:=s2+#9;
  321. dec(k,8);
  322. end;
  323. while (k>0) do
  324. begin
  325. s2:=s2+' ';
  326. dec(k);
  327. end;
  328. sl[i]:=s2+s;
  329. end;
  330. end;
  331. inc(i);
  332. end;
  333. end;
  334. procedure AddSection(b:boolean;s:string);
  335. begin
  336. if b then
  337. begin
  338. ss.Clear;
  339. fpcini.ReadSectionRaw(s,ss);
  340. mf.AddStrings(ss);
  341. mf.Add('');
  342. end;
  343. end;
  344. procedure AddRule(s:string);
  345. var
  346. i : integer;
  347. begin
  348. i:=0;
  349. while (i<userini.rules.Count) do
  350. begin
  351. if (userini.rules[i]<>'') and
  352. (userini.rules[i][1]=s[1]) and
  353. (Copy(userini.rules[i],1,length(s))=s) then
  354. exit;
  355. inc(i);
  356. end;
  357. mf.Add(s+': fpc_'+s);
  358. mf.Add('');
  359. end;
  360. procedure AddTargets(const pre:string;var t:TTargetsString);
  361. var
  362. i : integer;
  363. begin
  364. if t[0]<>'' then
  365. mf.Add(pre+'='+t[0]);
  366. for i:=1to targets do
  367. if (t[i]<>'') then
  368. begin
  369. mf.Add('ifeq ($(OS_TARGET),'+targetstr[i]+')');
  370. if t[i]<>'' then
  371. mf.Add(pre+'+='+t[i]);
  372. mf.Add('endif');
  373. end;
  374. end;
  375. procedure AddHead(const s:string);
  376. begin
  377. mf.Add('');
  378. mf.Add('# '+s);
  379. mf.Add('');
  380. end;
  381. var
  382. hs : string;
  383. begin
  384. { Open the Makefile }
  385. Verbose('Creating Makefile');
  386. mf:=TStringList.Create;
  387. { Buffer for reading and writing the sections }
  388. ss:=TStringList.Create;
  389. with mf do
  390. begin
  391. { write header & autodetection }
  392. Add('#');
  393. Add('# Makefile generated by '+title+' on '+FormatDateTime(TimeFormat,Now));
  394. Add('#');
  395. Add('');
  396. Add('defaultrule: '+userini.defaultrule);
  397. Add('');
  398. AddSection(true,'osdetect');
  399. { set the forced target os/cpu }
  400. if (userini.defaulttarget<>'') or (userini.defaultcpu<>'') then
  401. begin
  402. AddSection(true,'defaulttarget');
  403. if userini.defaulttarget<>'' then
  404. Add('override OS_TARGET:='+userini.defaulttarget);
  405. if userini.defaultcpu<>'' then
  406. Add('override CPU_TARGET:='+userini.defaultcpu);
  407. Add('');
  408. end;
  409. { fpc detection }
  410. AddSection(true,'fpcdetect');
  411. { write the default & user settings }
  412. AddSection(true,'defaultsettings');
  413. AddSection(true,'usersettings');
  414. { Pre Settings }
  415. if userini.PreSettings.count>0 then
  416. begin
  417. AddHead('Pre Settings');
  418. AddStrings(userini.PreSettings);
  419. end;
  420. { Targets }
  421. AddHead('Targets');
  422. AddTargets('LOADEROBJECTS',userini.targetloaders);
  423. AddTargets('UNITOBJECTS',userini.targetunits);
  424. AddTargets('EXEOBJECTS',userini.targetprograms);
  425. { Clean }
  426. AddHead('Clean');
  427. AddTargets('EXTRACLEANUNITS',userini.cleanunits);
  428. AddTargets('EXTRACLEANFILES',userini.cleanfiles);
  429. { Install }
  430. AddHead('Install');
  431. AddTargets('EXTRAINSTALLUNITS',userini.installunits);
  432. AddTargets('EXTRAINSTALLFILES',userini.installfiles);
  433. { Defaults }
  434. AddHead('Defaults');
  435. if userini.defaultunits then
  436. Add('DEFAULTUNITS=1');
  437. if userini.defaultoptions<>'' then
  438. Add('override NEEDOPT='+userini.defaultoptions);
  439. { Dirs }
  440. AddHead('Directories');
  441. if userini.dirfpc<>'' then
  442. begin
  443. { this dir can be set in the environment, it's more a default }
  444. Add('ifndef FPCDIR');
  445. Add('FPCDIR='+userini.dirfpc);
  446. Add('endif');
  447. end;
  448. if userini.dirpackage<>'' then
  449. begin
  450. { this dir can be set in the environment, it's more a default }
  451. Add('ifndef PACKAGEDIR');
  452. Add('PACKAGEDIR='+userini.dirpackage);
  453. Add('endif');
  454. end;
  455. if userini.dirunit<>'' then
  456. Add('override NEEDUNITDIR='+userini.dirunit);
  457. if userini.dirlib<>'' then
  458. Add('override NEEDLIBDIR='+userini.dirlib);
  459. if userini.dirobj<>'' then
  460. Add('override NEEDOBJDIR='+userini.dirobj);
  461. if userini.dirinc<>'' then
  462. Add('override NEEDINCDIR='+userini.dirinc);
  463. if userini.dirtarget<>'' then
  464. begin
  465. Add('ifndef TARGETDIR');
  466. Add('TARGETDIR='+userini.dirtarget);
  467. Add('endif');
  468. end;
  469. if userini.dirunittarget<>'' then
  470. begin
  471. Add('ifndef UNITTARGETDIR');
  472. Add('UNITTARGETDIR='+userini.dirunittarget);
  473. Add('endif');
  474. end;
  475. { Packages }
  476. AddHead('Packages');
  477. if userini.Packages<>'' then
  478. Add('PACKAGES='+userini.Packages);
  479. if userini.PackageFCL then
  480. Add('override NEEDUNITDIR+=$(FPCDIR)/fcl/$(OS_TARGET)');
  481. if userini.Packages<>'' then
  482. Add('override NEEDUNITDIR+=$(addprefix $(PACKAGEDIR)/,$(PACKAGES))');
  483. { Libs }
  484. AddHead('Libraries');
  485. if userini.libname<>'' then
  486. Add('LIBNAME='+userini.libname);
  487. if userini.libunits<>'' then
  488. Add('SHAREDLIBOBJECTUNITS='+userini.libunits);
  489. if userini.libgcc then
  490. Add('override NEEDGCCLIB=1');
  491. if userini.libother then
  492. Add('override NEEDOTHERLIB=1');
  493. { Info }
  494. if userini.SectionInfo then
  495. begin
  496. AddHead('Info');
  497. hs:='';
  498. if userini.infocfg then
  499. hs:=hs+'fpc_infocfg ';
  500. if userini.infodirs then
  501. hs:=hs+'fpc_infodirs ';
  502. if userini.infotools then
  503. hs:=hs+'fpc_infotools ';
  504. if userini.infoobjects then
  505. hs:=hs+'fpc_infoobjects ';
  506. if userini.infoinstall then
  507. hs:=hs+'fpc_infoinstall ';
  508. Add('FPCINFO='+hs);
  509. end;
  510. { Post Settings }
  511. if userini.PostSettings.count>0 then
  512. begin
  513. AddHead('Post Settings');
  514. AddStrings(userini.PostSettings);
  515. end;
  516. Add('');
  517. { write dirs }
  518. if userini.sectiondirs then
  519. begin
  520. AddSection(true,'dir_default');
  521. AddSection(userini.libgcc,'dir_gcclib');
  522. AddSection(userini.libother,'dir_otherlib');
  523. AddSection(true,'dir_install');
  524. end;
  525. { commandline }
  526. if userini.sectioncommand then
  527. begin
  528. Add('');
  529. AddSection(true,'command_begin');
  530. AddSection(true,'command_rtl');
  531. AddSection(true,'command_needopt');
  532. AddSection((userini.dirfpc<>''),'command_fpcdir');
  533. AddSection((userini.dirunit<>'') or (userini.packages<>'') or (userini.packagefcl),'command_needunit');
  534. AddSection((userini.dirlib<>''),'command_needlib');
  535. AddSection((userini.dirobj<>''),'command_needobj');
  536. AddSection((userini.dirinc<>''),'command_needinc');
  537. AddSection(userini.libgcc,'command_gcclib');
  538. AddSection(userini.libother,'command_otherlib');
  539. AddSection((userini.dirinc<>''),'command_inc');
  540. AddSection((userini.dirtarget<>''),'command_target');
  541. AddSection((userini.dirunittarget<>''),'command_unittarget');
  542. AddSection(true,'command_smartlink');
  543. AddSection(true,'command_end');
  544. end;
  545. { write tools }
  546. if userini.sectiontools then
  547. begin
  548. AddSection(true,'shelltools');
  549. AddSection(true,'tool_default');
  550. AddSection(userini.toolsppdep,'tool_ppdep');
  551. AddSection(userini.toolsppumove,'tool_ppumove');
  552. AddSection(userini.toolsppufiles,'tool_ppufiles');
  553. AddSection(userini.toolsdata2inc,'tool_data2inc');
  554. AddSection(userini.toolsupx,'tool_upx');
  555. AddSection(userini.toolssed,'tool_sed');
  556. AddSection(userini.toolsdate,'tool_date');
  557. AddSection(userini.toolszip,'tool_zip');
  558. AddSection(userini.toolscmp,'tool_cmp');
  559. AddSection(userini.toolsdiff,'tool_diff');
  560. end;
  561. { extensions }
  562. if userini.sectionexts then
  563. AddSection(true,'extensions');
  564. { add default rules }
  565. AddSection(true,'defaultrules');
  566. AddRule('all');
  567. AddRule('smart');
  568. AddRule('shared');
  569. AddRule('showinstall');
  570. AddRule('install');
  571. AddRule('zipinstall');
  572. AddRule('zipinstalladd');
  573. AddRule('clean');
  574. AddRule('clean_all');
  575. AddRule('depend');
  576. AddRule('info');
  577. { default fpc_ rules }
  578. if userini.SectionCompile then
  579. AddSection(true,'compilerules');
  580. if userini.SectionLibs then
  581. AddSection(true,'libraryrules');
  582. if userini.SectionInstall then
  583. AddSection(true,'installrules');
  584. if userini.SectionZipInstall then
  585. AddSection(true,'zipinstallrules');
  586. if userini.SectionClean then
  587. AddSection(true,'cleanrules');
  588. if userini.SectionDepend then
  589. AddSection(true,'dependrules');
  590. if userini.SectionInfo then
  591. begin
  592. AddSection(true,'inforules');
  593. AddSection(userini.infocfg,'info_cfg');
  594. AddSection(userini.infodirs,'info_dirs');
  595. AddSection(userini.infotools,'info_tools');
  596. AddSection(userini.infoobjects,'info_objects');
  597. AddSection(userini.infoinstall,'info_install');
  598. end;
  599. { insert users rules }
  600. if userini.rules.count>0 then
  601. begin
  602. AddSection(true,'userrules');
  603. AddStrings(userini.rules);
  604. end;
  605. end;
  606. { Write the Makefile and cleanup }
  607. Verbose('Writing Makefile');
  608. FixTab(mf);
  609. mf.SaveToFile('Makefile');
  610. mf.Destroy;
  611. ss.Destroy;
  612. WriteMakefile:=true;
  613. end;
  614. begin
  615. { Open userini.ini }
  616. fpcini:=ReadFpcMakeIni;
  617. if not assigned(fpcini) then
  618. Error('Can''t read fpcmake.ini');
  619. { Open Makefile.fpc }
  620. if not ReadMakefilefpc then
  621. Error('Can''t read Makefile.fpc');
  622. { Write Makefile }
  623. if not WriteMakefile then
  624. Error('Can''t write Makefile');
  625. fpcini.destroy;
  626. end.
  627. {
  628. $Log$
  629. Revision 1.7 1999-11-23 09:43:35 peter
  630. + internal .ini file
  631. + packages support
  632. * ppufiles,data2inc support
  633. Revision 1.6 1999/11/10 22:10:49 peter
  634. * fpcmake updated
  635. Revision 1.5 1999/11/09 14:38:32 peter
  636. * sections section to leave out whole info/tools
  637. Revision 1.4 1999/11/08 15:01:39 peter
  638. * fpcmake support
  639. Revision 1.3 1999/11/04 12:07:13 michael
  640. + Now envvar is used
  641. Revision 1.2 1999/11/03 23:39:53 peter
  642. * lot of updates
  643. Revision 1.1 1999/11/02 23:57:40 peter
  644. * initial version
  645. }