With the build environment, you just type "make." Now you create a new header file, say Foo.h, and you change one of your project's other source files, say Bar.cpp, to include Foo.h. You type "make" again, and make will recompile Bar.cpp and all other sources that might include Bar.cpp. Now you change Foo.h and type "make" yet again. make will recompile Bar.cpp and all other sources depending on it.
PACKAGES = FLTK GLThis list of packages will be applied to all targets; you can augment or redefine the package list on a per-target basis if required.
...
########################################################################
# Specify build rules for executables
########################################################################
# These are all the source files that need to be *linked* into
# the "Main" executable:
MAIN_SOURCES = Source1.cpp \
Source2.cpp \
Source3.cpp \
... \
SourceN.cpp
# ... or, to just use *all* sources found in the project directory
# and all its subdirectories:
MAIN_SOURCES = $(shell find --follow . -name "*.cpp")
# Set up a target for the "Main" executable with a list of
# object files it depends on:
$(EXEDIR)/Main: $(MAIN_SOURCES:%.cpp=$(OBJDIR)/%.o)
# Note: No actual linker command line required!
# Set up a phony target to allow typing "make Main" for building
# the "Main" executable:
.PHONY: Main
Main: $(EXEDIR)/Main
...
... ALL = $(EXEDIR)/Main ...(Use the full $(EXEDIR)/Main target to ensure that it will be deleted on a "make clean".)
Of course, this is the simplest possible setup. A project directory can contain any number of executable targets, libraries, shared libraries, etc. Parameters and flags can be overriden on a per-target basis, this includes per-executable-target override and per-objectfile-target override. Say that the Main executable uses the pthreads library. You can tell the compiler and linker where to find the library by adding a per-target parameter (before the other lines regarding target Main):
$(EXEDIR)/Main: PACKAGES += PTHREADS