home *** CD-ROM | disk | FTP | other *** search
/ APDL Public Domain 1 / APDL_PD1A.iso / program / c / makatic / Docs / !Help next >
Encoding:
Text File  |  1996-03-30  |  15.7 KB  |  565 lines

  1.     Makatic tools release 2.10 30 Mar 1996
  2.     ••••••••••••••••••••••••••••••••••••••
  3.  
  4.  
  5.  
  6. Contents
  7. ————————
  8.  
  9.     Important
  10.     Introduction
  11.     Makatic.Maktic2
  12.     Makatic scripts
  13.     Example projects
  14.     Projects with sub-makefiles
  15.     Files in the Makatic directory
  16.     Motivation for Makatic
  17.     Problems
  18.     And finally...
  19.  
  20.  
  21.  
  22.  
  23. Important
  24. —————————
  25.  
  26. The behaviour of the scripts Makatic.Small/Medium/Large has been changed
  27. slightly since Makatic 2.07.
  28.  
  29. See 'Makatic.Docs.History' for details of the change.
  30.  
  31.  
  32. Introduction
  33. ————————————
  34.  
  35.     Makatic is a set of freeware command-line tools which can
  36.     automate much of the management of C, C++ and Assembler
  37.     projects.
  38.     
  39.     The Makatic tools automatically generate and run makefiles, by 
  40.     looking for source files in the project directory, and adding 
  41.     equivalent .o filenames to a user-supplied template makefile. 
  42.     
  43.     This means that adding or removing a source-file to a project 
  44.     doesn't mean one has to edit a makefile, or inform a desktop 
  45.     front-end such as '!Make' about the change.
  46.     
  47.     This is particularly helpful with large projects, particularly
  48.     if they involve building different versions of a project from
  49.     the same source code.
  50.     
  51.     Makatic needs a tool to run the makefiles. It has only been
  52.     tested with Acorn's AMU program, but should work with other
  53.     similar programs. 
  54.     
  55.     
  56.     Tool names
  57.     ¨¨¨¨¨¨¨¨¨¨
  58.     
  59.         To avoid clashes with other tool names, all Makatic
  60.         tools are within the 'Makatic' directory and you should
  61.         move the whole directory into your Run$Path (instead of
  62.         moving the individual Makatic tools into your 
  63.         Run$Path).
  64.         
  65.         This means that Makatic tools should be called with 
  66.         (for example) 'Makatic.Makatic2 <parameters>'.
  67.     
  68.     
  69.     Wot - no Desktop front-end?
  70.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  71.     
  72.         Makatic doesn't have a desktop interface.
  73.         
  74.         A desktop-only interface would be no use if you want to
  75.         (for example) control Makatic from a script. By
  76.         contrast, CLI tools are ideal for this sort of thing,
  77.         and don't take up memory when they aren't running.
  78.         
  79.         Moreover, it would be very easy to add a desktop
  80.         frontend to the existing CLI tools in the future. Making
  81.         a CLI tool from a desktop application is much more
  82.         tricky.
  83.         
  84.         Putting simple TaskObey scripts in a project directory 
  85.         (as in the example projects) which call the Makatic 
  86.         tools, enables one to double-click on Filer icons to 
  87.         build the project, providing a crude Wimp interface. I
  88.         have used this system for a while, and haven't felt the
  89.         need for a proper Wimp application.
  90.         
  91.         However, if anyone writes a desktop front-end (eg using
  92.         Acorn's FrontEnd system), I'd be interested in including
  93.         it in future releases of Makatic.
  94.  
  95.  
  96.  
  97. Makatic.Makatic2
  98. ————————————————
  99.  
  100.     This is the core tool. It takes a fair number of flags and 
  101.     parameters (which are described if you run 
  102.     'Makatic.Makatic2 -help'), so there are some simple Obey 
  103.     scripts in the 'Makatic' directory which implement the 
  104.     functionality required for some standard project-types.
  105.     
  106.     'Makatic.Makatic2' will preserve dynamic dependancies in an
  107.     existing makefile, and an existing makefile is only replaced if
  108.     the new version is different.
  109.     
  110.     The generated makefile can be automatically run after it is
  111.     created - this facility is used by the Obey scripts.
  112.  
  113.  
  114.  
  115. Makatic scripts
  116. ———————————————
  117.  
  118.     Makatic.Small
  119.     ¨¨¨¨¨¨¨¨¨¨¨¨¨
  120.         Builds small projects with a single output file.
  121.     
  122.     Makatic.Medium
  123.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  124.         This handles more complicated projects which can be 
  125.         built in different ways, by sending different flags to 
  126.         cc and link. Each different build is put in its own 
  127.         subdirectory within the project directory.
  128.     
  129.     Makatic.Large
  130.     ¨¨¨¨¨¨¨¨¨¨¨¨¨    
  131.         This is similar to 'Makatic.Medium' except that it 
  132.         automatically deals with source files nested to any 
  133.         depth within the project directory, allowing the use
  134.         of directories to partition source code.
  135.     
  136.     
  137.     
  138.     Notes on using <Obey$Dir>
  139.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  140.     
  141.         All three scripts require the project directory to 
  142.         passed as the first parameter. This causes a small 
  143.         problem if you pass <Obey$Dir> as this parameter, 
  144.         because the scripts are Obey file themselves. This 
  145.         means that by the time the script starts, <Obey$Dir> 
  146.         will be incorrectly set to the Makatic tools directory.
  147.         
  148.         The example projects avoid this problem by setting a 
  149.         temporary CSD with Acorn's Prefix command, and passing 
  150.         '@' to the makatic script.
  151.         
  152.         An alternative would be to force the <Obey$Dir> to be 
  153.         expanded before the Makatic script is called. One way 
  154.         of doing this is as follows:
  155.         
  156.         1.    Put the following in your !Boot file:
  157.                 Set Alias$Do Set Alias$Do2 %%*0 |m Do2 |mUnset Alias$Do2
  158.         
  159.         2.    Call Makatic scripts from an Obey file within 
  160.             the project directory with: 
  161.                 Do Makatic.Small <Obey$Dir>
  162.  
  163.  
  164.  
  165. Example projects
  166. ————————————————
  167.  
  168.     In 'Makatic.Examples.' are three example project-types, which 
  169.     use the three Obey scripts 'Makatic.Small', 'Makatic.Medium' 
  170.     and 'Makatic.Large'. These have all been written for use with 
  171.     Acorn's compiler, linker and AMU tool. 
  172.     
  173.     The Makatic scripts instruct Makatic2 to look for c., c++. and
  174.     s. source code, and the template makefiles have rules for
  175.     assembling .s and compiling .c++ files, but only .c code is
  176.     present in these examples, apart from Examples.Large++.
  177.     
  178.     Apart from the directory structure and source code, each 
  179.     project contains one or more very simple TaskObey files which 
  180.     build the project by calling one of the Makatic tools. All 
  181.     other files and directories required are automatically created
  182.     by Makatic.
  183.     
  184.     
  185.     Examples.Small
  186.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  187.         This is a simple 'Hello World' C project.
  188.         
  189.         Double-clicking 'MakeIt' builds the !RunImage in a 
  190.         taskwindow.
  191.     
  192.     
  193.     Examples.Medium
  194.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  195.         This is similar, except that different versions of the 
  196.         program can be built from the same source-code. 
  197.         '!Debug.!Run' and '!Normal.!Run' build the two 
  198.         versions.
  199.         
  200.         The .o and !RunImage files are built within 
  201.         '!Normal' and '!Debug'.
  202.     
  203.     
  204.     Examples.Large
  205.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  206.         This has an additional feature - source code can be 
  207.         anywhere within the 'Sources.' directory, in 
  208.         arbitrarily-deep subdirectories. This allows one to 
  209.         (for example) group related source files together in
  210.         a directory, and also to get around RISC OS's 77 file 
  211.         directory limit.
  212.         
  213.         As with 'Examples.Medium', '!Debug.!Run' and 
  214.         '!Normal.!Run' build the two versions of the project.
  215.     
  216.     
  217.     Examples.Large++
  218.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  219.         This is similar to Examples.Large, except that it uses a
  220.         both c++ and c source files.
  221.         
  222.         It also overcomes a bug in Acorn's c++ compiler 3.1 [May
  223.         25 1995] which means that the compiler always outputs to
  224.         'o.<input leafname>', ignoring any '-o <output file>'
  225.         parameter, and also uses the incorrect .o filename in
  226.         any !Depend file.
  227.         
  228.         This is done by replacing the call to c++ with a call to
  229.         'Makatic._C++'. See 'Problems' below.
  230.         
  231.         Note that there is an empty .o directory ready for c++'s
  232.         incorrect output file.
  233.     
  234.     
  235.     Examples.TestLib
  236.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  237.         This is an extremely simple C library, with a factorial
  238.         function. There are two different builds of the    library.
  239.  
  240.  
  241.  
  242.  
  243. Projects with sub-makefiles
  244. ———————————————————————————
  245.  
  246.     The script file 'Makatic.MultiBuild' handles large projects 
  247.     such as DeskLib which consist of sub-projects containing their 
  248.     own makefile.
  249.     
  250.     Unlike the other script files, there isn't an example of such a 
  251.     project in the Makatic distribution. Here is a brief 
  252.     description of the required directory structure:
  253.     
  254.     Project.
  255.         Libraries.
  256.             <sublib name>.
  257.                 c.
  258.                 c++.
  259.                 s.
  260.                 
  261.                 Automatically added by 
  262.                 'Makatic.MultiBuild <build type>':
  263.                 <build type>.
  264.                     o.
  265.                     Makefile
  266.         
  267.         <build type>.
  268.             TemplateMF    Template makefile for 
  269.                     sublibraries.
  270.             
  271.             TempalteAl    Template makefile for whole 
  272.                     library.
  273.             
  274.             All        Made by 'Makatic.MultiBuild 
  275.                     <build type>'.
  276.     
  277.     
  278.     If you are interested in using 'Makatic.MultiBuild', you will 
  279.     need to write two template makefiles for each build-type. 
  280.     TemplateMF is similar to the template used in Examples.Medium 
  281.     except that it doesn't have to link the .o files together, 
  282.     while 'TemplateAl' should use LibFile to join all the .o files 
  283.     together.
  284.     
  285.     I will be shortly releasing a preliminary version of my School 
  286.     RISC OS class-library which will show how to use 
  287.     'Makatic.MultiBuild'. Future releases of DeskLib are also likely
  288.     to use Makatic.
  289.  
  290.  
  291.  
  292.  
  293.  
  294. Files in the Makatic directory
  295. ——————————————————————————————
  296.  
  297.  
  298. Makatic.
  299.  
  300.         Tools and scripts
  301.         ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  302.         
  303.     Makatic2    General tool for constructing makefiles from 
  304.             template files and running the resulting
  305.             makefile.
  306.     
  307.     Small        Obey-file frontend for Makatic for use with 
  308.             very simple projects.
  309.     
  310.     Medium        Obey-file frontend for Makatic for use with 
  311.             projects which can be built in different ways.
  312.     
  313.     Large        Obey-file frontend for Makatic for use with 
  314.             large projects whose source code is arranged 
  315.             in a tree of directories.
  316.     
  317.     MultiBuild    Completely (re)builds a multi-sublibrary 
  318.             project.
  319.         
  320.     MultiLink    Used by MultiBuild to create the final library 
  321.             from all the .o files. Quicker than MultiBuild 
  322.             if no re-compilation is needed.
  323.     
  324.     MultiMFs    Remakes all makefiles for a multi-sublibrary
  325.             project, but doesn't run them.
  326.         
  327.     _EnsureDir    Used internally by MultiBuild and MultiLink.
  328.     
  329.     _C++        Wrapper for c++, to enable bug-fix to Acorn c++.
  330.     
  331.     Every2        Tool used by Multi* scripts. Runs a specified
  332.             command on all files matching a wild-carded
  333.             specification.
  334.     
  335.     
  336.         Documentation and examples
  337.         ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  338.     Docs.
  339.     
  340.         
  341.         
  342.         !Help        This file.
  343.         
  344.         History        History of Makatic.
  345.         
  346.         
  347.         
  348.         Examples.    Example projects using the Makatic 
  349.                 system.
  350.             
  351.             
  352.             Small.        'Hello World' C program.
  353.             
  354.                 MakeIt        TaskObey file which 
  355.                         builds the program.
  356.                 
  357.                 TemplateMF    Template makefile.
  358.             
  359.             
  360.             Medium.        'Hello World' with different 
  361.                     versions built from the same 
  362.                     source code using different 
  363.                     pre-processor #defines.
  364.                 
  365.                 !Debug.
  366.                     !Run    Builds debug-version
  367.                 
  368.                 !Normal
  369.                     !Run    Builds normal version.
  370.                 
  371.                 TemplateMF    Template makefile.
  372.             
  373.             
  374.             Large.        'Hello World' with different 
  375.                     builds, and demonstrating the 
  376.                     use of different subdirectories 
  377.                     for source code.
  378.                 
  379.                 Sources.    All source code, in 
  380.                         arbitrary 
  381.                         sub-directories.
  382.                 
  383.                 !Normal        Builds normal version.
  384.                 !Debug        Builds debug version.
  385.                     
  386.                     Sources.    Automatically-
  387.                             created 
  388.                             duplicate of 
  389.                             'Large.Sources.'
  390.                             tree, for 
  391.                             compiled .o 
  392.                             files.
  393.                 
  394.                 TemplateMF    Template makefile.
  395.             
  396.             
  397.             Large++.    As 'Large', but with c/c++
  398.                     source code.
  399.                 
  400.                 TemplateMF    Template makefile with
  401.                         a hack to get around
  402.                         a bug in Acorn's c++.
  403.                 
  404.                 !Normal.o    Directory for
  405.                         erroneously-placed
  406.                         files from c++.
  407.                 
  408.                 !Debug.o    Directory for
  409.                         erroneously-placed
  410.                         files from c++.
  411.             
  412.             TestLib.    Example C library with two
  413.                     different builds.
  414.  
  415.  
  416.  
  417.  
  418.  
  419. Motivation for Makatic
  420. ——————————————————————
  421.  
  422.     After finding that Acorn's !Make program didn't support 
  423.     building different versions of a project from the same source 
  424.     code, and was generally a pain to use, I used hand-written 
  425.     makefiles for all my projects.
  426.     
  427.     When I became the moderator of DeskLib, the need for a way of 
  428.     automating the generation of makefiles became apparent, so 
  429.     the first version of Makatic was written. This was included in 
  430.     DeskLib 2.30 .
  431.     
  432.     The much improved 'Makatic.Makatic2' was written so that many 
  433.     different types of projects could be supported. In particular, 
  434.     'Makatic.Large++' is a great help for everyday project 
  435.     management.
  436.  
  437.  
  438.  
  439.  
  440. Problems
  441. ————————
  442.  
  443.     Problems with ImageFSFix
  444.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  445.         There seems to be a bug in the ImageFSFix module used by
  446.         ArcFS, which breaks the system-call OS_GBPB (which
  447.         returns the files within a directory) when it is called
  448.         for a non-existent directory (if you're interested, when
  449.         ImageFSFix is present and the call is used for a
  450.         non-existant directory, it doesn't return an error, so
  451.         programs which use it treat the returned block as
  452.         containing data when, in fact, it contains garbage).
  453.         
  454.         The Makatic scripts instruct Makatic.Makatic2 to look
  455.         inside .c, .s and .c++ directories for source files, so
  456.         they used to crash with an address exception (or
  457.         similar) if these directories aren't present and
  458.         ImageFSFix is running. 
  459.         
  460.         I think I've managed to add a fix to Makatic2 which
  461.         works around the problem but, if you still have problems
  462.         problems, try putting empty .s and .c++ directories in
  463.         your project directory.
  464.         
  465.         Please let me know if you have this problem.
  466.         
  467.     
  468.     
  469.     Problems with Acorn's C++ compiler
  470.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  471.         
  472.         There is a bug in Acorn's C++ compiler 3.1 [May 25 1995]
  473.         which means that the compiler always outputs to
  474.         'o.<input leafname>', ignoring any '-o <output file>'
  475.         parameter.
  476.         
  477.         A second (probably related) problem is that any !Depend
  478.         file generated by Acorn's c++ contains the incorrect 
  479.         o.<input leafname> filename.
  480.         
  481.         These problems can be worked around using the tool
  482.         'Makatic._C++', as in 'Examples.Large++', and including
  483.         an empty .o directory for the incorrectly names .o
  484.         files.
  485.         
  486.         This is done by replacing the call to c++ with a call to
  487.         'Makatic._C++', using with the full c++ command
  488.         (including the 'c++ ' at the start) as parameters.
  489.         
  490.         'Makatic._C++' calls c++ first. When C++ returns,
  491.         'Makatic._C++' moves the .o file to the correct place, 
  492.         and any !Depend file is altered to contain the correct 
  493.         .o filename.
  494.         
  495.         See 'Docs.Examples.Large++.TemplateMF' to see this in
  496.         action.
  497.         
  498.         'Makatic._C++' is based on a program written by Mark
  499.         Seaborn.
  500.         
  501.     
  502.     Thanks go to Mark Seaborn for telling me about both of these
  503.     problems, and supplying code to fix things.
  504.     
  505.     
  506.     Problems with Wimpslot size and Acorn C++
  507.     ¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨¨
  508.         
  509.         If a RISC OS program is started with an insufficient
  510.         Wimpslot, all sorts of bizarre errors can occur, such as
  511.         'Not enough memory to load shared C library', or plain
  512.         crashing of the application. This can happen even when
  513.         there is a large amount of free memory available,
  514.         because the problem occurs before the application has
  515.         started up properly. 
  516.         
  517.         The Makatic scripts all set a Wimpslot of 640k, which I
  518.         have found sufficient for nearly all cases.
  519.         
  520.         However, when using Acorn's C++ compiler, 640k is not
  521.         always enough. I think this is because of the way in
  522.         which c++ calls CFront and cc as child tasks, which
  523.         means that CFront and cc are started in an environment
  524.         which may not have a large amount of free memory
  525.         available initially (I assume c++ uses the ANSI C
  526.         'system()' function for this; Makatic._C++ certainly
  527.         does). 
  528.         
  529.         The problem is compounded by the use of 'Makatic._C++',
  530.         because this makes c++ itself a child process to be
  531.         started up in what is left of the initial wimpslot after
  532.         'Makatic._C++' has been loaded.
  533.         
  534.         If you have problems, I suggest you set a large Wimpslot
  535.         (eg 1000k) before using Makatic with c++. The TaskObey
  536.         files used to make the example project in
  537.         'Makatic.Docs.Examplesd.Large++.' do this already.
  538.  
  539.  
  540.  
  541.  
  542. And finally...
  543. ——————————————
  544.  
  545.     The contents of the Makatic directory are Freeware and 
  546.     Copyright Julian Smith 1996. They may not be used in connection
  547.     with any profit-making activity without my prior permission.
  548.     
  549.     I hope you find Makatic a useful set of tools.
  550.     
  551.     If you have any comments or suggestions about Makatic, I'd be 
  552.     very pleased to hear about them. I can be contacted at the address 
  553.     below
  554.  
  555.  
  556.  
  557. - Julian Smith
  558.  
  559.  
  560.  ---------------------------------------------------------------------------
  561.  Julian Smith                              Dept of Experimental Psychology
  562.  julian.smith@psy.ox.ac.uk                 South Parks Road, Oxford, OX1 3UD
  563.  http://cogsci1.psych.ox.ac.uk/~julians/   UK
  564.  ---------------------------------------------------------------------------
  565.