Red Antigua Logo
Yet another piece of web.
Ads by Goooooogle
Search this site (by Google)
Tools    (top)
Your IP
Check a site for broken links
(W3C)

Perl modules    (top)
Tree::Numbered::Tools
(CPAN)
Perl tutorials    (top)
Perl modules
HTML::Template
CGI::Application
Mail::POP3Client
Mail::Send
MIME::Tools
Cookies with CGI::Application
Upload files with CGI::Application
Download files with CGI::Application
Redirect with CGI::Application
CPAN shell
Install DBD::mysql from the CPAN shell
Perl trim function
Validate an IP with Perl
Run suid Perl scripts under Apache
Perl taint mode
Perl date functions with Date::Calc

In Spanish
Curso de Perl

C tutorials    (top)
C - Introduction
C - Absolute beginner's Emacs
C - Examples for beginners
C - Makefile examples
C - Autotools examples
Server configurations    (top)
DNS
Apache
Apache Authentication and Access Control
mod_perl on FreeBSD
MySQL
MySQL add account
phpMyAdmin
Squid
DHCP

UNIX on Windows    (top)
Apache setup on Windows
MySQL setup on Windows
PHP setup on Windows
Perl setup on Windows
Emacs setup on Windows
UnxUtils
PuTTY
WinSCP
GIMP on Windows
MinGW - gcc on Windows
MSYS - UNIX-styled shell on Windows
msysDTK - autotools on Windows
GDB for MinGW on Windows

Misc. FreeBSD/UNIX    (top)
CD and DVD creation on FreeBSD using 'k3b' on FreeBSD
'portupgrade' on FreeBSD
'ipf' on FreeBSD
'pf' on FreeBSD
'su' on FreeBSD
Mount an ISO image under FreeBSD
Load the correct sound driver under FreeBSD without knowing what sound card you are using
Simultaneous sound channels on FreeBSD
FreeBSD network stuff
DOS-to-UNIX file conversion
favicon.ico on UNIX
Emacs tips
Sendmail tips
GKrellm
Command Line Calculator
Save multimedia streams with 'mplayer'
xargs - solution to 'Argument list too long'
Process multiple images from the command line using 'ImageMagick'
Turn the system bell off under X Windows
Process each line in an input file from the command line (or in a shell script)
How to keep a program running in the background using 'nohup'
How to remove symbolic links in the current directory using 'find' and 'rm'
How to remove Emacs backup files in the current directory and all subdirectories using 'find' and 'rm'
How to execute .profile without logging in
Configure X to handle non-English characters
How to move /var to /usr/var

Redirect a web page    (top)
Redirect to another web page
Apache redirect
C redirect
Perl redirect
PHP redirect
HTML redirect
JavaScript redirect

Javascript    (top)
Trim function
Login form
Register form
Popup window

Virus list    (top)
Latest 10 viruses - Sophos

Off topic    (top)
Personal home links

Print make's internal database
Print make's internal database
IndexPreviousNext
Using GNU make
Using BSD make
Using AIX make
Using GNU make top
To print GNU make's internal database:
make --print-data-base
Implicit rules are stored in the make database, so we can use the following expression to get the implicit rule for .c targets:
make --print-data-base -f /dev/null 2>/dev/null |grep -A 6 -e '^\.c:'|grep -v -e '^#'
Read the command above like this:
"Print the database, use /dev/null as (dummy) Makefile, ignore errors.
Grep the line starting with .c (the .c implicit rule), and the following 6 lines.
Ignore lines which are comments."
This will display:
.c:
        $(LINK.c) $^ $(LOADLIBES) $(LDLIBS) -o $@
In a similar manner, you can get the default variable definitions from the make database:
make --print-data-base -f /dev/null 2>/dev/null |grep -e '^LINK.c '
The result:
LINK.c = $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) $(TARGET_ARCH)

Using BSD (Berkeley) make top
To achieve the same results as above using BSD make (default make tool on FreeBSD):
Print the internal database:
make -p
Get the implicit rule for .c targets:
make -p -f /dev/null|grep -A 1 -E '^\.c '
The result:
.c              : 
        ${CC} ${CFLAGS} ${LDFLAGS} ${.IMPSRC} ${LDLIBS} -o ${.TARGET}
Get the definition (if any) for each variable in the implicit rule:
make -p -f /dev/null|grep -E '^CC|^CFLAGS|^LDFLAGS|^.IMPSRC|^LDLIBS|^.TARGET'
As we can see, not all variables are defined in the database...
LDFLAGS          = 
CFLAGS           = -O2 -fno-strict-aliasing -pipe ${_CPUCFLAGS}
CC               = cc
.TARGETS         = 
make -p -f /dev/null|grep -E '^_CPUCFLAGS'
... and other variables are empty by default:
_CPUCFLAGS       = 
Note: On FreeBSD, if you prefer GNU make, it's is available as the gmake command.

Using AIX make top
AIX make has some quirks to be aware of.
AIX make prints its database to stderr by default, and grep on AIX does not support the -B (Before) and -A (After) flags, so to display the implicit rule for .c targets we have to use the following command (tested on AIX 5.2):
make -p -f /dev/null 2>&1 |grep -p -e '^.c '|grep -v '#'
Here we see that the rule definitions also differ from GNU make:
.c              :
        $(CC) $(CFLAGS) $(LDFLAGS) $< -o $@

Exercises:
  1. Get the value for each variable in the implicit .c rule using commands similar to the one above, using GNU make.
  2. Create an empty directory. Create a simple C source file with the .c extension. Play around with variables from the command line to understand how the implicit rules and associated variables work, for example:
    make CFLAGS='-g -O2' LDFLAGS=-static your-program-without-c-extension
IndexPreviousNext
Last modified: Thu Jul 2 15:01:38 CEST 2009