From e4bcf31ffe1cfcb48b161adb08dd30b77f38d1d8 Mon Sep 17 00:00:00 2001 From: San Jacobs Date: Sat, 26 Feb 2022 16:22:34 +0100 Subject: Set up basic C++ project --- makefile | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 makefile (limited to 'makefile') diff --git a/makefile b/makefile new file mode 100644 index 0000000..ef4d837 --- /dev/null +++ b/makefile @@ -0,0 +1,27 @@ +# INCLUDE is where you find the headerfiles for the libs you're using. They are used during compilation. +INCLUDE=-I /usr/include/boost/ + +# LIBDIR is where you can find the linkable objects or whatever. They are used for the linking stage. +LIBDIR=-L /usr/lib/x86_64-linux-gnu/ + +# LIBS are the libs you are using written with a -l and then ignoring the lib-part at the beginning of the file's name. +# So "libboost_date_time.a" will be just "-lboost_date_time" +LIBS=-lboost_date_time + +# Sources are the source code files. Only the .cpp files, becuase the .h files are included into them during pre-processing. +SOURCES=$(wildcard src/*.cpp) +OBJDIR=obj/ +OBJECTS=$(patsubst src/%.cpp, $(OBJDIR)%.o, $(SOURCES)) +# This last line creates an identical list of objects based on the list of .cpp files. + +a.out: $(OBJECTS) + g++ $(LIBDIR) $(LIBS) $(OBJECTS) + +$(OBJECTS): obj/%.o : src/%.cpp + g++ $(INCLUDE) -c $< -o $@ + +clean: + rm obj/*.o + +cleanall: + rm obj/*.o a.out -- cgit v1.2.1