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

Size: px
Start display at page:

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

Transcription

1 ... Martin Ohlerich, Parallel Programming of High Performance Systems

2 Outline Leibniz Rechenzentrum 2 / 42

3 Outline Leibniz Rechenzentrum 3 / 42

4 Common Situation Larger software project: many developers, many files, maybe different languages,... Questions Solution How to automate build process? Build only necessary parts during development? Different build options (Debug, Release, Hardware Optimization,...) : c, autotools base on it Leibniz Rechenzentrum 4 / 42

5 First Example Typical Situation prog-path include src Makefile main.cxx $ ls -F include/ Makefile src/ $ g++ -o prog src/main.cxx Goal Create executable prog! Makefile.PHONY: clean prog: src/main.cxx TAB g++ -o prog src/main.cxx clean: -rf prog $ ls -F prog* include/ Makefile src/ $ clean Leibniz Rechenzentrum 5 / 42

6 Getting help: $ -h... Get version: $ -v GNU Make GNUfile, file or Makefile in current directory: $ g++ -O3 -I./include -o src/file1.o src/file1.cxx... Leibniz Rechenzentrum 6 / 42

7 Makefile with different name (mymakefile): $ -f mymakefile... Parallel resources available: $ -j Different target (like clean above): $ clean... Leibniz Rechenzentrum 7 / 42

8 Set some variable(s) used inside the Makefile: $ VAR=2... Call from a different directory: $ ls -F prog-path $ ls -F prog-path include/ Makefile src/ $ -C prog-path... helpful for recursive calls of Leibniz Rechenzentrum 8 / 42

9 Get info about variable settings, etc.: $ -p... $ -p grep -i verbose... $ VERBOSE=1 -p grep -i verbose... Fake: Just prints command sequence but isn t really doing $ -n... Leibniz Rechenzentrum 9 / 42

10 Makefile Elements : similar to BASH SHELL variables Rules: targets, prerequisites, shell commands Directives: control structures, include and conditionals Comments: ignored by, everthing after # Leibniz Rechenzentrum 10 / 42

11 by Example A.h (class A declaration) A.cxx (implementation) main.cxx Makefile version 1 (03_MakefileVersion1).PHONY: clean prog: src/main.cxx src/a.cxx include/a.h TAB g++ -o prog -I./include src/main.cxx src/a.cxx clean: -rf prog src/*.o *~ */*~ No gain! Still all files recompiled. Leibniz Rechenzentrum 11 / 42

12 by Example - better solution A.h A.cxx main.cxx Makefile version 2 (03_MakefileVersion2).PHONY: clean prog: src/main.o src/a.o TAB g++ -o prog src/main.o src/a.o src/a.o: src/a.cxx include/a.h TAB g++ -c -I./include -o src/a.o src/a.cxx src/main.o: src/main.cxx include/a.h TAB g++ -c -I./include -o main.o src/main.cxx clean: -rf prog src/*.o *~ */*~ Leibniz Rechenzentrum 12 / 42

13 Syntax for explicit Rules targets... : prerequisites... TAB shell command Targets: file names or labels Prerequisites: file names or other targets separated by spaces; necessary to create the target Shell commands: interpreted by /bin/sh Note! (02_HelloMakeDiffTab) Tab character at beginning of command lines is mandatory! (unless.recipeprefix is set differently in newer versions) Leibniz Rechenzentrum 13 / 42

14 Command Lines Command Part Issues (01_HelloMake) Commands /bin/sh, unless SHELL set differently Split "Hello" \ echo " Command: Command NOT printed to screen - Command: failure is ignored, e.g. rm FileNotExist # Command line: just printed to screen Leibniz Rechenzentrum 14 / 42

15 Goals and the Default Goal Note! Goals = selected targets for update: $ src/main.o must match exactly one of Makefile s targets Default goal can be set via.default_goal inside Makefile else, 1st target in 1st rule of 1st file not starting with dot (".") Order of explicit rules not significant, except maybe for determining the default goal Leibniz Rechenzentrum 15 / 42

16 PHONY and Empty Targets.PHONY targets.phony targets = targets without real file possible files with same name as.phony target are ignored control Makefile behavior; typical.phony targets: clean, test, all Declare all.phony targets as such! Empty Targets print: src/a.cxx src/main.cxx $? print Only source files printed that changed since last call of $ print Leibniz Rechenzentrum 16 / 42

17 by Example Makefile version 3 (03_MakefileVersion3) PNAME=prog CXX=g++ INC=-I./include.PHONY: clean $(PNAME): src/main.o src/a.o TAB $(CXX) -o $(PNAME) src/main.o src/a.o src/a.o: src/a.cxx include/a.h TAB $(CXX) -c $(INC) src/a.cxx src/main.o: src/main.cxx include/a.h TAB $(CXX) -c $(INC) src/main.cxx clean: -rf $(PNAME) src/*.o *~ */*~ Leibniz Rechenzentrum 17 / 42

18 Overview Variable names case-sensitive: a_bla1 A_bla1 ${variablename} or $(variablename) for substitution Variable referenced in targets, prerequisites, commands, most directives, and new variable values Leibniz Rechenzentrum 18 / 42

19 User defined variables Recursively Expanded Example (Definition of recursively expanded variables) name = value variables stored as verbatim text; not expanded until referencing Advantage Order of definition NOT significant Problems name = ${name} anothervalue infinite recursion! referenced in definition of such variables are executed every time the variable is expanded execution much slower/unpredictable Leibniz Rechenzentrum 19 / 42

20 User defined variables Simply Expanded Example (Definition of simply expanded variables) name := value value of such variable scanned once Advantages No infinite recursions No slow down of Better style Leibniz Rechenzentrum 20 / 42

21 Appending More Text to Example (Simply Expanded ) name := value name += anothervalue # is equivalent to name := value name := ${name} anothervalue Example (Recursively Expanded ) name = value name += anothervalue # is equivalent to name = value temp = ${name} name = ${temp} anothervalue # except that temp not needed using "+=" Leibniz Rechenzentrum 21 / 42

22 Overriding variables How variables get their values 1 transforms BASH environment variables into variables with same name/value 2 Variable defined in Makefile any environment variable of same name ignored 3 are overridden on command line: $ PNAME=bla -f Makefile 4 Prevent any overriding by (in Makefile) override variablename = value works also for ":=" and "+=" operators Leibniz Rechenzentrum 22 / 42

23 Wildcard Characters in File Names Similar to BASH wildcards * Matches any string, including the null string? Matches any single character [... ] Matches any one of the enclosed characters / denotes your home directory john/ denotes John s home directory Leibniz Rechenzentrum 23 / 42

24 Build-in Searching Directories for Prerequisites VPATH: directories to look for prerequisites Rules can be written, as if all prerequisite files current directory VPATH: colon- or space-separated list of directories Example # Suppose foo.c is found in./src/. VPATH = src foo.o : foo.c Caution! (03_MakefileVersion6) Object files created in CURRENT directory! Leibniz Rechenzentrum 24 / 42

25 Used by Built-In for executable Programs ${FC} Fortran Compiler ${CC} C Compiler ${CPP} C Preprocessor ${CXX} C++ Compiler for Flags ${FFLAGS} Flags for the Fortran Compiler ${CFLAGS} Flags for the C Compiler ${CPPFLAGS} Flags for the C Preprocessor ${CXXFLAGS} Flags for the C++ Compiler ${LDFLAGS} Flags for the linker Leibniz Rechenzentrum 25 / 42

26 by Example Makefile version 4 (03_MakefileVersion4) PNAME=prog CXX=g++ INC=-I./include OBJS=src/main.o src/a.o.phony: clean $(PNAME): $(OBJS) TAB $(CXX) -o $@ $ˆ %.o: %.cxx include/a.h TAB $(CXX) -c $(INC) -o $@ $< clean: -rf $(PNAME) $(OBJS) *~ */*~ Leibniz Rechenzentrum 26 / 42

27 Syntax for implicit Rules target-pattern : prerequisites... TAB shell command target-pattern contains exactly one %! Note! Order of appearance of rules in Makefile important Most important automatic $@ File name of target of rule $< Name of first prerequesite $? Names of all prerequesites newer than target $ˆ Names of all prerequesites with spaces between them Leibniz Rechenzentrum 27 / 42

28 by Example Makefile version 5 (03_MakefileVersion7) PNAME=prog VPATH=include CXX=g++ INC=-I./include SRC = $(wildcard src/*.cxx) OBJS = $(SRC:.cxx=.o) # same as OBJS = $(patsubst %.cxx,%.o,$src).phony: clean bin/$(pname): $(OBJS) -p bin TAB $(CXX) -o $@ $ˆ %.o: %.cxx A.h TAB $(CXX) -c $(INC) -o $@ $< clean: -rf $(PNAME) bin *~ */*~ Leibniz Rechenzentrum 28 / 42

29 for String Substitution and Analysis $(subst from,to,text) replaces each occurence of from in text by to $(patsubst pattern,repl,text) finds whitespace-separated words in text matching the pattern and replaces with repl; % in pattern = wildcard; may also appear in repl $(filter patterns...,text) returns all whitespace-separated words in text which match any of whitespace-separated patterns $(filter-out patterns...,text) does exact opposite of filter $(subst ee,oo,feet) $(patsubst %.o,%.f90,foo.o) $(filter %.f90,foo.f90 bar.o) $(filter-out %.f90,foo.f90 bar.o) # = foot # = foo.f90 # = foo.f90 # = bar.o Leibniz Rechenzentrum 29 / 42

30 Further $(wildcard pattern): explicitely request wildcard expansion for file names; pattern may contain bash s wildcard characters *,?, [... ] $(foreach var,list,text): similar to bash s for or Perl s foreach $(call variable,arg1,arg2,...): expand appropriately defined variable as function $(shell command): execute command in a shell and process its output Many more functions available see user manual! Leibniz Rechenzentrum 30 / 42

31 by Example Makefile version 5 (03_MakefileVersion8) PNAME=prog CXX=g++ ifdef INTEL CXX=icpc endif INC=-I./include OBJS=$(patsubst %.cxx,%.o,$(wildcard src/*.cxx)).phony: clean $(PNAME): $(OBJS) TAB $(CXX) -o $@ $ˆ %.o: %.cxx include/a.h TAB $(CXX) -c $(INC) -o $@ $<... $ INTEL=1 or $ export INTEL=1 && Leibniz Rechenzentrum 31 / 42

32 Conditional Parts in Makefiles control what sees/ignores Example (Syntax of a simple conditional) ifeq (arg1, arg2) # take this if arguments equal endif all variable references in both arguments are expanded first, then arguments are compared Example (Syntax of another simple conditional) ifneq (arg1, arg2) # take this if arguments are not equal endif Leibniz Rechenzentrum 32 / 42

33 More complex conditionals Example (General syntax of conditionals) conditional-directive # take this if first condition is met [ else conditional-directive # take this if this condition is met # Note: available since v3.81 [... ] ] [ else # take this if no condition is true ] endif conditional-directive may be one of ifeq (arg1, arg2) ifneq (arg1, arg2) ifdef arg ifndef arg Leibniz Rechenzentrum 33 / 42

34 Include Directive Syntax include Make.inc useful to switch between e.g. compilers (incl. their flags, options, libraries) or hardware can be combined with conditionals ( command line switches or environmental variables) Example Please, have a look in the PTScotch Library, or other GNU suite programms! Leibniz Rechenzentrum 34 / 42

35 Exercise 04_Exercise include A.h src A.cxx main.cxx libb include B.h src B.cxx 04_Exercise Create Makefile(s)! Compile programm named prog into bin of top-level directory! main depends on A.h and B.h. Class B should become a library, located in lib of the top-level directory! Hint How to build dynamic libraries under Linux using gcc, please look here. Leibniz Rechenzentrum 35 / 42

36 Outline Leibniz Rechenzentrum 36 / 42

37 Header Situation (05_Example) A.h B.h A.cxx main.cxx B.cxx or even more complex (C++ class hierarchies) Always a solution... If headers are modified: $ clean && Disadvantage: all source files have to be recompiled Leibniz Rechenzentrum 37 / 42

38 Header Or... (05_Example) PNAME := prog CXX := g++ INC := -I./include CXXFLAGS := -O3 $(INC) SRCS := $(wildcard src/*.cxx) OBJS := $(patsubst %.cxx,%.o,$(srcs)) DEPDIR :=.d $(shell mkdir -p $(DEPDIR)/src > /dev/null) DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.Td COMPILE.cc = $(CXX) $(DEPFLAGS) $(CXXFLAGS) -c POSTCOMPILE = mv -f $(DEPDIR)/$*.Td $(DEPDIR)/$*.d.PHONY: clean $(PNAME) : $(OBJS) TAB $(CXX) -o $@ $ˆ... Leibniz Rechenzentrum 38 / 42

39 Header... cont d (05_Example)... %.o : %.cxx TAB $(COMPILE.cc) -o $@ $< TAB $(POSTCOMPILE).PRECIOUS: $(DEPDIR)/%.d -include $(patsubst %,$(DEPDIR)/%.d,$(basename $(SRCS))) clean: -rf $(DEPDIR) $(PNAME) $(OBJS) *~ */*~ $ cat.d/src/a.d src/a.o: src/a.cxx include/a.h include/a.h: Leibniz Rechenzentrum 39 / 42

40 Debugging Debugging existing Makefile or Variable settings $ -p $ -n in combination with pipes and grep etc. Debugging specific Variable settings (06_Make_DEBUG) insert rule into Makefile: print-%: $*=$($*) and call for instance: $ VAR=1 print-var Leibniz Rechenzentrum 40 / 42

41 Outline Leibniz Rechenzentrum 41 / 42

42 user manual: or in PDF form: Specifically: Reference in Appendix A error messages: Messages.html Leibniz Rechenzentrum 42 / 42

Compilation & linkage. Compilation & linkage. Make. Compilation & linkage. Explicit rules. What makefile contains

Compilation & linkage. Compilation & linkage. Make. Compilation & linkage. Explicit rules. What makefile contains Linkage: g++ read main list o Compilation: g++ -c read main list read read read main main list list list If only one file is modified, do we have to recompile all over again? No. The Makefile uses the

More information

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

[Software Development] Makefiles. Davide Balzarotti. Eurecom Sophia Antipolis, France [Software Development] Makefiles Davide Balzarotti Eurecom Sophia Antipolis, France 1 Software Development Tools 1. Configuring and Building the program GCC Makefiles Autotools 2. Writing and managing

More information

We d like to hear your suggestions for improving our indexes. Send to

We d like to hear your suggestions for improving our indexes. Send  to Index [ ] (brackets) wildcard, 12 { } (curly braces) in variables, 41 ( ) (parentheses) in variables, 41 += (append) operator, 45 * (asterisk) wildcard, 12 $% automatic variable, 16 $+ automatic variable,

More information

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

GNU make. Michal Koutný. Software development and monitoring tools (NSWI126) GNU make Michal Koutný Software development and monitoring tools (NSWI126) Make basics Dependency tree (target and prerequisites) Check prerequisites, build target with recipe Configured via Makefile (a

More information

Tutorial: Compiling, Makefile, Parallel jobs

Tutorial: Compiling, Makefile, Parallel jobs Tutorial: Compiling, Makefile, Parallel jobs Hartmut Häfner Steinbuch Centre for Computing (SCC) Funding: www.bwhpc-c5.de Outline Compiler + Numerical Libraries commands Linking Makefile Intro, Syntax

More information

Software Building (Sestavování aplikací)

Software Building (Sestavování aplikací) Software Building (Sestavování aplikací) http://d3s.mff.cuni.cz Pavel Parízek parizek@d3s.mff.cuni.cz CHARLES UNIVERSITY IN PRAGUE faculty of mathematics and physics Make Nástroje pro vývoj software Software

More information

Workshop Agenda Feb 25 th 2015

Workshop Agenda Feb 25 th 2015 Workshop Agenda Feb 25 th 2015 Time Presenter Title 09:30 T. König Talk bwhpc Concept & bwhpc-c5 - Federated User Support Activities 09:45 R. Walter Talk bwhpc architecture (bwunicluster, bwforcluster

More information

CS11 Advanced C++ Fall Lecture 4

CS11 Advanced C++ Fall Lecture 4 CS11 Advanced C++ Fall 2006-2007 Lecture 4 Today s Topics Using make to automate build tasks Using doxygen to generate API docs Build-Automation Standard development cycle: Write more code Compile Test

More information

The Make Utility. Independent compilation. Large programs are difficult to maintain. Problem solved by breaking the program into separate files

The Make Utility. Independent compilation. Large programs are difficult to maintain. Problem solved by breaking the program into separate files The Make Utility Independent compilation Large programs are difficult to maintain Problem solved by breaking the program into separate files Different functions placed in different files The main function

More information

CS11 Intro C++ Spring 2018 Lecture 4

CS11 Intro C++ Spring 2018 Lecture 4 CS11 Intro C++ Spring 2018 Lecture 4 Build Automation When a program grows beyond a certain size, compiling gets annoying g++ -std=c++14 -Wall units.cpp testbase.cpp \ hw3testunits.cpp -o hw3testunits

More information

Multiple file project management & Makefile

Multiple file project management & Makefile Multiple file project management & Makefile Compilation & linkage read.c read.h main.c Compilation: gcc -c read.c main.c list.c list.h list.c read.o main.o list.o Linkage: gcc... read.o main.o list.o -o

More information

GNU Make. A Program for Directing Recompilation GNU make Version 3.79 April Richard M. Stallman and Roland McGrath

GNU Make. A Program for Directing Recompilation GNU make Version 3.79 April Richard M. Stallman and Roland McGrath GNU Make GNU Make A Program for Directing Recompilation GNU make Version 3.79 April 2000 Richard M. Stallman and Roland McGrath Copyright c 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000 Free

More information

Creating a Project Using an Existing Build System

Creating a Project Using an Existing Build System Creating a Project Using an Existing Build System You can use the cpptestscan or cpptesttrace utility to create a C++test project that you would normally build using tools such as GNU make, CMake, and

More information

Makefiles SE 2XA3. Term I, 2018/19

Makefiles SE 2XA3. Term I, 2018/19 Makefiles SE 2XA3 Term I, 2018/19 Outline Example Calling make Syntax How it works Macros Suffix rules Command line options Example Assume we have files main.c, test.c, and lo.asm Consider the makefile

More information

Introduction to Supercomputing

Introduction to Supercomputing Introduction to Supercomputing TMA4280 Introduction to UNIX environment and tools 0.1 Getting started with the environment and the bash shell interpreter Desktop computers are usually operated from a graphical

More information

AN 834: Developing for the Intel HLS Compiler with an IDE

AN 834: Developing for the Intel HLS Compiler with an IDE AN 834: Developing for the Intel HLS Compiler with an IDE Subscribe Send Feedback Latest document on the web: PDF HTML Contents Contents 1 Developing for the Intel HLS Compiler with an Eclipse* IDE...

More information

Using GNU make C HAPTER 4

Using GNU make C HAPTER 4 CH04.fm Page 101 Monday, October 7, 2002 8:54 PM C HAPTER 4 Using GNU make A ll serious software projects are built in pieces by many developers. These pieces consist of source code and header files, libraries

More information

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

CMPT 300. Operating Systems. Brief Intro to UNIX and C CMPT 300 Operating Systems Brief Intro to UNIX and C Outline Welcome Review Questions UNIX basics and Vi editor Using SSH to remote access Lab2(4214) Compiling a C Program Makefile Basic C/C++ programming

More information

CSE 374 Programming Concepts & Tools

CSE 374 Programming Concepts & Tools CSE 374 Programming Concepts & Tools Hal Perkins Fall 2017 Lecture 14 Makefiles and Compilation Management 1 Where we are Onto tools... Basics of make, particular the concepts Some fancier make features

More information

CSci 4061 Introduction to Operating Systems. Programs in C/Unix

CSci 4061 Introduction to Operating Systems. Programs in C/Unix CSci 4061 Introduction to Operating Systems Programs in C/Unix Today Basic C programming Follow on to recitation Structure of a C program A C program consists of a collection of C functions, structs, arrays,

More information

@shorttitlepage GNU Make Copyright (C) 1988, '89, '90, '91, '92, '93 Free Software Foundation, Inc.

@shorttitlepage GNU Make Copyright (C) 1988, '89, '90, '91, '92, '93 Free Software Foundation, Inc. GNU Make @shorttitlepage GNU Make Copyright (C) 1988, '89, '90, '91, '92, '93 Free Software Foundation, Inc. Published by the Free Software Foundation 675 Massachusetts Avenue, Cambridge, MA 02139 USA

More information

The Make Utility. Independent compilation. Large programs are difficult to maintain. Problem solved by breaking the program into separate files

The Make Utility. Independent compilation. Large programs are difficult to maintain. Problem solved by breaking the program into separate files The Make Utility Independent compilation Large programs are difficult to maintain Problem solved by breaking the program into separate files Different functions placed in different files The main function

More information

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2

Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 2 Compiling a C program CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Example of a small program Makefile Define Variables Compilation options Conclusion Berner Fachhochschule Haute

More information

CS Basics 15) Compiling a C prog.

CS Basics 15) Compiling a C prog. CS Basics 15) Compiling a C prog. Emmanuel Benoist Fall Term 2016-17 Berner Fachhochschule Haute cole spcialise bernoise Berne University of Applied Sciences 1 Compiling a C program Example of a small

More information

Basic Compilation Control with Make

Basic Compilation Control with Make by P.N. Hilfinger (U.C. Berkeley) modified by M. Clancy (UCB) and C. Bono Basic Compilation Control with Make Even relatively small software systems can require rather involved, or at least tedious, sequences

More information

Laboratory Exercises, C++ Programming

Laboratory Exercises, C++ Programming LUND INSTITUTE OF TECHNOLOGY EDAF30 Department of Computer Science 2016 Laboratory Exercises, C++ Programming General information: The course has four compulsory laboratory exercises. You shall work in

More information

Introduction to System Programming : makefile

Introduction to System Programming : makefile Introduction to System Programming : makefile Reference Documentation: http://www.gnu.org/software/make/manual/make.html Tutorials: http://www.cs.umd.edu/class/spring2002/cmsc214/tutorial/makefile.html

More information

BMS: Build Management System

BMS: Build Management System BMS: Build Management System D. Lawrence Jefferson Lab May 3, 2005 Abstract The BMS Build Management System is a set of GNU Makefiles which simplify and standardize the building of source code distribruted

More information

Makefile Brief Reference

Makefile Brief Reference Makefile Brief Reference COMP 229, 346, 444, 5201 Revision 1.1 Date: July 31, 2003 1 Contents Intro Format Examples 2 Intro Makefiles in conjunction with the make utility (man make) provide a very convenient

More information

HPC User Environment

HPC User Environment HPC User Environment Dirk Schmidl schmidl@rz.rwth-aachen.de Center for Computing and Communication RWTH Aachen University 22.03.2010 1 Program development tools on Linux IDEs eclipse sunstudio kdevelop

More information

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

Instructions for setting up to compile and run OSGPS code under Linux Instructions for setting up to compile and run OSGPS code under Linux A. The latest and greatest OSGPS software is available on SorceForge. If you are not already monitoring this, you need to be. To set

More information

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell

Linux environment. Graphical interface X-window + window manager. Text interface terminal + shell Linux environment Graphical interface X-window + window manager Text interface terminal + shell ctrl-z put running command to background (come back via command fg) Terminal basics Two basic shells - slightly

More information

2 Compiling a C program

2 Compiling a C program 2 Compiling a C program This chapter describes how to compile C programs using gcc. Programs can be compiled from a single source file or from multiple source files, and may use system libraries and header

More information

GNU Make. A Program for Directing Recompilation. Edition 0.51, for make Version 3.75 Beta. May Richard M. Stallman and Roland McGrath

GNU Make. A Program for Directing Recompilation. Edition 0.51, for make Version 3.75 Beta. May Richard M. Stallman and Roland McGrath GNU Make GNU Make A Program for Directing Recompilation Edition 0.51, for make Version 3.75 Beta. May 1996 Richard M. Stallman and Roland McGrath Copyright c 1988, '89, '90, '91, '92, '93, '94, '95, '96

More information

CS2141 Software Development using C/C++ Compiling a C++ Program

CS2141 Software Development using C/C++ Compiling a C++ Program CS2141 Software Development using C/C++ Compiling a C++ Program g++ g++ is the GNU C++ compiler. A program in a file called hello.cpp: #include using namespace std; int main( ) { cout

More information

Maemo Diablo GNU Make and makefiles Training Material

Maemo Diablo GNU Make and makefiles Training Material Maemo Diablo GNU Make and makefiles Training Material February 9, 2009 Contents 1 GNU Make and makefiles 2 1.1 What is GNU Make?......................... 2 1.2 How does make work?........................

More information

independent compilation and Make

independent compilation and Make independent compilation and Make Geoffrey Brown David S. Wise Chris Haynes Bryce Himebaugh Computer Structures Fall 2013 Independent Compilation As a matter of style, source code files should rarely be

More information

Conduite de Projet Cours 4 The C build process

Conduite de Projet Cours 4 The C build process Conduite de Projet Cours 4 The C build process Stefano Zacchiroli zack@pps.univ-paris-diderot.fr Laboratoire IRIF, Université Paris Diderot 2016 2017 URL http://upsilon.cc/zack/teaching/1617/cproj/ Copyright

More information

COSC345 Software Engineering. Make

COSC345 Software Engineering. Make COSC345 Software Engineering Make The build process Make When to use make How to use make Suffix rules makedepend Outline Warning: Make is different everywhere you go! Build Process The build process can

More information

Program Development Tools

Program Development Tools Program Development Tools GNU make (much of this material is adapted from GNU Make by Richard Stallman) The make utility automatically determines which pieces of a large program need to be recompiled,

More information

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

Build automation. CSE260, Computer Science B: Honors Stony Brook University Build automation CSE260, Computer Science B: Honors Stony Brook University http://www.cs.stonybrook.edu/~cse260 2 Build Automation Build automation is the act of scripting or automating a wide variety

More information

Introduction to Linux

Introduction to Linux Introduction to Linux EECS 211 Martin Luessi April 14, 2010 Martin Luessi () Introduction to Linux April 14, 2010 1 / 14 Outline 1 Introduction 2 How to Get Started 3 Software Development under Linux 4

More information

CSC 2500: Unix Lab Fall 2016

CSC 2500: Unix Lab Fall 2016 CSC 2500: Unix Lab Fall 2016 Makefile Mohammad Ashiqur Rahman Department of Computer Science College of Engineering Tennessee Tech University Agenda Make Utility Build Process The Basic Makefile Target

More information

CSE 333 Interlude - make and build tools

CSE 333 Interlude - make and build tools CSE 333 Interlude - make and build tools Hal Perkins Paul G. Allen School of Computer Science & Engineering University of Washington make make is a classic program for controlling what gets (re)compiled

More information

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

Make was originally a Unix tool from 1976, but it has been re-implemented several times, notably as GNU Make. 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

More information

Intermediate Programming, Spring 2017*

Intermediate Programming, Spring 2017* 600.120 Intermediate Programming, Spring 2017* Misha Kazhdan *Much of the code in these examples is not commented because it would otherwise not fit on the slides. This is bad coding practice in general

More information

GDB and Makefile. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island

GDB and Makefile. Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island GDB and Makefile Bin Li Assistant Professor Dept. of Electrical, Computer and Biomedical Engineering University of Rhode Island GDB Debugging: An Example #include void main() { int i; int result

More information

Task Automation. Anthony Scemama Labratoire de Chimie et Physique Quantiques IRSAMC (Toulouse)

Task Automation. Anthony Scemama Labratoire de Chimie et Physique Quantiques IRSAMC (Toulouse) Task Automation Anthony Scemama Labratoire de Chimie et Physique Quantiques IRSAMC (Toulouse) Introduction Many common tasks are repetitive Computers are better than humans

More information

Systems Programming/ C and UNIX

Systems Programming/ C and UNIX Systems Programming/ C and UNIX Alice E. Fischer Lecture 5 Makefiles October 2, 2017 Alice E. Fischer Lecture 5 Makefiles Lecture 5 Makefiles... 1/14 October 2, 2017 1 / 14 Outline 1 Modules and Makefiles

More information

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

Makefile Tutorial. Eric S. Missimer. December 6, 2013 Makefile Tutorial Eric S. Missimer December 6, 2013 1 Basic Elements of a Makefile 1.1 Explicit Rules A the major part of a Makefile are the explicit rules (a.k.a. recipes) that make certain files. Below

More information

Systems Programming. laboratory. Compilation automation. make ceedling

Systems Programming. laboratory. Compilation automation. make ceedling Systems Programming 2 nd laboratory Compilation automation make ceedling Compilation automation Large SW projects are composed of diferent su-systems with links and dependencies among them Libraries/ cliens/servers/interfaces

More information

Reviewing gcc, make, gdb, and Linux Editors 1

Reviewing gcc, make, gdb, and Linux Editors 1 Reviewing gcc, make, gdb, and Linux Editors 1 Colin Gordon csgordon@cs.washington.edu University of Washington CSE333 Section 1, 3/31/11 1 Lots of material borrowed from 351/303 slides Colin Gordon (University

More information

The Linux Programming Environment. Computer Science Department Texas State University

The Linux Programming Environment. Computer Science Department Texas State University The Linux Programming Environment Computer Science Department Texas State University TUTORIAL REQUIREMENTS... 1 INTRODUCTION... 1 COMPILATION... 1 COMMAND LINE COMPILATION... 1 Basic Compilation... 2 The

More information

Beyond Makefiles: Autotools and the GNU Build System

Beyond Makefiles: Autotools and the GNU Build System SEA : Autotools and the GNU Build System Patrick Nichols Software Engineer CISL Consulting Group UCAR SEA December 10, 2015 Why do we need more tools? Diversity! 1. Compilers, programming languages and

More information

UNIX Makefile. C Project Library Distribution and Installation.

UNIX Makefile. C Project Library Distribution and Installation. UNIX Makefile C Project Library Distribution and Installation. Tarballs Most non-package software is distributed in source code format. The most common format being C project libraries in compressed TAR

More information

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

GNU Make 1. 1 material adapted from GNU Make by Richard Stallman 1 The make utility automatically determines which pieces of a large program need to be recompiled, and issues commands to recompile them. Make can be used with any programming language whose compiler can

More information

GNU Make. A Program for Directing Recompilation GNU make Version 3.82 July Richard M. Stallman, Roland McGrath, Paul D.

GNU Make. A Program for Directing Recompilation GNU make Version 3.82 July Richard M. Stallman, Roland McGrath, Paul D. GNU Make GNU Make A Program for Directing Recompilation GNU make Version 3.82 July 2010 Richard M. Stallman, Roland McGrath, Paul D. Smith This file documents the GNU make utility, which determines automatically

More information

CS Students Linux User's Guide

CS Students Linux User's Guide CS Students Linux User's Guide Writing a Makefile Author: Jaco Kroon (jaco@kroon.co.za) Version: 1.0 Last modified: Mon Aug 11 13:27:34 SAST 2003 Table of Contents 4.2 Writing a Makefile 4.2.1 Why Use

More information

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi

sottotitolo A.A. 2016/17 Federico Reghenzani, Alessandro Barenghi Titolo presentazione Piattaforme Software per la Rete sottotitolo BASH Scripting Milano, XX mese 20XX A.A. 2016/17, Alessandro Barenghi Outline 1) Introduction to BASH 2) Helper commands 3) Control Flow

More information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division. P. N. Hilfinger UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS164 Spring 2009 P. N. Hilfinger Basic Compilation Control with Gmake Even relatively small

More information

Documentation of the chemistry-transport model. [version 2017r4] July 25, How to install required libraries under GNU/Linux

Documentation of the chemistry-transport model. [version 2017r4] July 25, How to install required libraries under GNU/Linux Documentation of the chemistry-transport model [version 2017r4] July 25, 2018. How to install required libraries under GNU/Linux Contents 1 pnetcdf and NetCDF4 formats 2 1.1 Problems with NetCDF4 files..........................

More information

Separate Compilation of Multi-File Programs

Separate Compilation of Multi-File Programs 1 About Compiling What most people mean by the phrase "compiling a program" is actually two separate steps in the creation of that program. The rst step is proper compilation. Compilation is the translation

More information

Data and File Structures Laboratory

Data and File Structures Laboratory Tools: Gcov, Cscope, Ctags, and Makefiles Assistant Professor Machine Intelligence Unit Indian Statistical Institute, Kolkata August, 2018 1 Gcov 2 Cscope 3 Ctags 4 Makefiles Gcov Gcov stands for GNU Coverage

More information

Introduction to Linux Scripting (Part 2) Brett Milash and Wim Cardoen CHPC User Services

Introduction to Linux Scripting (Part 2) Brett Milash and Wim Cardoen CHPC User Services Introduction to Linux Scripting (Part 2) Brett Milash and Wim Cardoen CHPC User Services Overview Advanced Scripting Compiling Code Getting the exercise files For today s exercises, open a session to one

More information

A Fast Review of C Essentials Part II

A Fast Review of C Essentials Part II A Fast Review of C Essentials Part II Structural Programming by Z. Cihan TAYSI Outline Macro processing Macro substitution Removing a macro definition Macros vs. functions Built-in macros Conditional compilation

More information

Make: a build automation tool

Make: a build automation tool Make: a build automation tool What is the problem? The lab examples repository for the CS 253 course has 228 files in 54 folders. To build them all would requires us to navigate to 54 folders and compile

More information

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND

CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND CS 307: UNIX PROGRAMMING ENVIRONMENT FIND COMMAND Prof. Michael J. Reale Fall 2014 Finding Files in a Directory Tree Suppose you want to find a file with a certain filename (or with a filename matching

More information

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo

UNIX COMMANDS AND SHELLS. UNIX Programming 2015 Fall by Euiseong Seo UNIX COMMANDS AND SHELLS UNIX Programming 2015 Fall by Euiseong Seo What is a Shell? A system program that allows a user to execute Shell functions (internal commands) Other programs (external commands)

More information

An Overview of ROMS Code. Kate Hedstrom, ARSC January 2011

An Overview of ROMS Code. Kate Hedstrom, ARSC January 2011 An Overview of ROMS Code Kate Hedstrom, ARSC January 2011 Outline Outline of the code cpp cppdefs.h Modules ocean.in Compiling ROMS ls Trunk Atmosphere/ Lib/ ROMS/ Compilers/ makefile User/ Data/ Master/

More information

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

CAAM 420 Daily Note. Scriber: Qijia Jiang. Date: Oct.16. Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise. CAAM 420 Daily Note Scriber: Qijia Jiang Date: Oct.16 1 Announcement Project 3 Due Wed 23.Oct. Two parts: debug code and library exercise. 2 Make Convention Make syntax for library directories and library

More information

The make utility. Alark Joshi COMPSCI 253

The make utility. Alark Joshi COMPSCI 253 The make utility Alark Joshi COMPSCI 253 What is make? Make is a utility that is included with Linux/Unix operating systems It is a command generator It is designed to help you compile large projects It

More information

Make: a build automation tool 1/23

Make: a build automation tool 1/23 Make: a build automation tool 1/23 What is the problem? The lab examples repository for the CS 253 course has 293 files in 81 folders. To build them all would requires us to navigate to 81 folders and

More information

Reliable C++ development - session 1: From C to C++ (and some C++ features)

Reliable C++ development - session 1: From C to C++ (and some C++ features) Reliable C++ development - session 1: From C to C++ (and some C++ features) Thibault CHOLEZ - thibault.cholez@loria.fr TELECOM Nancy - Université de Lorraine LORIA - INRIA Nancy Grand-Est From Nicolas

More information

Programming in the Large Steps

Programming in the Large Steps Building 1 Programming in the Large Steps Design & Implement Program & programming style Common data structures and algorithms Modularity Building techniques & tools

More information

Chapter 4. Unix Tutorial. Unix Shell

Chapter 4. Unix Tutorial. Unix Shell Chapter 4 Unix Tutorial Users and applications interact with hardware through an operating system (OS). Unix is a very basic operating system in that it has just the essentials. Many operating systems,

More information

CSE 333 Midterm Exam 7/27/15 Sample Solution

CSE 333 Midterm Exam 7/27/15 Sample Solution Question 1. (24 points) C programming. In this problem we want to implement a set of strings in C. A set is represented as a linked list of strings with no duplicate values. The nodes in the list are defined

More information

Make A Program for Maintaining Computer Programs

Make A Program for Maintaining Computer Programs S. I. Feldman ABSTRACT In a programming project, it is easy to lose track of which files need to be reprocessed or recompiled after a change is made in some part of the source. Make provides a simple mechanism

More information

Assignment clarifications

Assignment clarifications Assignment clarifications How many errors to print? at most 1 per token. Interpretation of white space in { } treat as a valid extension, involving white space characters. Assignment FAQs have been updated.

More information

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines

Introduction to UNIX. Logging in. Basic System Architecture 10/7/10. most systems have graphical login on Linux machines Introduction to UNIX Logging in Basic system architecture Getting help Intro to shell (tcsh) Basic UNIX File Maintenance Intro to emacs I/O Redirection Shell scripts Logging in most systems have graphical

More information

/visualc/vcug/_asug_overview.3a_.nmake_reference.htm

/visualc/vcug/_asug_overview.3a_.nmake_reference.htm NMAKE 1 Definition : Microsoft development utility program for keeping a set of separately compiled files current, (AT&T and Lucent also maintain versions of nmake). Eliminates unnecessary compilations

More information

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE

INTERMEDIATE SOFTWARE DESIGN SPRING 2011 ACCESS SPECIFIER: SOURCE FILE HEADER FILE A header (.h,.hpp,...) file contains Class definitions ( class X {... }; ) Inline function definitions ( inline int get_x() {... } ) Function declarations ( void help(); ) Object declarations

More information

Kurt Schmidt. May 23, 2018

Kurt Schmidt. May 23, 2018 duction to duction to Dept. of Computer Science, Drexel University May 23, 2018 duction to make duction to Automates certain tasks Usually simple command-line stuff Compiling multi-file programs Archiving/extracting

More information

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash

CS 25200: Systems Programming. Lecture 10: Shell Scripting in Bash CS 25200: Systems Programming Lecture 10: Shell Scripting in Bash Dr. Jef Turkstra 2018 Dr. Jeffrey A. Turkstra 1 Lecture 10 Getting started with Bash Data types Reading and writing Control loops Decision

More information

ENERGY 211 / CME 211. Evolution

ENERGY 211 / CME 211. Evolution ENERGY 211 / CME 211 Lecture 2 September 24, 2008 1 Evolution In the beginning, we all used assembly That was too tedious, so a very crude compiler for FORTRAN was built FORTRAN was still too painful to

More information

COMS 6100 Class Notes 3

COMS 6100 Class Notes 3 COMS 6100 Class Notes 3 Daniel Solus September 1, 2016 1 General Remarks The class was split into two main sections. We finished our introduction to Linux commands by reviewing Linux commands I and II

More information

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell:

Shells. A shell is a command line interpreter that is the interface between the user and the OS. The shell: Shells A shell is a command line interpreter that is the interface between the user and the OS. The shell: analyzes each command determines what actions are to be performed performs the actions Example:

More information

CS 247: Software Engineering Principles. Modules

CS 247: Software Engineering Principles. Modules CS 247: Software Engineering Principles Modules Readings: Eckel, Vol. 1 Ch. 2 Making and Using Objects: The Process of Language Translation Ch. 3 The C in C++: Make: Managing separate compilation Ch. 10

More information

CSE 374 Midterm Exam 11/2/15 Sample Solution. Question 1. (10 points) Suppose the following files and subdirectories exist in a directory:

CSE 374 Midterm Exam 11/2/15 Sample Solution. Question 1. (10 points) Suppose the following files and subdirectories exist in a directory: Question 1. (10 points) Suppose the following files and subdirectories exist in a directory:.bashrc.emacs.bash_profile proj proj/data proj/data/dict.txt proj/data/smalldict.txt proj/notes proj/notes/todo.txt

More information

CAAM 420 Fall 2012 Lecture 15. Roman Schutski

CAAM 420 Fall 2012 Lecture 15. Roman Schutski CAAM 420 Fall 2012 Lecture 15 Roman Schutski December 2, 2012 Table of Contents 1 Using make. Structures. 3 1.1 Makefiles...................................... 3 1.1.1 Syntax...................................

More information

Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable;

Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable; Makefile Makefiles are a simple way to organize code compilation. Using a makefile it is possible to compile several source files to produce an executable; Source (.cc) and header (.h) files can be placed

More information

Projects and Make Files

Projects and Make Files Projects and Make Files Creating an executable file requires compiling the source code into an object* file (file.o) and then linking that file with (other files and) libraries to create the executable

More information

Unix Power Use. Martti Louhivuori. Spring School in Computational Chemistry 2013 PRACE Advanced Training CSC

Unix Power Use. Martti Louhivuori. Spring School in Computational Chemistry 2013 PRACE Advanced Training CSC Unix Power Use Martti Louhivuori Spring School in Computational Chemistry 2013 PRACE Advanced Training Center @ CSC Shell Scripting Martti Louhivuori CSC Tieteen tietotekniikan keskus Oy CSC IT Center

More information

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80

CSE 303 Lecture 2. Introduction to bash shell. read Linux Pocket Guide pp , 58-59, 60, 65-70, 71-72, 77-80 CSE 303 Lecture 2 Introduction to bash shell read Linux Pocket Guide pp. 37-46, 58-59, 60, 65-70, 71-72, 77-80 slides created by Marty Stepp http://www.cs.washington.edu/303/ 1 Unix file system structure

More information

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco

CS 326 Operating Systems C Programming. Greg Benson Department of Computer Science University of San Francisco CS 326 Operating Systems C Programming Greg Benson Department of Computer Science University of San Francisco Why C? Fast (good optimizing compilers) Not too high-level (Java, Python, Lisp) Not too low-level

More information

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2

Section 1: Tools. Kaifei Chen, Luca Zuccarini. January 23, Make Motivation How... 2 Kaifei Chen, Luca Zuccarini January 23, 2015 Contents 1 Make 2 1.1 Motivation............................................ 2 1.2 How................................................ 2 2 Git 2 2.1 Learn by

More information

Generic TriBITS Project, Build, Test, and Install Reference Guide

Generic TriBITS Project, Build, Test, and Install Reference Guide Generic TriBITS Project, Build, Test, and Install Reference Guide Author: Roscoe A. Bartlett Contact: bartlett.roscoe@gmail.com Date: 2018-03-12 Version: tribits_start-2039-g2119b16 Abstract: This document

More information

cget Documentation Release Paul Fultz II

cget Documentation Release Paul Fultz II cget Documentation Release 0.1.0 Paul Fultz II Jun 27, 2018 Contents 1 Introduction 3 1.1 Installing cget.............................................. 3 1.2 Quickstart................................................

More information

CSE 15L Winter Midterm :) Review

CSE 15L Winter Midterm :) Review CSE 15L Winter 2015 Midterm :) Review Makefiles Makefiles - The Overview Questions you should be able to answer What is the point of a Makefile Why don t we just compile it again? Why don t we just use

More information

And You Thought There Couldn t be More C++ Fundamentals of Computer Science

And You Thought There Couldn t be More C++ Fundamentals of Computer Science And You Thought There Couldn t be More C++ Fundamentals of Computer Science Outline Multi-File Programs makefiles Multi-File Programs Advantages If you write classes in separate files (like in Java) you

More information

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs

Table of contents. Our goal. Notes. Notes. Notes. Summer June 29, Our goal is to see how we can use Unix as a tool for developing programs Summer 2010 Department of Computer Science and Engineering York University Toronto June 29, 2010 1 / 36 Table of contents 1 2 3 4 2 / 36 Our goal Our goal is to see how we can use Unix as a tool for developing

More information