Makegen
 Building multi-file projects with Bcc55 

Makegen speeds-up program development for DOS/Windows with the free Borland C/C++ compiler 5.5 and commandline tools.

Program Description

Makegen (for Bcc55) is a free interactive DOS program (a Blue-Screen program). Its purpose is to generate makefiles compatible with the free Borland C/C++ compiler.

 Click on image to view a screen dump.

(The compiler can be downloaded from http://www.inprise.com/bcppbuilder/freecompiler/).

Once a makefile has been generated, calling the Borland "make" program included with the compiler is all that is needed in order to compile the source code, link the resulting object files with the Borland libraries, and generate an executable (.exe) or a library (.dll).

(Note that commercial "Integrated Development Environments" -IDE for short-, like Borland C++ builder, include the equivalent of  makegen for building software projects.)

Legalities

Makegen is a public-domain program (this means it's free and you can modify it and redistribute it as you wish). Its source code is also available and is in the public domain. There is no guarantee whatsoever as to the suitability of purpose of the program or its source code. Use at your own risk.

Download Makegen Binary and Source
The makegen executable can be downloaded here  (Version 1.02, August 2001 - size 87040 bytes, compressed.)
The corresponding C++ source code can be downloaded here  - It is a self-extracting executable (75KB).

If you ever modify makegen and produce a useful variant, please tell us. We, or others, may use it.


Background Information

Makefiles

When a software project is composed of several files (the general case), the compilation and linking process is usually controlled by a utility called "make".

"make" reads a special file called a "makefile" to determine what source files it needs to compile and link, and what software libraries it needs to use in order to complete the project. 

It is possible to write a makefile manually using a text editor, and this is indeed what most programmers who work on large programs do. However, this requires a fair amount of knowledge, and is tedious if you have to do it repeatedly for small to medium-sized programs.


Make

The make utility distributed by Borland requires a special makefile syntax. You can learn about it by downloading the free command-line tools help from the Borland web site and studying the information in the help section on "make". There are some examples of use of the Borland make on the very informative Pharo web site:
http://www.pharo.onlinehome.de/Bcc55.html
and on the quite useful Bcc55 "webnotes" tutorial page at:
http://www.webnotes.org/bcc55eng.htm.


Makegen Capabilities and Limitations

Capabilities

If you are going to write many small or medium-sized projects, you will need many Makefiles. The "makegen" utility has been created to simplify the work of creating Borland Makefiles. Originally it was intended to simplify the work of students of C and C++, so as to let them concentrate on the difficulties of the language instead, but it can be used by anyone.

- Makegen is suitable for building DOS console programs or Windows programs.
- The end result of a build can be an executable (.exe) or dynamically linked libraries (.dll).
- Programs can use either the static Borland libraries or the dynamic libraries.
- The programmer can control the level of warnings output during compilation.
- Any number of extra library or include directories, of compilation or linking flags, of Windows resources, of object files or of libraries can be specified.
- Makegen automatically includes your source files into the project, and intelligently selects a name for your program (in that it is easier and quicker to use than commercial IDEs!). You can over-ride its decisions manually.
- Makegen is itself a Win32 DOS console program, written with the Bcc55 free command-line tools. It can be invoked from the DOS command-line, but it can be more useful when integrated within the tools of a programmer's editor, when it can be invoked with a click of the mouse.

Note: Makegen has been used in a university environment where it is integrated with the free programmer's editor JFE (see below). In that educational environment it has proved very useful.

Limitations

- Makegen is really only suitable for small to medium-sized projects. A major restriction is that all the project source files are to be located in a single directory.

- Another limitation is that each makefile written by Makegen can generate only one main target (executable or DLL). Although you can have different makefiles in the same directory for different targets.

These limitations will only affect a very small number of users (most commercial IDEs suffer from the same limitations).

Note: When you reach the point where your projects are large enough to require different sections to be located into different directories, and all sections built at once from a single makefile, then it is worth getting the extra level of control that you can gain by learning how to write makefiles manually.


Using Makegen

Installation

1- "Makegen.exe" should be located in the Borland compiler "Bin" directory, for example C:\Borland\Bcc55\Bin.

2- It should be run from the directory where the project C/C++ source files are located.

You can call "makegen /?" at the DOS prompt from a project directory to check that the program is properly installed (It prints a brief help message and its version number).


Usage

- Call "makegen" at the DOS prompt...
The blue "Options" screen of Makegen appears.

If you just press [Enter] at this point. Makegen automatically creates a valid Borland makefile for you.

Makegen builds makefiles with the following defaults:
 - It includes all the ".c" and ".cpp" files in the current directory as part of your project.

 - It also assumes that the name of the executable is to be the name of the source file that contains the "main()" function (or "WinMain()", etc.. for Windows programs), and simply replaces the ".c" or ".cpp" extension, with ".exe" to obtain the name of the executable. If the file with "main()" is not there yet, it'll use the directory name.

- It assumes that you want to compile a DOS console application rather than a Windows program.

- It places all the output files into the current directory.

- It links the produced executable with the Borland static libraries (rather than the dynamic libraries).

- It writes a makefile called "makefile.b" into the current directory.

-------------

If you are satisfied with the makegen defaults, just press [Enter]. The project file is written and the makefile "makefile.b" is written. All you have to do now is to enter:
    make -fmakefile.b
at the DOS prompt. }
All the files in your program that need to be recompiled (because they have changed) will be automatically compiled, and your program will be linked.


Selecting Options:

- If you are not happy with the makefile produced with the defaults, makegen allows you to modify these defaults. Makegen stores your chosen project configuration into a project configuration file "Project.gen" in the current directory. The next time you open Makegen in this directory, Makegen will retrieve the saved configuration.

The options you are most likely to want to change appear first in the following list:

Console:    (ON by default). A DOS console program will be built. Turn it OFF if you are writing a Windows GUI program.

Dynamic:   (OFF by default). Your program will used the Borland static library (and be much larger). If you turn it ON, your program will load the dynamic libraries at run-time. Your executable file will be MUCH! smaller, but then the Borland runtime dynamic libraries (in the compiler "Bin" directory) must be on the Windows path, otherwise users of your program will receive an error message.

Warnings:  WarnHigh will print more warnings when ON, WarnLow will print fewer warnings when ON, and NoWarn will print no warnings at all. There are few good reasons to change from the default setup (all OFF) when all important warning are displayed anyway. Using  the NoWarn setting would be foolhardy.

ANSI:         (Default OFF) is more meaningful for C programming than C++. If you turn it ON you will not be able to use Borland proprietary language features (like conio.h). This can be useful to check that you C code follows the ANSI C standards and is portable to other compilers.

Debug:        (ON by default). This enables the use of the Turbo debugger TD32 that Borland/Inprise provide for free on their web site. When OFF, compiling is a little faster and the ".tds" (Turbo Debugger Symbols) temporary file is not generated. There is little if any gain in the size of the executable produced when Debug is OFF (on the opposite, some executables are much smaller when Debug is ON than when it is OFF -which does not seem to make sense?!?). Try it for yourself.

Optimise:    (OFF by default) When it is ON, it sometimes makes debugging more difficult, but it reduces the size of the executable produced by your program, and speeds it a little.

SpeedOpt:  (OFF by default) When it is ON, optimisation trade-offs favour speed over size. It is worth turning it ON for those programs where performance is essential. Of course, it does not make sense having this ON when "Optimise" is OFF.

Pentium:     (OFF by default). When it is ON, Pentium processor instructions are generated, which can speed up your program on PCs equiped with Pentium processors or later. It would markedly slow down your program on 486 computers however. It's up to you to choose to ignore those people still running 486s or not. . . Personally I would not; in some countries 486s are still quite common.

DLL:          (OFF by default). Turn it ON to produce your own dynamically-linked-library (DLL).

MultiThread: (OFF by default) You'll have to turn it ON to produce a multi-threaded program.

Add Compile Flags: . . .
Add Link Flags:
      For advanced users: if  makegen does not give you sufficient control on your builds, select the relevant entry, and type in extra flags. Those extra flags will be passed on to the compiler/linker. You can see what flags are already passed on to the compiler and linker by makegen by opening the project file (Project.gen), a plain ASCII text file. The available flags are listed in the Borland help for the free command-line tools.


Selecting Project Files:

You will quite frequently have in your directory C or C++ source files that do not belong to your project. In the makegen "options screen", press the right arrow key [->]. This will take you to the "Project files" list. There you can remove from the project or include into it any source file in the directory. All the C and C++ source files in the directory are shown (not the header (.h) files which are only compiled when they are #include-d into ".c" or ".cpp" files).

On that screen you can also see the name of the current directory. It is amazing how many times I have discovered that I was inadvertently editing a project in the wrong directory...
                                                                                          OOoops!..


The Advanced Screen:

If you press once more onto the right arrow key [->], you will reach the deepest and darkest makegen screen.

There you can specify extra directories where the compiler should search for header files, or where the linker should be looking for libraries.
You can specify extra software libraries that the linker should link your program with.
Extra object files that the linker should be also looking for can also be mentioned there.
Windows programmers can also specify compiled resource (.res) files.

All of this will be correctly passed on by makegen to the relevant Borland commandline tool during compilation or linking.

On this screen advanced users weave their strange abra-cadabra. Leave this dark corner of makegen well alone until you understand about libraries and resources. Only extremely occasionally will you have to type in something into one of these mysterious fields.


Makegen Output

Within any of the makegen screens, press [Enter].
The project file (Project.gen by default) is saved, the makefile (Makefile.b by default) is written.

Enter "make -fmakefile.b" at the DOS prompt to build your project.

Cleaning up the Project Directory

The process of compilation and linking leaves many temporary files behind.
Traditionally makefiles have a special target called "clean" such that if you call "make clean",
the temporary files left behind by your compiler are deleted.

The makefiles generated by makegen have the same facility, except that they call a special interactive cleaning program (Bclean.exe, another public-domain blue-screen program) that gives you better control as to what exactly gets deleted. Bclean is not specially written for Bcc55, but it works nicely with it.

If you want to enable the "clean" target of your makefiles, or simply call the "Bclean" program directly from the command line, download it from here  

Integrating Makegen into an Editor

There are a number of programmer's editor out there that could easily call Makegen at the click of a button, and therefore instantly become near complete IDEs for Bcc55.

One of them is already being used for that purpose. It is Jens Altmann's excellent free Programmer's editor JFE, that you can download (in German or in English) from
http://home.t-online.de/home/Jens.Altmann/jfe.htm

To integrate makegen and Bclean into the JFE editor (assuming that the three programs are installed and working on your computer), download the following "jfe.ini" file, unzip it into the same directory as "jfe.exe".

When you open a file into JFE, a number of buttons pop up and convert JFE into a very nice environment for Bcc55 programming.


Modified: August 2001   Maintained by: cutter@codecutter.net