Working with Multiple Makefiles and Directories127
4.4.4Makefile in the tftp-dir Directory
The makefile in the
tftp-dir
directory builds the
tftp
target. It compiles and then
statically links the object files using the library we built in the
common-dir
directory. This
makefile is shown below. It also has rules to install the target and clean the directory.
# Variable definition
SRCS = tftp.c
OBJS = tftp.o
HDRS = tftp.h
CC = gcc
CFLAGS = -g -O2 -c
INCLUDES = -I../common-dir
LIBSDIR = ../common-dir
LDFLAGS = -static -L$(LIBSDIR)
INSTALLDIR = /root
# Default Target
tftp: $(SRCS) $(HDRS)
$(CC) $(CFLAGS) $(INCLUDES) tftp.c
$(CC) $(LDFLAGS) $(COMMON) $(OBJS) -lcommon -o tftp
install:
cp tftp $(INSTALLDIR)
clean:
@echo "Deleting files ..."
rm -f tftp $(OBJS) *~
4.4.5Makefile in the dns-dir Directory
The makefile in the
dns-dir
directory builds the
dnsresolver
target. It compiles and
then statically links the object files using the library we built in the
common-dir
directory.
This makefile is shown below.
# Variable definition
SRCS = dnsresolver.c
OBJS = dnsresolver.o
HDRS = dnsresolver.h
CC = gcc
CFLAGS = -g -O2 -c
INCLUDES = -I../common-dir
LIBSDIR = ../common-dir
LDFLAGS = -static -L$(LIBSDIR)
INSTALLDIR = /root
Next Page >>
<< Previous Page
Back to the Table of Contents