01.09.2014 Views

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

The Linux Development Platform Configuring, Using, and ... - Classes

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CH04.fm Page 127 Monday, October 7, 2002 8:54 PM<br />

Working with Multiple Makefiles <strong>and</strong> Directories 127<br />

4.4.4 Makefile in the tftp-dir Directory<br />

<strong>The</strong> makefile in the tftp-dir directory builds the tftp target. It compiles <strong>and</strong> then<br />

statically links the object files using the library we built in the common-dir directory. This<br />

makefile is shown below. It also has rules to install the target <strong>and</strong> clean the directory.<br />

# Variable definition<br />

SRCS = tftp.c<br />

OBJS = tftp.o<br />

HDRS = tftp.h<br />

CC = gcc<br />

CFLAGS = -g -O2 -c<br />

INCLUDES = -I../common-dir<br />

LIBSDIR = ../common-dir<br />

LDFLAGS = -static -L$(LIBSDIR)<br />

INSTALLDIR = /root<br />

# Default Target<br />

tftp: $(SRCS) $(HDRS)<br />

$(CC) $(CFLAGS) $(INCLUDES) tftp.c<br />

$(CC) $(LDFLAGS) $(COMMON) $(OBJS) -lcommon -o tftp<br />

install:<br />

cp tftp $(INSTALLDIR)<br />

clean:<br />

@echo "Deleting files ..."<br />

rm -f tftp $(OBJS) *~<br />

4.4.5 Makefile in the dns-dir Directory<br />

<strong>The</strong> makefile in the dns-dir directory builds the dnsresolver target. It compiles <strong>and</strong><br />

then statically links the object files using the library we built in the common-dir directory.<br />

This makefile is shown below.<br />

# Variable definition<br />

SRCS = dnsresolver.c<br />

OBJS = dnsresolver.o<br />

HDRS = dnsresolver.h<br />

CC = gcc<br />

CFLAGS = -g -O2 -c<br />

INCLUDES = -I../common-dir<br />

LIBSDIR = ../common-dir<br />

LDFLAGS = -static -L$(LIBSDIR)<br />

INSTALLDIR = /root

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!