Modularize the source code.

This makes greeting generation separate from greeting output, which
makes it easier to unit-test greeting generation.

Change-Id: Ice07f45ed0e9274bd4d4b3cd031cb37fffd34a5e
diff --git a/Jenkinsfile b/Jenkinsfile
index 5590199..fc6bb76 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -43,7 +43,7 @@
     stage('Archive artifacts') {
       steps {
         container('baker') {
-          archiveArtifacts 'hello-world-ng'
+          archiveArtifacts 'exe/hello-world-ng'
         }
       }
     }
diff --git a/exe/hello-world-ng.cpp b/exe/hello-world-ng.cpp
new file mode 100644
index 0000000..f59229c
--- /dev/null
+++ b/exe/hello-world-ng.cpp
@@ -0,0 +1,9 @@
+#include <mod/greeting.hpp>
+
+#include <iostream>
+#include <cstdlib>
+
+int main(int, char **) {
+  std::cout << greeting::make_greeting("world") << std::endl;
+  return EXIT_SUCCESS;
+}
diff --git a/hello-world-ng.cpp b/hello-world-ng.cpp
deleted file mode 100644
index d6e2ec3..0000000
--- a/hello-world-ng.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-#include <iostream>
-#include <cstdlib>
-
-int main(int, char **) {
-  std::cout << "Hello world!" << std::endl;
-  return EXIT_SUCCESS;
-}
diff --git a/makefile b/makefile
index 539a1ee..26607eb 100644
--- a/makefile
+++ b/makefile
@@ -1,11 +1,23 @@
 .PHONY: all clean
 
-all: hello-world-ng
+CXX = c++
+LDFLAGS =
+CXXFLAGS = -I.
+
+EXE = exe/hello-world-ng
+
+mod_OBJ = mod/greeting.o
+hello_world_ng_OBJ = exe/hello-world-ng.o
+
+OBJ = $(hello_world_ng_OBJ) $(mod_OBJ)
+
+all: $(EXE)
 
 clean:
-	$(RM) hello-world-ng.o hello-world
+	$(RM) $(OBJ)
+	$(RM) $(EXE)
 
-hello-world-ng: hello-world-ng.o
+exe/hello-world-ng: $(hello_world_ng_OBJ) $(mod_OBJ)
 	$(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $^
 
 %.o: %.cpp
diff --git a/mod/greeting.cpp b/mod/greeting.cpp
new file mode 100644
index 0000000..a8101b8
--- /dev/null
+++ b/mod/greeting.cpp
@@ -0,0 +1,13 @@
+#include "greeting.hpp"
+
+#include <sstream>
+
+namespace greeting {
+
+std::string make_greeting(std::string const& greetee) {
+  std::ostringstream out;
+  out << "Hello " << greetee << "!";
+  return out.str();
+}
+
+}
diff --git a/mod/greeting.hpp b/mod/greeting.hpp
new file mode 100644
index 0000000..c9d1a3d
--- /dev/null
+++ b/mod/greeting.hpp
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <string>
+
+namespace greeting {
+
+std::string make_greeting(std::string const& greetee);
+
+}