% All macros commented                %  1
\newcommand{\paperpdf}{}              %  2
\newcommand{\papertex}{}              %  3
\newcommand{\projecttex}{}            %  4
\newcommand{\verifytex}{}             %  5
\newcommand{\initializetex}{}         %  6
\newcommand{\downloadtex}{}           %  7
\newcommand{\inputtwo}{}              %  8
\newcommand{\inputsconf}{}            %  9
\newcommand{\analysisonetex}{}        % 10
\newcommand{\outoneb}{}               % 11
\newcommand{\outonebdep}{}            % 12
\newcommand{\inputone}{}              % 13
\newcommand{\inputonedep}{}           % 14
\newcommand{\analysistwotex}{}        % 15
\newcommand{\outtwob}{}               % 16
\newcommand{\outtwobdep}{}            % 17
\newcommand{\analysisthreetex}{}      % 18
\newcommand{\analysisthreeouts}{}     % 19
\newcommand{\outtwoa}{}               % 20
\newcommand{\outtwoadep}{}            % 21
\newcommand{\outthreeadep}{}          % 22





\begin{tikzpicture}[
  line width=1.5pt,
  black!50,
  text=black,
]

  %% Use small fonts
  \footnotesize

  %% These white lines are only added to fix the vertical position of
  %% the figure so it doesn't change as we add more boxes.
  \draw [white] (-7.5,0) -- (7.4,0);
  \draw [white] (0,-4.7) -- (0,5.7);

  %% top-make.mk
  \node [at={(-0.05cm,2mm)},
         rectangle,
         very thick,
         text centered,
         font=\ttfamily,
         text width=2.8cm,
         minimum height=7.8cm,
         draw=green!50!black!50,
         minimum width=\linewidth,
         fill=black!10!green!2!white,
         label={[shift={(0,-5mm)}]\texttt{top-make.mk}}] {};

  %% Work-horse Makefiles. -5.6 -> -5.73 = -0.13
  \node (initializemk) [node-makefile, at={(-5.73cm,-1.3cm)},
    label={[shift={(0,-5mm)}]\texttt{initialize.mk}}] {};
  \node (downloadmk)   [node-makefile, at={(-2.93cm,-1.3cm)},
    label={[shift={(0,-5mm)}]\texttt{download.mk}}] {};
  \node (analysis1mk)  [node-makefile, at={(-0.13cm,-1.3cm)},
    label={[shift={(0,-5mm)}]\texttt{format.mk}}] {};
  \node (analysis2mk)  [node-makefile, at={(2.67cm,-1.3cm)},
    label={[shift={(0,-5mm)}]\texttt{demo-plot.mk}}] {};
  \node [opacity=0.6] (analysis3mk)  [node-makefile, at={(5.47cm,-1.3cm)},
    label={[shift={(0,-5mm)}, opacity=0.6]\texttt{another-step.mk}}] {};

  %% verify.mk
  \node [at={(-5.3cm,-2.8cm)},
         thick,
         rectangle,
         text centered,
         font=\ttfamily,
         text width=2.45cm,
         minimum width=3.5cm,
         minimum height=1.3cm,
         draw=green!50!black!50,
         fill=black!10!green!12!white,
         label={[shift={(1cm,-5mm)}]\texttt{verify.mk}}] {};

  %% Paper.mk
  \node [at={(2.67cm,-2.8cm)},
         thick,
         rectangle,
         text centered,
         text width=2.8cm,
         minimum width=8.5cm,
         minimum height=1.3cm,
         draw=green!50!black!50,
         fill=black!10!green!12!white,
         font=\ttfamily,
         label={[shift={(0,-5mm)}]\texttt{paper.mk}}] {};

  %% paper.pdf
  \ifdefined\paperpdf
  \node (paperpdf) [node-terminal, at={(5.47cm,-2.9cm)}] {paper.pdf};
  \fi

  %% paper.tex
  \ifdefined\papertex
  \node (reftex) [node-nonterminal, at={(2.67cm,-4.2cm)}] {references.tex};
  \node (papertex) [node-nonterminal, at={(5.47cm,-4.2cm)}] {paper.tex};
  \node (papertex-north) [node-point, at={(5.47cm,-3.58cm)}] {};
  \draw [rounded corners] (reftex) |- (papertex-north);
  \draw [->] (papertex) -- (paperpdf);
  \fi

  %% project.tex
  \ifdefined\projecttex
  \node (projecttex) [node-terminal, at={(-0.13cm,-2.9cm)}] {project.tex};
  \draw [->] (projecttex) -- (paperpdf);
  \fi

  %% verify.tex
  \ifdefined\verifytex
  \node (verifytex) [node-terminal, at={(-5.73cm,-2.9cm)}] {verify.tex};
  \draw [->] (verifytex) -- (projecttex);
  \fi

  %% Initialize.tex
  \ifdefined\initializetex
  \node (initializetex) [node-terminal, at={(-5.73cm,-0.8cm)}] {initialize.tex};
  \node (initialize-south) [node-point, at={(-5.73cm,-1.5cm)}] {};
  \draw [->] (initializetex) -- (verifytex);
  \node [anchor=west, at={(-7.05cm,2.30cm)}] {Basic project info};
  \node [anchor=west, at={(-7.05cm,1.95cm)}] {(e.g., Git commit).};
  \node [anchor=west, at={(-7.05cm,1.10cm)}] {Also defines};
  \node [anchor=west, at={(-7.05cm,0.75cm)}] {project structure};
  \node [anchor=west, at={(-7.05cm,0.40cm)}] {(for \texttt{*.mk} files).};
  \fi

  %% download.tex
  \ifdefined\downloadtex
  \node (downloadtex) [node-terminal, at={(-2.93cm,-0.8cm)}] {download.tex};
  \draw [rounded corners, -] (downloadtex) |- (initialize-south);
  \fi

  %% input-2.dat
  \ifdefined\inputtwo
  \node (input2) [node-terminal, at={(-2.93cm,1.9cm)}] {menke20.xlsx};
  \draw [->] (input2) -- (downloadtex);
  \fi

  %% INPUTS.conf
  \ifdefined\inputsconf
  \node (INPUTS) [node-nonterminal, at={(-2.93cm,4.6cm)}] {INPUTS.conf};
  \node (input2-west) [node-point, at={(-4.33cm,1.9cm)}] {};
  \draw [->,rounded corners] (INPUTS.west) -| (input2-west) |- (input2);
  \fi

  %% analysis1.tex
  \ifdefined\analysisonetex
  \node (a1tex) [node-terminal, at={(-0.13cm,-0.8cm)}] {format.tex};
  \draw [rounded corners, -] (a1tex) |- (initialize-south);
  \fi

  %% out1b.dat
  \ifdefined\outoneb
  \node (out1b) [node-terminal, at={(-0.13cm,1.1cm)}] {menke20-table-3.txt};
  \draw [->] (out1b) -- (a1tex);
  \fi

  %% outonebdep
  \ifdefined\outonebdep
  \node (out1b-west) [node-point, at={(-1.53cm,1.1cm)}] {};
  \draw [->, rounded corners] (input2) |- (out1b);
  \fi

  %% analysis2.tex
  \ifdefined\analysistwotex
  \node (a2tex) [node-terminal, at={(2.67cm,-0.8cm)}] {demo-plot.tex};
  \draw [rounded corners, -] (a2tex) |- (initialize-south);
  \fi

  %% out-2b.dat
  \ifdefined\outtwob
  \node (menkedemoyear) [node-nonterminal, at={(2.67cm,4.6cm)}] {menke-demo-year.conf};
  \node (a2tex-west) [node-point, at={(1.27cm,-0.8cm)}] {};
  \node (out2b) [node-terminal, at={(2.67cm,0.3cm)}] {tools-per-year.txt};
  \draw [->] (out2b) -- (a2tex);
  \draw [->,rounded corners] (menkedemoyear.west) -| (a2tex-west) |- (a2tex);
  \fi

  %% out-2b dependencies
  \ifdefined\outtwobdep
  \draw [->,rounded corners,] (out1b.south) |- (out2b);
  \fi

  %% analysis3.tex
  \ifdefined\analysisthreetex
  \node [opacity=0.6] (a3tex) [node-terminal, at={(5.47cm,-0.8cm)}] {another-step.tex};
  \draw [opacity=0.6, rounded corners, -, dashed] (a3tex) |- (initialize-south);
  \fi

  %% Outputs of analysis3
  \ifdefined\analysisthreeouts
  \node [opacity=0.6] (out3a) [node-terminal, at={(5.47cm,2.7cm)}] {out-3a.dat};
  \node [opacity=0.6] (out3b) [node-terminal, at={(5.47cm,1.1cm)}] {out-3b.dat};
  \node (a3tex-east) [node-point, at={(6.87cm,-0.8cm)}] {};
  \draw [opacity=0.6, ->,rounded corners, dashed] (out3a.east) -| (a3tex-east) |- (a3tex);
  \draw [opacity=0.6, ->, dashed] (out3b) -- (a3tex);
  \fi

  %% out-2a.dat
  \ifdefined\outtwoa
  \node [opacity=0.6] (out2a) [node-terminal, at={(2.67cm,1.9cm)}] {demo-out.dat};
  \draw [opacity=0.6, ->, rounded corners, dashed] (out2a.south) |- (out3b);
  \fi

  %% Dependencies of out-2a
  \ifdefined\outtwoadep
  \node (out2a-west) [node-point, at={(1.27cm,1.9cm)}] {};
  \draw [opacity=0.6, ->, dashed] (input2) -- (out2a);
  \fi

  %% Dependencies of out-3a
  \ifdefined\outthreeadep
  \node [opacity=0.6] (out3a-west) [node-point, at={(4.07cm,2.7cm)}] {};
  \draw [opacity=0.6, ->,rounded corners, dashed] (input2) |- (out3a);
  \node [opacity=0.6] (a3conf1) [node-nonterminal, at={(5.47cm,4.6cm)}]  {param-3.conf};
  \draw [opacity=0.6, rounded corners, dashed] (a3conf1.west) -| (out3a-west) |- (out3a);
  \fi
\end{tikzpicture}
