Make was originally a Unix tool from 1976, but it has been re-implemented several times, notably as GNU Make.

Similar documents
Beyond Makefiles: Autotools and the GNU Build System

Workshop Agenda Feb 25 th 2015

July 8, 2007 Jim Huang (jserv)

Autotools Tutorial. Mengke HU. ASPITRG Group Meeting. ECE Department Drexel University

The Makefile utility. (Extract from the slides by Terrance E. Boult

CMPT 300. Operating Systems. Brief Intro to UNIX and C

CS 470 Spring Mike Lam, Professor. OpenMP

CS 470 Spring Mike Lam, Professor. OpenMP

Autotools and GNU Build system

Software Building (Sestavování aplikací)

Makefiles SE 2XA3. Term I, 2018/19

COMP 2400 UNIX Tools

EPL372 Lab Exercise 5: Introduction to OpenMP

CS354R: Game Technology

Tutorial: Compiling, Makefile, Parallel jobs

Introduction to Supercomputing

Lecture 4: OpenMP Open Multi-Processing

Software Building (Sestavování aplikací)

Study of tools used in build process

Why Use the Autotools?...xviii Acknowledgments... xx I Wish You the Very Best... xx

The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them.

How To Create a GNU Autoconf / Automake Based Configure Script for Your Application Under Construction

HPC User Environment

OpenMP 2. CSCI 4850/5850 High-Performance Computing Spring 2018

COSC345 Software Engineering. Make

Autoconf Tutorial. Mark Galassi

OpenMP. António Abreu. Instituto Politécnico de Setúbal. 1 de Março de 2013

The GNU configure and build system

GNU make... Martin Ohlerich, Parallel Programming of High Performance Systems

CS420: Operating Systems

[Software Development] Makefiles. Davide Balzarotti. Eurecom Sophia Antipolis, France

Parallel and Distributed Programming. OpenMP

Parallel Processing/Programming

Shared memory parallel computing

Special Course on Computer Architecture

CAAM 420 Daily Note. Scriber: Qijia Jiang. Date: Oct.16. Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise.

OpenMPand the PGAS Model. CMSC714 Sept 15, 2015 Guest Lecturer: Ray Chen

Maemo Diablo GNU Make and makefiles Training Material

Multiple file project management & Makefile

OpenMP Fundamentals Fork-join model and data environment

These steps may include:

OpenMP 4. CSCI 4850/5850 High-Performance Computing Spring 2018

Using GNU make C HAPTER 4

Projects and Make Files

How to learn C? CSCI [4 6]730: A C Refresher or Introduction. Diving In: A Simple C Program 1-hello-word.c

Makefile Tutorial. Eric S. Missimer. December 6, 2013

ESTABLISHED Paul Kunz SLAC. Overview. Examples. Expose the downsides. Benefits. Risks and Costs. Building with Automake 1 Paul F.

GNU make. Michal Koutný. Software development and monitoring tools (NSWI126)

2 Compiling a C program

Introduction to OpenMP

Our new HPC-Cluster An overview

Maemo Diablo Reference Manual for maemo 4.1. GNU Build System

Parallel Numerical Algorithms

Review of Scientific Programming in C and Fortran. Michael McLennan Software Architect HUBzero Platform for Scientific Collaboration

GLOSSARY. OpenMP. OpenMP brings the power of multiprocessing to your C, C++, and. Fortran programs. BY WOLFGANG DAUTERMANN

Continue: How do I learn C? C Primer Continued (Makefiles, debugging, and more ) Last Time: A Simple(st) C Program 1-hello-world.c!

ITCS 4/5145 Parallel Computing Test 1 5:00 pm - 6:15 pm, Wednesday February 17, 2016 Solutions Name:...

For those with laptops

DPHPC: Introduction to OpenMP Recitation session

Reviewing gcc, make, gdb, and Linux Editors 1

Parallel Programming

FOLLOW ALONG WITH THE EXAMPLES

CS691/SC791: Parallel & Distributed Computing

The makeutility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them.

GNU Automake. For version , 1 February David MacKenzie Tom Tromey Alexandre Duret-Lutz

GNU Make 1. 1 material adapted from GNU Make by Richard Stallman

cp r /global/scratch/workshop/openmp-wg-oct2017 cd openmp-wg-oct2017 && ls Current directory

CS 61C: Great Ideas in Computer Architecture. OpenMP, Transistors

Introduction to Supercomputing

High Performance Computing: Tools and Applications

Shared memory programming model OpenMP TMA4280 Introduction to Supercomputing

Lecture 2: Introduction to OpenMP with application to a simple PDE solver

COMP4510 Introduction to Parallel Computation. Shared Memory and OpenMP. Outline (cont d) Shared Memory and OpenMP

Shared Memory programming paradigm: openmp

Build automation. CSE260, Computer Science B: Honors Stony Brook University

The WAF build system

C Compilation Model. Comp-206 : Introduction to Software Systems Lecture 9. Alexandre Denault Computer Science McGill University Fall 2006

Exercise 1: Basic Tools

Hands-on Clone instructions: bit.ly/ompt-handson. How to get most of OMPT (OpenMP Tools Interface)

Embedded Systems Programming

Advanced C Programming Winter Term 2008/09. Guest Lecture by Markus Thiele

Hello, World! in C. Johann Myrkraverk Oskarsson October 23, The Quintessential Example Program 1. I Printing Text 2. II The Main Function 3

A brief introduction to OpenMP

Instructions for setting up to compile and run OSGPS code under Linux

OpenMP threading: parallel regions. Paolo Burgio

The following program computes a Calculus value, the "trapezoidal approximation of

Deep C. Multifile projects Getting it running Data types Typecasting Memory management Pointers. CS-343 Operating Systems

GNU Autotools Tutorial

Cluster Clonetroop: HowTo 2014

CS 261 Recitation 1 Compiling C on UNIX

CSCI-243 Exam 2 Review February 22, 2015 Presented by the RIT Computer Science Community

Lab #1 Installing a System Due Friday, September 6, 2002

Tool for Analysing and Checking MPI Applications

15213 Recitation Section C

OpenMP Overview. in 30 Minutes. Christian Terboven / Aachen, Germany Stand: Version 2.

Linux system programming - About this course

OpenACC. Part I. Ned Nedialkov. McMaster University Canada. October 2016

Tcl Extension Architecture Developer s Guide DRAFT

Oregon State University School of Electrical Engineering and Computer Science. CS 261 Recitation 1. Spring 2011

OpenMP, Part 2. EAS 520 High Performance Scientific Computing. University of Massachusetts Dartmouth. Spring 2015

Transcription:

make Make was originally a Unix tool from 1976, but it has been re-implemented several times, notably as GNU Make. Make accepts a Makefile, which is a strictly formatted file detailing a series of desired outputs, their dependencies, and how these should be composed together to yield the requested output. Makefiles contain five kinds of things: explicit rules, implicit rules, variable definitions, directives, and comments. An explicit rule says when and how to remake one or more files, called the rule's targets. It lists the other files that the targets depend on, called the prerequisites of the target, and may also give a recipe to use to create or update the targets. An implicit rule says when and how to remake a class of files based on their names. It describes how a target may depend on a file with a name similar to the target and gives a recipe to create or update such a target. A variable definition is a line that specifies a text string value for a variable that can be substituted into the text later. A directive is an instruction for make to do something special while reading the makefile such as reading another makefile. # in a line of a makefile starts a comment. It and the rest of the line are ignored. compatibility with bash/sh/etc. note that variable defns have spaces around equals, for instance variables: CC,FC, CFLAGS,CXX, etc. The Makefile rules for building and installation can also use compilers and related programs, but should do so via make variables so that the user can substitute alternatives. Here are some of the programs we mean: ar bison cc flex install ld ldconfig lex make makeinfo ranlib texi2dvi yacc Use the following make variables to run those programs: $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX) $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC) Also: $(FC) $(CXX) An example Makefile: SHELL = /bin/sh OBJS = hello_world_openmp.o # On a Mac, g++ is an alias for clang which doesn't have great OpenMP support. ARCH := $(firstword $(shell uname -s)) ifeq ($(ARCH),Darwin) CC = gcc-4.8 else CC = gcc endif.suffixes:.suffixes:.c.o

DEBUG = -g CFLAGS = -Wall -c $(DEBUG) -fopenmp -std=c99 LFLAGS = -Wall -lm $(DEBUG) -fopenmp hello_world_openmp : $(OBJS) $(CC) $(LFLAGS) $(OBJS) -o hello_world_openmp hello_world_openmp.o : hello_world_openmp.c $(CC) $(CFLAGS) hello_world_openmp.c clean: rm *.o hello_world_openmp tar: tar cfv hello_world_openmp.tar hello_world_openmp.c test: echo "Executing with 1 thread:" OMP_NUM_THREADS=1 echo "Executing with 2 threads:" OMP_NUM_THREADS=2 echo "Executing with 4 threads:" OMP_NUM_THREADS=4 echo "Executing with 8 threads:" OMP_NUM_THREADS=8 requires file: #include <stdio.h> #include <omp.h> int main(int argc, char *argv[]) { int rank_id; double start_time, wall_time; printf("c OpenMP minimal working example\n"); int num_ranks = omp_get_num_procs(); printf("number of available processors = %d.\n", num_ranks); int num_threads = omp_get_max_threads(); printf("number of available threads = %d.\n", num_threads); start_time = omp_get_wtime(); #pragma omp parallel private (rank_id) {

} rank_id = omp_get_thread_num(); printf("\tprocess number %d branching off.\n", rank_id); wall_time = omp_get_wtime() - start_time; } printf("elapsed wallclock time = %8.6fs.\n", wall_time); return 0; There are magic variables that are important to know about. A file could be written as: CC = gcc Warnings = -Wall test: test.o anothertest.o $(CC) $(Warnings) $^ -o $@ test.o: test.c $(CC) -c $(Warnings) $< anothertest.o: anothertest.c $(CC) -c $(Warning) $< clean: rm -rf *.o test Here $@ becomes the target, $< is the first prerequesite, and $^ is all the prerequisites. This has made the file less readable, but doesn t offer any benefit in this simiple example. And naturally, make install may be a bit more complicated than you might have thought. It can range from a simple attempt to copy things over to /usr/bin (see man install ) to a sophisticated system-independent wrapper: install: install-am install-exec: install-exec-am install-data: install-data-am uninstall: uninstall-am install-am: all-am @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am./configure Why Autoconf? [Make's] lack of support for automatic dependency tracking, recursive builds in subdirectories, reliable timestamps (e.g., for network file systems)

The configuration scripts that Autoconf produces are by convention called configure. When run, configure creates several files, replacing configuration parameters in them with appropriate values. The files that configure creates are: one or more Makefile files, usually one in each subdirectory of the package (see Makefile Substitutions); optionally, a C header file, the name of which is configurable, containing #define` directives (see Configuration Headers); a shell script called config.status that, when run, recreates the files listed above (see config.status Invocation); an optional shell script normally called config.cache (created when using configure --config-cache ) that saves the results of running many of the tests (see Cache Files); a file called config.log containing any messages produced by compilers, to help debugging if configure makes a mistake. The Autoconf approach to portability is to test for features, not for versions. A Full Example $ ls src/ $ ls src/ hello_world_openmp.c $ autoscan $ mv configure.scan configure.ac AC_INIT([hello_world_opemp], [1.0], [davis68@illinois.edu]) AC_CONFIG_SRCDIR([src/hello_world_openmp.c]) #AC_CONFIG_HEADERS([config.h]) $ vi Makefile.am AUTOMAKE_OPTIONS = foreign SUBDIRS = src $ vi src/makefile.am AM_CFLAGS = -Wall -fopenmp -std=c99 bin_programs=hello_world_openmp hello_world_openmp_sources=hello_world_openmp.c AC_INIT([hello_world_opemp], [1.0], [davis68@illinois.edu]) AC_CONFIG_SRCDIR([hello_world_openmp.c]) #AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE(hello_world_openmp, 1.0.0) $ aclocal $ AC_CONFIG_FILES([ Makefile src/makefile ])

AC_OUTPUT --add-missing $./configure $ make http://aireadfun.com/blog/2012/12/03/study-automake/ https://ftp.gnu.org/old-gnu/manuals/automake- 1.6.1/htmlchapter/automake3.html http://pages.cs.wisc.edu/~beechung/ref/gcc-intro.html https://www.gnu.org/software/automake/manual/html_node/requirements.html Others CMake SCons wmake