Section 11.3: Converting old makefiles Up Chapter 11: amake Chapter 12: A4GL Utilities 

11.4 2. amake

amake # build default targets of all .mk files in ./
amake -k -all install # install all programs, ignore errors
amake P11 aubit -k # build aubit target defined in, ignore errors
amake P11 aubit -defaultinclude# build P11 target for Aubit compiler, use includes defined in P11
amake P11 -header # default P11 target, use for header
amake --help for full lost of flags and parameters.

11.4.1 Requests

Tell me if it’s useful for you, if you need help, explanations, changes... If you make generally useful changes, I would like if you send them back to me. Latest version of these files will always available through Aubit 4gl CVS

11.4.2 Notes

11.4.3 Installation

(don’t forget to convert back to UNIX file format if you are receiving this on Windows box; needless to say, scripts will need "chmod a+x")
These two should go somewhere in the path, but will probably be used only once:
prepmake - sh script to prepare original make file, created makefile.prep
genmake - sh script called from prepared makefile to create individual make files
Header will probably be most useful in your program directory, since it can contain module specific definitions, but one copy of general type should also probably be in /etc or /usr/incl:
header.mki - make file for including from each individual make file. It in turn includes and by default.
The Following files are supposed to be completely abstracted, so in /etc or /usr/include they go:
footer.mki - make targets definitions included from each individual makefile. - rules for compiling using Aubit 4gl compiler - rules for compiling using classic Informix 4gl compiler - rules for compiling using 4Js (Informix D4GL) 4gl compiler - rules for compiling using Querix 4gl compiler
And finally, this one should be in the path, probably in /bin:
amake - sh script used for executing make process, instead of the make command

11.4.4 Credits:

Thanks to Jonathan Leffler for Informix-4gl and 4Js rules, and general concept of how 4gl program should be processed by make.

11.4.5 #DEFINE

Note about using #DEFINE-style constructs, like C. There’s nothing built into 4GL, but many people use the Unix "M4" command successfully. You could also use "cpp".
Stuart Kemp (
To use the C preprocessor (cpp) in conjunction with GNU make you might use a suffix of ".cpp" on the files you edit, and then build a Makefile containing:
.SUFFIXES: .4gi .4go .4gl .cpp .frm .per .cpp.4gl:
@echo Make $@ from $< $(CPPDEFS)
@$(CPP) $(CPPDEFS) $< > $@
@echo Make $@ from $<
@form4gl -s $<
@fglpc $<

Of course, the downside of this is that if you get an error-message when running your .4g[io] program, the line-number will be that in the .4gl file, not the .cpp file.

11.4.6 4GL Makefiles

There are no standard rules for how to organize Makefiles for 4gl. This note attempts to repair this deficiency for both Unix and NT systems. Makefiles for Classic 4GL on Unix

Assuming that your version of MAKE understands the ’include’ directive, a typical makefile will look rather like the file described earlier in thisdoccument. If your MAKE does not understand the ’include’ directive, the simplest solution is to obtain a version of MAKE which does understand them.
One such MAKE is GNU Make, which is widely available on the Internet. See The GNU Project and the Free Software Foundation (FSF) for more information.
The rules file ’’ is located in some convenient directory. In the example, $HOME/etc is used, but a centralized location such as $AUBITDIR/incl, $INFORMIXDIR/etc or $FGLDIR/etc is a reasonable choice. Note that either the curly brackets or parentheses are required around the name of the environment variable in the makefile.
The macros list the components of the program, and the definitions of the lists avoid replicating names as much as possible, so that if a file is added, deleted or renamed, only one line in the makefile needs to be changed.
Note too that the current versions of and automatically provide definitions for the majority of the derived files, so the makefile itself does not have to define macros such as FILES.o or FILES.4ec. It must, however, define FILES.4gl for the I4GL source files, FILES.per for the form source files, and FILES.msg for the help source files, since these macros are used to define the other macros.
This makefile uses the ’standard’ install script for Unix, and that means it can only install a single file at a time (an silly design decision, but one which was made so long ago that it cannot readily be changed). Consequently, we have to iterate over the list of form files. If there was more than one message file, we’d need to do the same for the message files.
The hard work in this makefile is the install and clean process. The actual compilation rules are minimal, occupying just six non-blank lines. There are some standard targets which are desirable in most makefiles. These include all to build everything that is needed by default, install to put the software in a location where it can be used, and clean to remove the debris from the development process.
As another pseudo-standard, if you are working with both Classic 4GL and Dynamic 4GL, or if you are using both p-code and c-code, it helps to standardize on some extra names. The makefiles illustrated here use:
These makefiles can also builds the custom I4GL p-code runner that is needed to run the program.

11.4.7 D4GL Makefiles on Unix

The rules for compiling D4GL are similar to the rules for compiling I4GL, but they use a different set of suffixes.
The first target in the makefile is ’default’, and is what will be built if you simply type "make -f d4glonly.make". It is set up to build just the D4GL p-code program; to build the c-code program too, you have to specify "all" or "d4gl-ccode" on the command line.
This makefile builds a custom runner for D4GL because the code uses some C code. When you need a D4GL custom runner, you have to link with it too, so you have to build the custom runner before you try linking the program, and the dependencies ensure this happens automatically.
The rest of the makefile follows the pattern in the I4GL version, with the changes appropriate to handling D4GL instead of I4GL. I4GL Makefiles on Unix

The actual rules for compiling Informix Classic 4GL are defined in the file . There are a number of key things to note about them. NMAKE

If you have Microsoft Visual Studio or Microsoft Visual C++ on your NT machine, you will have the NMAKE program available to you. You can use Makefiles patterned on the one shown below (from the D4GLDEMO program). Note that both the rules and the makefiles are much simpler on NT than on Unix because Classic 4GL is not available on NT, and neither is the Dynamic 4GL c-code compiler.
Some of the significant differences between MAKE on Unix and NMAKE on NT are:
Prepared by:
Last Updated: 1999-10-08
Edited by AF

11.4.8 Bug in ESQL/C rules:

Compiling ESQL/C code did not work because of macro name mismatches.
Specifically, there’s a line that defines ESQL = ${ESQL_EC_ENV} ${ESQL_EC_CMD} ${ESQL_EC_FLAGS} but the corresponding macros for compiling ESQL/C code use ${ESQL_EC} rather than ${ESQL}. I concluded that I meant to define ESQL_EC, not ESQL.
For Aubit 4gl team,
Andrej Falout
 Section 11.3: Converting old makefiles Up Chapter 11: amake Chapter 12: A4GL Utilities