TutorialsTutorials HomeMakeIndexIntroduction A project Simple make A bit more Library example
FullDocument
|
Simple make
We'll use Simple compileIn order to create an executable program, all these source code files need to be compiled and linked. This command line will do it: % xlf90 -o project project_info.f print_project_info.f project.f
That's a lot of typing even for this simple program.
The
Here is possibly the simplest and clearest # # A first makefile project : project_info.f print_project_info.f project.f xlf90 -o project project_info.f print_project_info.f project.f
The pound character, % make project_info.f: ** project_info === End of Compilation 1 === 1501-510 Compilation successful for file project_info.f. print_project_info.f: ** print_project_info === End of Compilation 1 === 1501-510 Compilation successful for file print_project_info.f. project.f: ** project === End of Compilation 1 === 1501-510 Compilation successful for file project.f.
In addition, if we don't change any files and type % make Target "project" is up to date.
How does it know how to do this? Let's look at the project : project_info.f print_project_info.f project.f
contains the program name,
xlf90 -o project project_info.f print_project_info.f project.f
If the target is more recent than the dependency,
NOTE: Although you can't see it, there is a TAB
character before the xlf90 command. This TAB must be
present for Better compile
In the previous example, every source code file was recompiled
every time a new executable was produced. This is not necessary
in general, and it could waste a lot of time.
If we can understand the steps The xlf90 compiling system works in two stages; it:
All that is needed to produce the final program are
Here are the dependencies for this program:
Here's the
project : project.o print_project_info.o
xlf90 -o project project.o print_project_info.o
project_info.o : project_info.f
xlf90 -c project_info.f
print_project_info.o : print_project_info.f project_info.o
xlf90 -c project_info.o print_project_info.f
project.o : project.f
xlf90 -c project.f
The Now let's make the program:
% make
xlf90 -c project.f
** project === End of Compilation 1 ===
1501-510 Compilation successful for file project.f.
xlf90 -c project_info.f
** project_info === End of Compilation 1 ===
1501-510 Compilation successful for file project_info.f.
xlf90 -c project_info.o print_project_info.f
** print_project_info === End of Compilation 1 ===
1501-510 Compilation successful for file print_project_info.f.
xlf90 -o project project.o print_project_info.o
Typing make again produces: % make Target "project" is up to date. Running the program on the NERSC SP yields % ./project This is PROJECT version 0 . 2
Now let's change the version to 0.3. After we
have edited the file
% make
xlf90 -c project_info.f
** project_info === End of Compilation 1 ===
1501-510 Compilation successful for file project_info.f.
xlf90 -c project_info.o print_project_info.f
** print_project_info === End of Compilation 1 ===
1501-510 Compilation successful for file print_project_info.f.
xlf90 -o project project.o print_project_info.o
% ./project
This is PROJECT version 0 . 3
Note that make only executed the steps that were necessary to
build the program.
In particular, |
![]() |
Page last modified: Fri, 21 May 2004 22:28:00 GMT Page URL: http://www.nersc.gov/nusers/help/tutorials/make/simple_make.php Web contact: webmaster@nersc.gov Computing questions: consult@nersc.gov Privacy and Security Notice |
![]() |