\documentclass[13pt,aspectratio=169]{beamer}

%%%%%%%%%%%%%%%%%%%
% Commands/macros %
%%%%%%%%%%%%%%%%%%%
\newcommand{\link}[1]{
  \begin{flushright}
    \scriptsize{#1}
  \end{flushright}
}

\newcommand{\header}[1]{
  \hspace{-1em}\textit{#1:}
}

\newcommand{\sheader}[1]{
  \vspace{1.5em}
  \header{#1}
}

\newcommand{\screen}[1]{
  \setlength{\leftmargin}{0pt}
  \setlength{\rightmargin}{0pt}
  \begin{center}
    \includegraphics[height=3.0in,width=4.25in,keepaspectratio]{#1}
  \end{center}
}

%%%%%%%%%%%%%%%%
% Header/theme %
%%%%%%%%%%%%%%%%
%\usetheme[
%  pageofpages=of,
%  alternativetitlepage=true,
%]{Torino}
\setbeamertemplate{navigation symbols}{}
\setbeamertemplate{footline}{}
\setbeamersize{text margin left=20mm}
\setbeamersize{text margin right=10mm}
\setbeamerfont{frametitle}{size={\fontsize{15}{16}}}

% Import packages
\usepackage[english]{babel}
\usepackage[latin1]{inputenc}
\usepackage{times}
\usepackage[T1]{fontenc}
\usepackage{graphics}
\usepackage{hyperref}
\usepackage{ulem}
\usepackage{listings}

%%%%%%%%%%%%%%%%%%%%
% Title page setup %
%%%%%%%%%%%%%%%%%%%%
\subject{%
  c,
  compile,
  unix,
}

\keywords{%
  c,
  cc
  make,
  autotools,
}

\title[C Compiling]{%
  C Compiling and More!
}

\author[Spencer]{%
  Andy Spencer
}

\date[2018-12-15]{%
  December 15, 2018 \\
  \small{San Fernando Valley Linux Users Group}
}

%%%%%%%%%%%%%%%%%
% Content pages %
%%%%%%%%%%%%%%%%%

\begin{document}

%%%%%%%%%%%%%%%%
% Introduction %
%%%%%%%%%%%%%%%%

\begin{frame}[plain]
  \titlepage
\end{frame}

%%%%%%%%%%
% Why C? %
%%%%%%%%%%

\section{Why C?}

\begin{frame}
  Why C
\end{frame}

%%%%%%%%%%%%%%%%%%%%%
% Compiled software %
%%%%%%%%%%%%%%%%%%%%%
% - compilers vs interpreters
% - C compile steps (cpp, cc, as, ld)
% - executable formats (ELF)
% - dynamic and static linking

\section{Compiled software}

\begin{frame}{Compilers vs Interpreters}
  \structure{Interpreters}
  \begin{itemize}
    \item Bash, Python, Ruby
    \item Interpreter runs and follows the instructions
    \item The interpreter is generally compiled
    \item Advantages: advanced languages, lot of features, easy development
  \end{itemize}

  \structure{Compilers}
  \begin{itemize}
    \item C/C++, Fortran, Haskell, Rust, (GCC / LLVM)
    \item Translates one language to another
    \item Often self compiling (needs bootstrapping)
    \item Advantages: fast, deterministic, more static analysis
  \end{itemize}
\end{frame}

\begin{frame}{C compiling steps}
  \begin{itemize}
    \item[cpp] C Pre-Processor
      \begin{itemize}
        \item Text based macros (\#include, \#define)
      \end{itemize}

    \item[cc] C Compiler
      \begin{itemize}
        \item Translates C to Assembly
        \item Register allocation
        \item Memory layout (structs/unions)
        \item Function calling conventions
      \end{itemize}

    \item[as] Assembler
      \begin{itemize}
        \item Translates Assembly to object code
        \item Handles labels, addresses, and mnemonics
      \end{itemize}

    \item[ld] Linker
      \begin{itemize}
        \item Combines object files
        \item Resolves symbols and relocations
      \end{itemize}

  \end{itemize}
\end{frame}

\begin{frame}{Executable formats}
  \begin{itemize}
    \item[ELF] Executable and linking formats (Linux)
    \item[COFF] Common Object File Format (Unix)
    \item[PE] Portable Executable (Windows, EFI)
    \item[Mach-O] Mach Object (Mac OSX)
  \end{itemize}

  \textit{There are also DWARFs... \\
          "Debugging With Attributed Record Formats"}
\end{frame}

\begin{frame}{Executable formats}
  \screen{elf.pdf}
\end{frame}

\begin{frame}{Dynamic vs static}
  \begin{itemize}
    \item Static linking
    \item Dynamic linking
    \item Modules
    \item System calls
  \end{itemize}
\end{frame}

%%%%%%%%%%%%%%%%%
% Build systems %
%%%%%%%%%%%%%%%%%

\section{Build systems}

\begin{frame}{C is for CC}
  \structure{Running CC manually}
  \begin{itemize}
    \item Compiling manually...
    \item Works for very small program.
    \item cc hello.c
    \item gcc -Wall -o hello hello.c
  \end{itemize}

  \structure{Scripting}
  \begin{itemize}
    \item Why not just write a script for this?
    \item Dependency tracking, parallel execution.
  \end{itemize}
\end{frame}

\begin{frame}{Make}
  \begin{itemize}
    \item Generic dependency tracker.
    \item Except GNU Make, which has tons of dumb rules.
    \item Configured with -DOPTION or config.mk
  \end{itemize}
\end{frame}

\begin{frame}{autotools}
  \structure{Overview}
  \begin{itemize}
    \item Designed to be "portable".
    \item Good support for configuration.
    \item Handles all the weird corner cases.
    \item Nobody likes it but everybody uses it.
  \end{itemize}
  \structure{Usage}
  \begin{itemize}
    \item {[./autogen.sh]}
    \item ./configure --help
    \item make
    \item make install
  \end{itemize}
\end{frame}

\begin{frame}{kconfig}
  \begin{itemize}
    \item Started out in the Linux kernel.
    \item Even better support for configuration.
    \item Provides nice menu interfaces.
  \end{itemize}
\end{frame}

\begin{frame}{others}
  \begin{itemize}
    \item cmake
    \item scons
    \item bazel
    \item ant
    \item maven
    \item gradle
  \end{itemize}
\end{frame}

\end{document}
