Hi,
I got a following Make file. Could anyone give me a hint of what
COMPILEDIRS = $(SUBDIRS:=.compile)
means ? Does it replace all subdirs with .compile ???
Many thanks.
Anh
Code:
# Source, Executable, Includes, Library Defines
INCL = trees.h
SRCDIR= src
LIBDIR = lib
INCDIR = include
# Compiler, Linker Defines
CC = gcc
CFLAGS = -Wall
# make sure all variables are exported to sub-makes
export
# subdirectories to be built
SUBDIRS = $(SRCDIR) $(LIBDIR)
# path definitions
prefix = /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
# installation programs
INSTALL = /usr/bin/install
INSTALL_PROGRAM = $(INSTALL)
INSTALL_DATA = $(INSTALL) -m 644
# build everything recursively
all: srcdirs
COMPILEDIRS = $(SUBDIRS:=.compile)
.PHONY: srcdirs $(COMPILEDIRS)
# must build library first
src.compile: lib.compile
srcdirs: $(COMPILEDIRS)
$(COMPILEDIRS):
$(MAKE) -C $(@:.compile=) all
# install everything in the right place - again done recursively
install: installdirs
INSTALLDIRS = $(SUBDIRS:=.install)
.PHONY: installdirs $(INSTALLDIRS)
installdirs: $(INSTALLDIRS)
$(INSTALLDIRS): all
$(MAKE) -C $(@:.install=) install
# clear up after build
.PHONY: clean
clean:
(cd $(SRCDIR) ; $(MAKE) clean )
(cd $(LIBDIR) ; $(MAKE) clean )
</code>