CS410: Build Systems
W. Michael Petullo
University of Wisconsin–La Crosse
As of February 15, 2021 Java Arrays: No Screenshots
I hereby declare a moratorium on screenshots of source code. Either copy and paste your code into the body of an email or commit your code to Git. This allows me to inspect, compile, and run your code. It also demonstrates that you understand the most efficient way to use your tools.
!
Sending a photograph of your screen is out of the question! Build Systems: Package Managers
Red Hat-derived (.rpm) Debian-derived (.deb) List available dnf list apt-cache pkgnames dnf list *FOO* apt-cache pkgnames FOO Summarize dnf info PACKAGE apt-cache show PACKAGE Install dnf install PACKAGE apt install PACKAGE Remove dnf remove PACKAGE apt remove PACKAGE Determine owner rpm -qf /usr/bin/PROGRAM dpkg -S /usr/bin/PROGRAM Synchronize cache apt update Update dnf update apt dist-upgrade
Other package managers: opkg (OpenWrt), apk (Alpine), pkg * (OpenBSD), ... Build Systems: Containers
Description Podmancommand Build and run an interactive container podman run -it fedora List running containers podman ps -a Remove container podman rm ID Remove image podman image rm fedora Build Systems: GNOME Software Build Systems: tar
© Randall Munroe
Create gzip-compressed tarball: tar czvf foo.tar.gz foo/ Extract gzip-compressed tarball: tar xzvf foo.tar.gz
Replace z with Z for bzip2-compressed tarball, or drop entirely if using GNU tar. Build Systems: make
1 all: true false The make utility dates back to 1976, as it was 3 true.o: true.c Unix make 4 $ (CC) −c −o $@ $ˆ included in early versions of . The utility reads a build definition from a Makefile. 6 false.o: false.c 7 $ (CC) −c −o $@ $ˆ
9 e.o: e.c ◮ Capture build instructions 10 $ − − $ $ (CC) c o @ ˆ ◮ Build only what has changed 12 true: true.o e.o ◮ Express acyclic directed dependency graph 13 $ (CC) −o true $ˆ
15 false: false.o e.o 16 $ (CC) −o false $ˆ Each block defines a target and its dependencies before defining zero or more shell commands that 18 clean : build the target from its dependencies. 19 rm −f ∗ .o true false Build Systems: GNU autotools
The GNU autotools allow for the generation of platform-specific Makefiles and header files. This allows for a program to compile differently on different platforms.
Input: Output:
Makefile.am automake Makefile.in
configure.ac aclocal aclocal.m4 config.h
autoconf configure
Makefile autoheader config.h.in Build Systems: GNU autotools
bin PROGRAMS = caty #include
caty SOURCES = \ #include ”cat.h” main.c \ #include ”config.h” cat.c size t cat(char ∗d, const char ∗s, size t sz) AC INIT([caty], [0.0.1]) { AC OUTPUT #ifdef HAVE STRLCAT AM INIT AUTOMAKE return strlcat(d, s, sz); #else AC CONFIG HEADERS( config .h) size t n = strlen(d); strncat(d, s, sz − strlen(d) − 1); AC PROG CC return n + strlen(s); AC PROG INSTALL #e n d i f } AC CHECK FUNCS( strlcat ) This program will compile differently, depending on AC OUTPUT( Makefile ) how the configure script defines HAVE STRLCAT. Build Systems: Other Systems
General-purpose CMake, SCons, Meson/Ninja Java Ant, Maven, Gradle Build Systems: Assignments
Discussed GNU Manifesto; completed Aquinas editor, hello in C, and io in C
Graded Homework Aquinas: make and autotools due next Tuesday Reading Linux history and Torvalds v. Tanenbaum before next Tuesday
https://www.flyn.org/courses/cs410-2021-spring/schedule