I am moving a C++ project from Windows to Linux and I now need to create a build/make file. I have never created a build/make file before. I also need to include Boost libra
I would not recommend writing your own Makefiles. Instead, use a build system like CMake or SCons.
It is worth noting that those tools are cross-platform. So you can use the same build system on Linux and Windows.
I prefer a standard project description such as this one. In other words, I believe the focus on a makefile is too narrow.
The virtue of this project description is simplicity. It can be adapted to more complex projects with sub-directories using make -C subdir -f Makefile all in an all target. The subdir is of course your sub-directory with code that should be built.
The author points out that creating and maintaining build environments are not productive, so you want something that is easy to modify and that you understand. I would not necessarily set out to be a makefile expert. I don't think that's as useful as many think.
I like hiltmon's idea so much I'm turning it into a shell script. I may write the finished project in Python and ask the author if I can contribute to GitHub.
Using @Job 's idea, I recommend you to leave it for some IDE to do. For example, Build a project in Eclipse CDT and use it's auto-generated make file. Then, you can kearn it and by the time change it to fit exactly your needs.
A very simple GNU makefile follows:
CPPFLAGS += -Isome_include_path
CXXFLAGS += -O3
LDFLAGS += -Lsome_link_path -lsome_lib -lboost_filesystem
all: binary_name
binary_name: foo.o bar.o john.o
CPPFLAGS are flags that are applied to the C Preprocessor. Things like include paths.CXXFLAGS are flags that are applied to the C++ compiler. Things like optimization levels.LDFLAGS are flags that applied to the linker. Things like external libraries (boost_filesystem) and other libraries. Also, the paths to those libraries.make all rule, which is the default. In make, the first rule is the default.binary_name is the name of your binary.binary_name depends on 3 files: foo.o, bar.o, john.o.*.o because gnu make has an implicit rule for those.To use make, you would create a file named Makefile with the contents listed above. To build, you would run make in that directory.
As an aside (and as others have mentioned), I would recommend moving away from make if possible. There are better systems out there. The main benefit of make is that it's everywhere. However, if management requires it, then management requires it.
(Note that the GNU Make += notation is not always portable to other versions of Make. However, make on Linux is GNU Make.)
Given your edit, here's an example with the files that you note. The one caution is that the line beginning with $(CXX) should begin with a TAB character!
LDFLAGS := -lboost_filesystem
CXXFLAGS := -O3 -Wall
CPPFLAGS :=
all: program
program: simple_ls.o converter.o rawr.o
$(CXX) -o $< $^ $(LDFLAGS)
simple_ls.o: simple_ls.cpp rawr.h simple_ls.h 2dquicksort.h
converter.o: converter.cpp rawr.h simple_ls.h 2dquicksort.h
rawr.o: rawr.cpp rawr.h simple_ls.h 2dquicksort.h