source:forever.h forever.cpp(from qt/examples)
the Makefile:

CC= g++
INCL= -I$(QTDIR)/include
CFLAGS= -Wall -O
LFLAGS= -L$(QTDIR)/lib -L/usr/X11R6/lib
LIBS= -lqt -lX11

all: forever

forever: forever.o forever.moc.o
$(CC) $(LFLAGS) -o $@ $^ $(LIBS)

forever.o: forever.cpp forever.h

forever.moc.cpp: forever.h
$(QTDIR)/bin/moc forever.h -o $@

rm -f forever
rm -f *.o
rm -f .moc.cpp


$(CC) $(CFLAGS) $(INCL) -c $< -o $@

Let’s take a look at the contents of the user-provided input files that are relevant to this minimal project. Here is the `’:

bin_PROGRAMS = foonly
foonly_SOURCES = main.c foo.c foo.h nly.c scanner.l parser.y
foonly_LDADD = @LEXLIB@

This `’ specifies that we want a program called `foonly’ to be built and installed in the `bin’ directory when make install is run. The source files that are used to build `foonly’ are the C source files `main.c’, `foo.c’, `nly.c’ and `foo.h’, the lex program in `scanner.l’ and a yacc grammar in `parser.y’. This points out a particularly nice aspect about Automake: because lex and yacc both generate intermediate C programs from their input files, Automake knows how to build such intermediate files and link them into the final executable. Finally, we must remember to link a suitable lex library, if `configure’ concludes that one is needed.

And here is the `’:

dnl Process this file with autoconf to produce a configure script.
AM_INIT_AUTOMAKE(foonly, 1.0)

This `’ invokes some mandatory Autoconf and Automake initialization macros, and then calls on some Autoconf macros from the AC_PROG family to find suitable C compiler, lex, and yacc programs. Finally, the AC_OUTPUT macro is used to cause the generated `configure’ script to output a `Makefile’—but from what? It is processed from `’, which Automake produces for you based on your `’ (see section C. Generated File Dependencies).