Makefile in The Top Directory
4.4.4 Makefile 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 -LLIBSDIR 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.5 Makefile 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 -LLIBSDIR INSTALLDIR = root 128 Chapter 4 • Using GNU make Default Target dnsresolver: SRCS HDRS CC CFLAGS INCLUDES dnsresolver.c CC LDFLAGS COMMON OBJS -lcommon -o dnsresolver install: cp dnsresolver INSTALLDIR clean: echo Deleting files ... rm -f dnsresolver OBJS ~4.4.6 Building Everything
After going through these makefiles, you are ready to build the targets. Go to the top directory and run the make command from there. It will read the makefile in the top directory and will try to build all targets. A typical output of this action is as follows: [rootconformix make] make BUILDING ALL TARGETS for i in common-dir ftp-dir tftp-dir dns-dir ; do \ cd i ; make ; \ done make[1]: Entering directory `rootmakecommon-dir gcc -g -O2 -c common.c ar -cr libcommon.a common.o ranlib libcommon.a make[1]: Leaving directory `rootmakecommon-dir make[1]: Entering directory `rootmakeftp-dir gcc -g -O2 -c -I..common-dir ftp.c gcc -static -L..common-dir ftp.o -lcommon -o ftp make[1]: Leaving directory `rootmakeftp-dir make[1]: Entering directory `rootmaketftp-dir gcc -g -O2 -c -I..common-dir tftp.c gcc -static -L..common-dir tftp.o -lcommon -o tftp make[1]: Leaving directory `rootmaketftp-dir make[1]: Entering directory `rootmakedns-dir gcc -g -O2 -c -I..common-dir dnsresolver.c gcc -static -L..common-dir dnsresolver.o -lcommon -o dnsresolver make[1]: Leaving directory `rootmakedns-dir [rootconformix make] Working with Multiple Makefiles and Directories 129 During the process of building all targets, you can see how make enters and leaves each directory and builds targets in each directory.4.4.7 Cleaning Everything
The cleaning process is done the same way as we built all targets. Output of this process is shown below. Again you can see that make enters each directory, runs the make clean com- mand and then leaves the directory. The clean rule in makefiles present in each subdirectory is used to remove files. [rootconformix make] make clean rm -f ~ for i in common-dir ftp-dir tftp-dir dns-dir ; do \ cd i ; make clean ; \ done make[1]: Entering directory `rootmakecommon-dir rm -f common.o libcommon.a ~ make[1]: Leaving directory `rootmakecommon-dir make[1]: Entering directory `rootmakeftp-dir Deleting files ... rm -f ftp ftp.o ~ make[1]: Leaving directory `rootmakeftp-dir make[1]: Entering directory `rootmaketftp-dir Deleting files ... rm -f tftp tftp.o ~ make[1]: Leaving directory `rootmaketftp-dir make[1]: Entering directory `rootmakedns-dir Deleting files ... rm -f dnsresolver dnsresolver.o ~ make[1]: Leaving directory `rootmakedns-dir [rootconformix make] The make clean command finishes its operation after going through all subdirectories.4.4.8 Making Individual Targets
Instead of using a single big makefile, you can also build individual targets using smaller makefiles. While building only one target, make will go into only that directory and build that target. The following output shows the output of the make command when you build only the ftp target. [rootconformix make] make ftp make[1]: Entering directory `rootmakeftp-dir gcc -g -O2 -c -I..common-dir ftp.c gcc -static -L..common-dir ftp.o -lcommon -o ftp make[1]: Leaving directory `rootmakeftp-dir [rootconformix make]Parts
» the linux development platform 2003
» Requirement Gathering Life Cycle of a Software Development Project
» Writing Functional Specifications Life Cycle of a Software Development Project
» Creating Architecture and Design Documents
» Implementation and Coding Life Cycle of a Software Development Project
» Testing Life Cycle of a Software Development Project
» Technical documentation developed during the development process. This includes
» Technical documentation prepared for technical support staff. This includes technical
» End-user manuals and guides. This is the documentation for the end user to assist the
» Software Releases Support and New Features
» Hardware Platform Components of a Development System
» Operating System Components of a Development System
» Editors Components of a Development System
» Compilers and Assemblers Components of a Development System
» Debuggers Components of a Development System
» Version Control Systems Components of a Development System
» Selection Criteria for Hardware Platform Selection Criteria for Software Development Tools
» Creating Deadlines Managing Development Process
» Managing the Development Team
» Resolving Dependencies Managing Development Process
» Libraries Linux Development Platform Specifications LDPS and Linux
» Open Source Developers Network at http:www.osdn.org
» Extensibility What to Look for in an Editor
» References and Resources the linux development platform 2003
» Target machine. This is the machine for which the newly built compiler will generate
» Post-Installation Tasks Installing GNU Compiler
» Compiling to Intermediate Levels
» Compilation with Debug Support
» Compilation with Optimization Compiling a Program
» Compiling Source Code for Other Languages
» Linking a program Assembling a Program
» Creating Libraries the linux development platform 2003
» Standard Libraries the linux development platform 2003
» Compiling Fortran Programs the linux development platform 2003
» Smalltalk Oberon Other Compilers
» The target 2. Dependencies Basic Terminology
» The explicit rules 2. The implicit rules
» Input Files Introduction to GNU make
» Typical Contents of a Makefile
» Running make Introduction to GNU make
» Shell to Execute Commands Include Files
» The ftp server The The dnsresolver
» FTPOBJS OBJS Another Example of Makefile
» Explicit Rules The make Rules
» Implicit Rules The make Rules
» Defining Variables Types of Variables
» Pre-Defined Variables Automatic Variables
» Makefile in The Top Directory
» Makefile in common-dir Directory
» Makefile in the ftp-dir Directory
» Makefile in the tftp-dir Directory Makefile in the dns-dir Directory
» Building Everything Working with Multiple Makefiles and Directories
» The ifdef Directive Control Structures and Directives
» The ifndef Directive Control Structures and Directives
» Compilation Getting the Latest Version and Installation
» Most Commonly Used gdb Commands
» Passing Command Line Arguments to the Program Being Debugged
» The step and finish Commands
» Introduction to GDB Working with the Stack
» Displaying Program Variables Displaying Variables
» Automatic Displaying Variables with Each Command
» Displaying Environment Variables Displaying Variables
» Modifying Variables Displaying Variables
» Disabling Break Points Enabling Break Points
» Debugging Optimized Code the linux development platform 2003
» Debugging Running Processes the linux development platform 2003
» The kdbg Debugger Other Open Source Debuggers
» The ddd Debugger Other Open Source Debuggers
» The xxgdb Debugger Other Open Source Debuggers
» CVS Policies the linux development platform 2003
» Project Management and Communication
» Remote Repositories Checking out a Project
» Finding the Status of a Project
» Finding Differences Using the CVS Client
» Resolving Conflicts Using the CVS Client
» Checking the Project Back In Adding Files to a Project
» Removing Files from a Project
» Tags and Releases Using the CVS Client
» System Requirements Introduction to jCVS
» Installation Instructions Introduction to jCVS
» Using jCVS Introduction to jCVS
» Installing pcl-cvs Using Emacs with CVS
» Using pcl-cvs Using Emacs with CVS
» Have a shell account on the CVS server. 2. Create a publicprivate key pair on the client.
» Selecting Coding Styles Using indent Utility
» Formatting Braces Using indent Utility
» Formatting Declarations Using indent Utility
» Breaking Long Lines Using indent Utility
» Summary of Options Using indent Utility
» Using sed Utility Using cscope and cbrowser
» Generating C Function Prototypes from C Source Code Using cproto
» Using ltrace and strace Utilities
» Value 2. Type Name Using the nm Utility
» Using the ranlib Utility Using the strip Utility
» Using the strings Utility Using the addr2line Utility
» Host Machine Introduction to the Cross-Platform Development Process
» Target Machine Introduction to the Cross-Platform Development Process
» Cross Platform Development Cycle
» Embedded Systems and Moving Parts
» Embedded Systems and Power Consumption
» Embedded Operating Systems What are Embedded Systems?
» Knowledge of Target System Hardware
» Software Emulators Cross Compilations
» Using gdbserver with GNU Debugger
» Attaching to a Running Process Using gdbserver
» Arcom SBC-GX1 Board Hardware Used for Cross-Platform and Embedded Systems
» Artesyn PMPPC Mezzanine Card
» References the linux development platform 2003
» Java Compiler Java Virtual Machine
» Kaffe the linux development platform 2003
» The Jboss Java Development System
» Getting and Installing Java SDK from Sun Creating jar Files
» Creating Source Code File Compiling Java Code
» Running Java Applications Building Java Applications
» Using gcj to Build Java Applications
» Building Applets the linux development platform 2003
» Testing Applets with Netscape
» Jikes for Java the linux development platform 2003
Show more