Sponsored Content
Full Discussion: Understanding this Makefile
Top Forums Programming Understanding this Makefile Post 302121250 by porter on Tuesday 12th of June 2007 05:26:48 PM
Old 06-12-2007
$@ is the target of the dependancy

$? are the prequisites for each dependancy rule

The %.o: %.c means in order to build a file with this extension from a file of this extension follow this rule.

Personally I think wild cards are bad news in Makefiles. You want to know exactly what you are building.

While we are at it, I also I don't recommend requiring gmake.

Also, personally, I think that objects should be built in a totally different tree to the source.
 

10 More Discussions You Might Find Interesting

1. Programming

about the makefile

can anyone well explain how to create a makefile? especially those commands in the makefile? BTW, what is CFLAG? (2 Replies)
Discussion started by: ligerdave
2 Replies

2. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

3. Programming

[Makefile] nothing to be done for 'all'

hello, I have a firts makefile who call others makefile. for this i use: $ make -f linux.mak and output his: $ make -f linux.mak all make -C DerelictAL all PLATFORM=linux make: Entering directory `/home/builder/rpmbuild/SOURCES/derelict2-20100407/DerelictAL' make: Nothing to be done for... (2 Replies)
Discussion started by: bioinfornatics
2 Replies

4. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

5. Shell Programming and Scripting

Help with makefile

I made a simple makefile and can't figure out why it is getting an error. It is actually getting two separate errors but I believe the second is a result of the first. Here is my makefile myProgram: main.o employee.o address.o g++ -o main.o employee.o address.o main.o: main.cpp... (2 Replies)
Discussion started by: zero3ree
2 Replies

6. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

7. Shell Programming and Scripting

Makefile Help

Hello, I have to write makefile which supports specific targets and I have to do the following things: - A variable T determines whether the function is executed 1 or 2 - A variable N determines which size will be executed e.g. it must be read from the command line "make 1500" where 1... (0 Replies)
Discussion started by: StudUni
0 Replies

8. Shell Programming and Scripting

Help understanding makefile: static pattern rules

Hi all, I'm reading the GNU Make book I cannot understand the following syntax from the book. objects = foo.o bar.o all : $(objects) $(objects) : %.o : %.c $(CC) -c $(CFLAGS) $< -o $@ If I run: make, I get the output: cc -c foo.c cc -o foo foo.o I think I... (3 Replies)
Discussion started by: santiagorf
3 Replies

9. Programming

Makefile for g++

Hi All, We have moved our OS from Sun Solaris to Linux and also some of the compilers. Our old makefile used to be as below: CC=cc FLAGS=-G -KPIC -DLG_SOLARIS_OS DEFINES=-DSunOS SYSLIBS=-lc .SUFFIXES : .c .c.o : ;$(CC) -c $(FLAGS) $(DEFINES) $*.c -o $*.o ... (3 Replies)
Discussion started by: shash
3 Replies

10. UNIX for Beginners Questions & Answers

Help understanding a line in makefile

I have a big makefile that I am trying to get my head around, this line is what is confusing me. LDFLAGS = -Wl,-rpath-link,$(SYSROOT)/lib/arm-linux-gnueabihf,-rpath-link,$(SYSROOT)/usr/lib/arm-linux-gnueabihf --sysroot=$(SYSROOT) -L$(SYSROOT)/lib -L$(SYSROOT)/usr/lib... (5 Replies)
Discussion started by: sesefsefs
5 Replies
SHAPE_BUILD(1)						      General Commands Manual						    SHAPE_BUILD(1)

NAME
shape_build - shapeTools RMS system building and installation SYNOPSIS
shape [all][VERSIONS=<rule>] [variants] [macro settings] shape install[VERSIONS=<rule>] [INSTALLBASE=<path>] [variants] [macro settings] shape clean[<macro settings>] shape cleancache [<macro settings>] make [all][<macro settings>] make install[INSTALLBASE=<path>] [<macro settings>] make clean[<macro settings>] DESCRIPTION
Shape all, or just shape (as all is the default target), builds the current system node. It performs all necessary actions to derive the main target ($(TARGET) in the Makefile) from the node's source components. Shape all also builds all subsystems of the current node. Before triggering any build action itself, if recursively calls shape for each subsystem. Version selection is driven by the rule given as value to the VERSIONS macro, default is most_recent. The given version selection rule on the command line, if any, is inherited to the recursive calls. Shape install installs the build results of the current node in the appropriate locations. Things to be installed are usually binaries and manuals. The target installtargets in the Makefile lists all these things as its dependents. Shape install updates all build results in the same way as shape all does, before installing them. Shape install invokes all subsystems of the current node in the installation procedure by recursively calling shape install for each of them. This is done, before it performs any build or install actions itself. The appropri- ate versions are selected according to the given version selection rule named in the VERSIONS macro. The default rule for shape install is recent_release selecting the most recent release or prerelease (whichever is newer). The macro INSTALLBASE defines the installation base directory, an absolute pathname pointing to the root of a directory tree, where the build results are to be copied to. Check the Makefile for the default setting of INSTALLBASE and the installation directories defined as relative pathnames starting from the installation base directory. Values of the VERSION and the INSTALLBASE macro set on the command line are inherited to all recursive calls. Shape clean removes all derived objects currently established as UNIX files. These are the files listed in the OBJECTS macro in the Make- file, the derived target ($(TARGET)), and the target aliases ($(ALIASES)). The derived objects, established as UNIX files are those being produced from their source or reinstalled from the derived object cache during the last system build. Shape cleancache cleans up the derived object cache, will say, it removes all objects stored there. All names listed as dependents of the .BPOOL special macro in the Shapefile are candidates to be cached. When multiple (different) versions of derived objects with the same name arise, the older ones are stored to the derived object cache. Shape cleancache in conjunction with shape clean removes all derived (automatically reproducible) objects. The two cleanup actions are not called recursively. They apply only to the current node. The build and cleanup actions (all, install and clean) of the shape RMS can be performed by make(1) and by shape(1). The main difference is, that shape is capable of setting up the appropriate source context according to a given version selection rule, while make only regards the regular UNIX files. Make will fail if not every component of the system has a checked out busy version. The intention for maintaining Makefiles suitable for complete system builds aims at system building and installation from a source distribution rather than from the development area. Source distributions are system copies taken from one of the release trees (partial release area or release area). See shape_RMS(1) for details. Make all, make install and make clean behave similar to their shape counterparts. The difference is, that they expect a complete system source context to be set up as UNIX files (see above). Each macro definition in the Make- or Shapefile may be redefined from the command line. Most of the shape RMS standard macro definitions are inherited to recursive calls of make or shape. Check the shape_tmpl(7) manual page for a list of the standard macros. INCONVENIENCES
For technical reasons, each make call recursively invokes make on the same level before performing any actions. This unfortunately restricts the efficacy of command line options. E.g. there is no chance to work with the -f (alternate name for the Makefile) option and the redefinition of macros is restricted to inherited ones. This restriction does not apply to shape calls. FILES
Makefile Shapefile SEE ALSO
shape_stdrul(7), shape_tmpl(7) 1.6.119 SHAPE_BUILD(1)
All times are GMT -4. The time now is 11:41 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy