Jump to content

Making a make file?


Josh
 Share

Recommended Posts

I've never actually had to deal with creating these before. I need a makefile that gives me separate object files for each source code file, so I can do a partial rebuild. Right now my Linux build takes several minutes to compile for any little change I made. The information on these is not very clear or readily available. This is my GCC command line.

How do I turn this into a working makefile?

"command": "/usr/bin/g++",
            "args": [
                "./AppKit.cpp",                
                "./Libraries/Plugin SDK/GMFSDK.cpp",
                "./Libraries/Plugin SDK/MemReader.cpp",
                "./Libraries/Plugin SDK/MemWriter.cpp",
                "./Libraries/Plugin SDK/TextureInfo.cpp",
                "./Libraries/Plugin SDK/Utilities.cpp",
                "./Libraries/Plugin SDK/half/half.cpp",
                "./Libraries/s3tc-dxt-decompressionr/s3tc.cpp",
                "./Libraries/stb_dxt/stb_dxt.cpp",                
                "./Classes/Object.cpp",
                "./Classes/Math/Math_.cpp",
                "./Classes/Math/Vec2.cpp",
                "./Classes/Math/Vec3.cpp",
                "./Classes/Math/Vec4.cpp",
                "./Classes/Math/iVec2.cpp",
                "./Classes/Math/iVec3.cpp",
                "./Classes/Math/iVec4.cpp",
                "./Classes/String.cpp",
                "./Classes/WString.cpp",
                "./Classes/Display.cpp",
                "./Classes/IDSystem.cpp",
                "./Classes/JSON.cpp",
                "./Functions.cpp",
                "./Classes/GUI/Event.cpp",
                "./Classes/GUI/EventQueue.cpp",
                "./Classes/Language.cpp",
                "./Classes/FileSystem/Stream.cpp",
                "./Classes/FileSystem/BufferStream.cpp",
                "./Classes/FileSystem/FileSystemWatcher.cpp",
                "./Classes/GameEngine.cpp",
                "./Classes/Clock.cpp",
                "./Classes/Buffer.cpp",
                "./Classes/GUI/Interface.cpp",
                "./Classes/GUI/Widget.cpp",
                "./Classes/GUI/Panel.cpp",
                "./Classes/GUI/Slider.cpp",
                "./Classes/GUI/Label.cpp",
                "./Classes/GUI/Button.cpp",
                "./Classes/GUI/TextField.cpp",
                "./Classes/GUI/TreeView.cpp",
                "./Classes/GUI/TextArea.cpp",
                "./Classes/GUI/Tabber.cpp",
                "./Classes/GUI/ListBox.cpp",
                "./Classes/GUI/ProgressBar.cpp",
                "./Classes/GUI/ComboBox.cpp",
                "./Classes/GUI/Menu.cpp",
                "./Classes/Window/LinuxWindow.cpp",
                "./Classes/Timer.cpp",
                "./Classes/Process.cpp",
                "./Classes/FileSystem/StreamBuffer.cpp",
                "./Classes/Multithreading/Thread.cpp",
                "./Classes/Multithreading/Mutex.cpp",
                "./Classes/Loaders/Loader.cpp",
                "./Classes/Loaders/DDSTextureLoader.cpp",
                "./Classes/Assets/Asset.cpp",
                "./Classes/Plugin.cpp",
                "./Classes/Assets/Font.cpp",
                "./Classes/FileSystem/Package.cpp",
                "./Classes/Graphics/Pixmap.cpp",
                "./Classes/Graphics/Icon.cpp",
                "-D_ULTRA_APPKIT",              
                "-I\".\"",
                "-lm", "-lX11", "-lpthread",
                "-oAppKit",
                "-no-pie", "-g"
            ],

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

I recall looking into this a while back. A makefile is more of a script file and you can execute other bash commands before the g++ call.

Every cpp file thrown at the compiler gets outputted as a .o file. Then you collect all the .o files and build them into the executable.

There is most likely a bash command to help determine what .cpp files are new/changed and only rebuild the needed .o files.

I haven't done this, and using a makefile generator just makes it all confusing. But I hope this was a bit insightful. If nobody else has better solutions, I can ask around.

Cyclone - Ultra Game System - Component PreprocessorTex2TGA - Darkness Awaits Template (Leadwerks)

If you like my work, consider supporting me on Patreon!

Link to comment
Share on other sites

I have never compiled C++ code with any other compiler (I've never compiled C++ code on Linux either), I've never put a shirt on back to front, I've also never eaten cereal without milk (I'll stop with the never ever's).

I took a look at this for you and I gotta say, it made me feel sick, it shook me to my very core ?

All the years of technological advances in GUI's and fancy displays and we are back to the terminal window.

Anyway, from some reading and watching it didn't seem too bad to pick up. I will warn you though this is my first time but, this should hopefully give you a starting point and if this doesn't help then I'm sorry and I will be buying one of those Men in Black mind erasing pens and we will all cuddle in a circle waiting for that big flash.

From what I found, the general layout of these makefiles tend to follow a similar pattern, where they are made up of a set of rules:

targets: prerequisites
	command
	command
	command
  • Targets are the files you want to output (similar to building an executable with Visual Studio, your target application type would be a .exe).
  • Prerequisites are the files you would like to track, consider them dependencies that you need to use in order for any commands to work.
  • Commands are the functions run to produce the output.

Lets say you have like 5 files, a main.cpp and two other .cpp and .h files (lets call them functions.cpp and functions.h and utilities.cpp and utilities.h). Those files when compiled make ".o" files (I'm pretty sure you are probably aware of this, me on the other hand ... I had no clue). If we extend this to the above pattern to achieve an automated build by calling the "make" command from your projects directory:

# output is our target that is built from our C/C++ source files, it depends on all other source files that are included within it
output: main.o functions.o utilities.o
	g++ main.o functions.o utilities.o -o output

# main.o is output only when main.cpp is changed (main.o depends on main.cpp), we run g++ -c main.cpp to produce main.o
main.o: main.cpp
	g++ -c main.cpp

# functions.o is output only when functions.cpp or functions.h is changed (functions.o depends on functions.cpp and functions.h), we run g++ -c functions.cpp to produce functions.o
functions.o: functions.cpp functions.h
	g++ -c functions.cpp

# utilities.o is output only when utilities.cpp or utilities.h is changed (utilities.o depends on utilities.cpp and utilities.h), we run g++ -c utilities.cpp to produce utilities.o
utilities.o: utilties.cpp utilities.h
	g++ -c utilities.cpp

# clean is a command that can be executed to remove all ".o" files (consider this to be very similar to running "Clean solution" in Visual Studio, you know ... when it removes all of your intermediary files and folders)
clean:
	rm *.o output

There are some subtle syntax shenanigans at play here too, like you have to have 4 spaces before each command.

I found this for you which goes further than my explanation and there are some nice code examples too. Depending on how much time you really want to put into this I'm sure you could do some very complex automated build tasks (and it would certainly set you up in the long run). What I mentioned above though should get you by, although all those source files you have would be really tedious to have to type, you can do something called "pattern rules" which can form expressions to define more complex rules than the ones I wrote above.

Good luck!

Link to comment
Share on other sites

Example how to do using cmake which generates different kind of makefiles.

Create a CmakeList.txt file in your project with content below and modify/add your sources.

Will generate the makefiles:

cmake .

then build:

make

 

project(nerva_repl)


include_directories(source)

set(LIBS_PATH "${CMAKE_CURRENT_SOURCE_DIR}/libs")

include_directories("${LIBS_PATH}/include")
#include_directories("${LIBS_PATH}/include/exlib")

IF(UNIX)
    set(CMAKE_CXX_FLAGS "-std=c++11")

    #link_directories("${LIBS_PATH}/unix/exlib/")

    add_executable (nerva source/main.c source/cmd_handlers.c source/nerva_utils.c source/sqlite3.c)

    target_link_libraries(nerva m dl pthread)

ELSE (WIN32)
    #link_directories("${LIBS_PATH}/windows/exlib/")

    add_executable (nerva source/main.c source/main.c source/cmd_handlers.c source/nerva_utils.c source/sqlite3.c)

    target_link_libraries(nerva)

ENDIF (UNIX)

set(CMAKE_BUILD_TYPE Debug)

cmake is great if you want a build system that will work on all platforms , can generate also visual studio projects on windows.

But it has its quirks i seen in some big projects using it (and that require some time reading docs or workarounds).

 

So hand written makefile is  good option also if you want just for linux (or mac) and full control of what is going on.

I made this with Leadwerks/UAK:

Structura Stacky Desktop Edition

Website:

Binary Station

Link to comment
Share on other sites

  • 3 weeks later...

I had the most luck with this online generator:
https://solver.assistedcoding.eu/makefilegen

But I can't get the header search paths working.

OBJS	= ./AppKit.o SDK/GMFSDK.o SDK/MemReader.o SDK/MemWriter.o SDK/TextureInfo.o SDK/Utilities.o SDK/half/half.o ./Libraries/s3tc-dxt-decompressionr/s3tc.o ./Libraries/stb_dxt/stb_dxt.o ./Classes/Object.o ./Classes/Math/Math_.o ./Classes/Math/Vec2.o ./Classes/Math/Vec3.o ./Classes/Math/Vec4.o ./Classes/Math/iVec2.o ./Classes/Math/iVec3.o ./Classes/Math/iVec4.o ./Classes/String.o ./Classes/WString.o ./Classes/Display.o ./Classes/IDSystem.o ./Classes/JSON.o ./Functions.o ./Classes/GUI/Event.o ./Classes/GUI/EventQueue.o ./Classes/Language.o ./Classes/FileSystem/Stream.o ./Classes/FileSystem/BufferStream.o ./Classes/FileSystem/FileSystemWatcher.o ./Classes/GameEngine.o ./Classes/Clock.o ./Classes/Buffer.o ./Classes/GUI/Interface.o ./Classes/GUI/Widget.o ./Classes/GUI/Panel.o ./Classes/GUI/Slider.o ./Classes/GUI/Label.o ./Classes/GUI/Button.o ./Classes/GUI/TextField.o ./Classes/GUI/TreeView.o ./Classes/GUI/TextArea.o ./Classes/GUI/Tabber.o ./Classes/GUI/ListBox.o ./Classes/GUI/ProgressBar.o ./Classes/GUI/ComboBox.o ./Classes/GUI/Menu.o ./Classes/Window/LinuxWindow.o ./Classes/Timer.o ./Classes/Process.o ./Classes/FileSystem/StreamBuffer.o ./Classes/Multithreading/Thread.o ./Classes/Multithreading/Mutex.o ./Classes/Loaders/Loader.o ./Classes/Loaders/DDSTextureLoader.o ./Classes/Assets/Asset.o ./Classes/Plugin.o ./Classes/Assets/Font.o ./Classes/FileSystem/Package.o ./Classes/Graphics/Pixmap.o ./Classes/Graphics/Icon.o ./Libraries/CppTimer/CppTimer.o
SOURCE	= ./AppKit.cpp SDK/GMFSDK.cpp SDK/MemReader.cpp SDK/MemWriter.cpp SDK/TextureInfo.cpp SDK/Utilities.cpp SDK/half/half.cpp ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp ./Libraries/stb_dxt/stb_dxt.cpp ./Classes/Object.cpp ./Classes/Math/Math_.cpp ./Classes/Math/Vec2.cpp ./Classes/Math/Vec3.cpp ./Classes/Math/Vec4.cpp ./Classes/Math/iVec2.cpp ./Classes/Math/iVec3.cpp ./Classes/Math/iVec4.cpp ./Classes/String.cpp ./Classes/WString.cpp ./Classes/Display.cpp ./Classes/IDSystem.cpp ./Classes/JSON.cpp ./Functions.cpp ./Classes/GUI/Event.cpp ./Classes/GUI/EventQueue.cpp ./Classes/Language.cpp ./Classes/FileSystem/Stream.cpp ./Classes/FileSystem/BufferStream.cpp ./Classes/FileSystem/FileSystemWatcher.cpp ./Classes/GameEngine.cpp ./Classes/Clock.cpp ./Classes/Buffer.cpp ./Classes/GUI/Interface.cpp ./Classes/GUI/Widget.cpp ./Classes/GUI/Panel.cpp ./Classes/GUI/Slider.cpp ./Classes/GUI/Label.cpp ./Classes/GUI/Button.cpp ./Classes/GUI/TextField.cpp ./Classes/GUI/TreeView.cpp ./Classes/GUI/TextArea.cpp ./Classes/GUI/Tabber.cpp ./Classes/GUI/ListBox.cpp ./Classes/GUI/ProgressBar.cpp ./Classes/GUI/ComboBox.cpp ./Classes/GUI/Menu.cpp ./Classes/Window/LinuxWindow.cpp ./Classes/Timer.cpp ./Classes/Process.cpp ./Classes/FileSystem/StreamBuffer.cpp ./Classes/Multithreading/Thread.cpp ./Classes/Multithreading/Mutex.cpp ./Classes/Loaders/Loader.cpp ./Classes/Loaders/DDSTextureLoader.cpp ./Classes/Assets/Asset.cpp ./Classes/Plugin.cpp ./Classes/Assets/Font.cpp ./Classes/FileSystem/Package.cpp ./Classes/Graphics/Pixmap.cpp ./Classes/Graphics/Icon.cpp ./Libraries/CppTimer/CppTimer.cpp
HEADER	= 
OUT	= AppKit
CC	 = g++
FLAGS	 = -g -c -Wall
LFLAGS	 = 
INC = -I/usr/include/freetype2 -I/usr/include/fontconfig -I./

all: $(OBJS)
	$(CC) -g $(OBJS) -o $(OUT) $(LFLAGS)

./AppKit.o: ./AppKit.cpp
	$(CC) $(FLAGS) ./AppKit.cpp 

SDK/GMFSDK.o: SDK/GMFSDK.cpp
	$(CC) $(FLAGS) SDK/GMFSDK.cpp 

SDK/MemReader.o: SDK/MemReader.cpp
	$(CC) $(FLAGS) SDK/MemReader.cpp 

SDK/MemWriter.o: SDK/MemWriter.cpp
	$(CC) $(FLAGS) SDK/MemWriter.cpp 

SDK/TextureInfo.o: SDK/TextureInfo.cpp
	$(CC) $(FLAGS) SDK/TextureInfo.cpp 

SDK/Utilities.o: SDK/Utilities.cpp
	$(CC) $(FLAGS) SDK/Utilities.cpp 

SDK/half/half.o: SDK/half/half.cpp
	$(CC) $(FLAGS) SDK/half/half.cpp 

./Libraries/s3tc-dxt-decompressionr/s3tc.o: ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp
	$(CC) $(FLAGS) ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp 

./Libraries/stb_dxt/stb_dxt.o: ./Libraries/stb_dxt/stb_dxt.cpp
	$(CC) $(FLAGS) ./Libraries/stb_dxt/stb_dxt.cpp 

./Classes/Object.o: ./Classes/Object.cpp
	$(CC) $(FLAGS) ./Classes/Object.cpp 

./Classes/Math/Math_.o: ./Classes/Math/Math_.cpp
	$(CC) $(FLAGS) ./Classes/Math/Math_.cpp 

./Classes/Math/Vec2.o: ./Classes/Math/Vec2.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec2.cpp 

./Classes/Math/Vec3.o: ./Classes/Math/Vec3.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec3.cpp 

./Classes/Math/Vec4.o: ./Classes/Math/Vec4.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec4.cpp 

./Classes/Math/iVec2.o: ./Classes/Math/iVec2.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec2.cpp 

./Classes/Math/iVec3.o: ./Classes/Math/iVec3.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec3.cpp 

./Classes/Math/iVec4.o: ./Classes/Math/iVec4.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec4.cpp 

./Classes/String.o: ./Classes/String.cpp
	$(CC) $(FLAGS) ./Classes/String.cpp 

./Classes/WString.o: ./Classes/WString.cpp
	$(CC) $(FLAGS) ./Classes/WString.cpp 

./Classes/Display.o: ./Classes/Display.cpp
	$(CC) $(FLAGS) ./Classes/Display.cpp 

./Classes/IDSystem.o: ./Classes/IDSystem.cpp
	$(CC) $(FLAGS) ./Classes/IDSystem.cpp 

./Classes/JSON.o: ./Classes/JSON.cpp
	$(CC) $(FLAGS) ./Classes/JSON.cpp 

./Functions.o: ./Functions.cpp
	$(CC) $(FLAGS) ./Functions.cpp 

./Classes/GUI/Event.o: ./Classes/GUI/Event.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Event.cpp 

./Classes/GUI/EventQueue.o: ./Classes/GUI/EventQueue.cpp
	$(CC) $(FLAGS) ./Classes/GUI/EventQueue.cpp 

./Classes/Language.o: ./Classes/Language.cpp
	$(CC) $(FLAGS) ./Classes/Language.cpp 

./Classes/FileSystem/Stream.o: ./Classes/FileSystem/Stream.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/Stream.cpp 

./Classes/FileSystem/BufferStream.o: ./Classes/FileSystem/BufferStream.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/BufferStream.cpp 

./Classes/FileSystem/FileSystemWatcher.o: ./Classes/FileSystem/FileSystemWatcher.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/FileSystemWatcher.cpp 

./Classes/GameEngine.o: ./Classes/GameEngine.cpp
	$(CC) $(FLAGS) ./Classes/GameEngine.cpp 

./Classes/Clock.o: ./Classes/Clock.cpp
	$(CC) $(FLAGS) ./Classes/Clock.cpp 

./Classes/Buffer.o: ./Classes/Buffer.cpp
	$(CC) $(FLAGS) ./Classes/Buffer.cpp 

./Classes/GUI/Interface.o: ./Classes/GUI/Interface.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Interface.cpp 

./Classes/GUI/Widget.o: ./Classes/GUI/Widget.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Widget.cpp 

./Classes/GUI/Panel.o: ./Classes/GUI/Panel.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Panel.cpp 

./Classes/GUI/Slider.o: ./Classes/GUI/Slider.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Slider.cpp 

./Classes/GUI/Label.o: ./Classes/GUI/Label.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Label.cpp 

./Classes/GUI/Button.o: ./Classes/GUI/Button.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Button.cpp 

./Classes/GUI/TextField.o: ./Classes/GUI/TextField.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TextField.cpp 

./Classes/GUI/TreeView.o: ./Classes/GUI/TreeView.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TreeView.cpp 

./Classes/GUI/TextArea.o: ./Classes/GUI/TextArea.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TextArea.cpp 

./Classes/GUI/Tabber.o: ./Classes/GUI/Tabber.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Tabber.cpp 

./Classes/GUI/ListBox.o: ./Classes/GUI/ListBox.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ListBox.cpp 

./Classes/GUI/ProgressBar.o: ./Classes/GUI/ProgressBar.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ProgressBar.cpp 

./Classes/GUI/ComboBox.o: ./Classes/GUI/ComboBox.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ComboBox.cpp 

./Classes/GUI/Menu.o: ./Classes/GUI/Menu.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Menu.cpp 

./Classes/Window/LinuxWindow.o: ./Classes/Window/LinuxWindow.cpp
	$(CC) $(FLAGS) ./Classes/Window/LinuxWindow.cpp 

./Classes/Timer.o: ./Classes/Timer.cpp
	$(CC) $(FLAGS) ./Classes/Timer.cpp 

./Classes/Process.o: ./Classes/Process.cpp
	$(CC) $(FLAGS) ./Classes/Process.cpp 

./Classes/FileSystem/StreamBuffer.o: ./Classes/FileSystem/StreamBuffer.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/StreamBuffer.cpp 

./Classes/Multithreading/Thread.o: ./Classes/Multithreading/Thread.cpp
	$(CC) $(FLAGS) ./Classes/Multithreading/Thread.cpp 

./Classes/Multithreading/Mutex.o: ./Classes/Multithreading/Mutex.cpp
	$(CC) $(FLAGS) ./Classes/Multithreading/Mutex.cpp 

./Classes/Loaders/Loader.o: ./Classes/Loaders/Loader.cpp
	$(CC) $(FLAGS) ./Classes/Loaders/Loader.cpp 

./Classes/Loaders/DDSTextureLoader.o: ./Classes/Loaders/DDSTextureLoader.cpp
	$(CC) $(FLAGS) ./Classes/Loaders/DDSTextureLoader.cpp 

./Classes/Assets/Asset.o: ./Classes/Assets/Asset.cpp
	$(CC) $(FLAGS) ./Classes/Assets/Asset.cpp 

./Classes/Plugin.o: ./Classes/Plugin.cpp
	$(CC) $(FLAGS) ./Classes/Plugin.cpp 

./Classes/Assets/Font.o: ./Classes/Assets/Font.cpp
	$(CC) $(FLAGS) ./Classes/Assets/Font.cpp 

./Classes/FileSystem/Package.o: ./Classes/FileSystem/Package.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/Package.cpp 

./Classes/Graphics/Pixmap.o: ./Classes/Graphics/Pixmap.cpp
	$(CC) $(FLAGS) ./Classes/Graphics/Pixmap.cpp 

./Classes/Graphics/Icon.o: ./Classes/Graphics/Icon.cpp
	$(CC) $(FLAGS) ./Classes/Graphics/Icon.cpp 

./Libraries/CppTimer/CppTimer.o: ./Libraries/CppTimer/CppTimer.cpp
	$(CC) $(FLAGS) ./Libraries/CppTimer/CppTimer.cpp 

clean:
	rm -f $(OBJS) $(OUT)

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

Successfully compilation:

OBJS	= ./AppKit.o ./Libraries/PluginSDK/GMFSDK.o ./Libraries/PluginSDK/MemReader.o ./Libraries/PluginSDK/MemWriter.o ./Libraries/PluginSDK/TextureInfo.o ./Libraries/PluginSDK/Utilities.o ./Libraries/PluginSDK/half/half.o ./Libraries/s3tc-dxt-decompressionr/s3tc.o ./Libraries/stb_dxt/stb_dxt.o ./Classes/Object.o ./Classes/Math/Math_.o ./Classes/Math/Vec2.o ./Classes/Math/Vec3.o ./Classes/Math/Vec4.o ./Classes/Math/iVec2.o ./Classes/Math/iVec3.o ./Classes/Math/iVec4.o ./Classes/String.o ./Classes/WString.o ./Classes/Display.o ./Classes/IDSystem.o ./Classes/JSON.o ./Functions.o ./Classes/GUI/Event.o ./Classes/GUI/EventQueue.o ./Classes/Language.o ./Classes/FileSystem/Stream.o ./Classes/FileSystem/BufferStream.o ./Classes/FileSystem/FileSystemWatcher.o ./Classes/GameEngine.o ./Classes/Clock.o ./Classes/Buffer.o ./Classes/GUI/Interface.o ./Classes/GUI/Widget.o ./Classes/GUI/Panel.o ./Classes/GUI/Slider.o ./Classes/GUI/Label.o ./Classes/GUI/Button.o ./Classes/GUI/TextField.o ./Classes/GUI/TreeView.o ./Classes/GUI/TextArea.o ./Classes/GUI/Tabber.o ./Classes/GUI/ListBox.o ./Classes/GUI/ProgressBar.o ./Classes/GUI/ComboBox.o ./Classes/GUI/Menu.o ./Classes/Window/LinuxWindow.o ./Classes/Timer.o ./Classes/Process.o ./Classes/FileSystem/StreamBuffer.o ./Classes/Multithreading/Thread.o ./Classes/Multithreading/Mutex.o ./Classes/Loaders/Loader.o ./Classes/Loaders/DDSTextureLoader.o ./Classes/Assets/Asset.o ./Classes/Plugin.o ./Classes/Assets/Font.o ./Classes/FileSystem/Package.o ./Classes/Graphics/Pixmap.o ./Classes/Graphics/Icon.o ./Libraries/CppTimer/CppTimer.o
SOURCE	= ./AppKit.cpp ./Libraries/PluginSDK/GMFSDK.cpp ./Libraries/PluginSDK/MemReader.cpp ./Libraries/PluginSDK/MemWriter.cpp ./Libraries/PluginSDK/TextureInfo.cpp ./Libraries/PluginSDK/Utilities.cpp ./Libraries/PluginSDK/half/half.cpp ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp ./Libraries/stb_dxt/stb_dxt.cpp ./Classes/Object.cpp ./Classes/Math/Math_.cpp ./Classes/Math/Vec2.cpp ./Classes/Math/Vec3.cpp ./Classes/Math/Vec4.cpp ./Classes/Math/iVec2.cpp ./Classes/Math/iVec3.cpp ./Classes/Math/iVec4.cpp ./Classes/String.cpp ./Classes/WString.cpp ./Classes/Display.cpp ./Classes/IDSystem.cpp ./Classes/JSON.cpp ./Functions.cpp ./Classes/GUI/Event.cpp ./Classes/GUI/EventQueue.cpp ./Classes/Language.cpp ./Classes/FileSystem/Stream.cpp ./Classes/FileSystem/BufferStream.cpp ./Classes/FileSystem/FileSystemWatcher.cpp ./Classes/GameEngine.cpp ./Classes/Clock.cpp ./Classes/Buffer.cpp ./Classes/GUI/Interface.cpp ./Classes/GUI/Widget.cpp ./Classes/GUI/Panel.cpp ./Classes/GUI/Slider.cpp ./Classes/GUI/Label.cpp ./Classes/GUI/Button.cpp ./Classes/GUI/TextField.cpp ./Classes/GUI/TreeView.cpp ./Classes/GUI/TextArea.cpp ./Classes/GUI/Tabber.cpp ./Classes/GUI/ListBox.cpp ./Classes/GUI/ProgressBar.cpp ./Classes/GUI/ComboBox.cpp ./Classes/GUI/Menu.cpp ./Classes/Window/LinuxWindow.cpp ./Classes/Timer.cpp ./Classes/Process.cpp ./Classes/FileSystem/StreamBuffer.cpp ./Classes/Multithreading/Thread.cpp ./Classes/Multithreading/Mutex.cpp ./Classes/Loaders/Loader.cpp ./Classes/Loaders/DDSTextureLoader.cpp ./Classes/Assets/Asset.cpp ./Classes/Plugin.cpp ./Classes/Assets/Font.cpp ./Classes/FileSystem/Package.cpp ./Classes/Graphics/Pixmap.cpp ./Classes/Graphics/Icon.cpp ./Libraries/CppTimer/CppTimer.cpp
HEADER	= 
OUT	= AppKit
CC	 = g++
FLAGS	 = -g -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./ -D_DEBUG -D_ULTRA_APPKIT -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
LFLAGS	 = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl

all: $(OBJS)
	$(CC) -g $(OBJS) -o $(OUT) $(LFLAGS)

./AppKit.o: ./AppKit.cpp
	$(CC) $(FLAGS) ./AppKit.cpp 

./Libraries/PluginSDK/GMFSDK.o: ./Libraries/PluginSDK/GMFSDK.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/GMFSDK.cpp -o ./Libraries/PluginSDK/GMFSDK.o

./Libraries/PluginSDK/MemReader.o: ./Libraries/PluginSDK/MemReader.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/MemReader.cpp -o ./Libraries/PluginSDK/MemReader.o

./Libraries/PluginSDK/MemWriter.o: ./Libraries/PluginSDK/MemWriter.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/MemWriter.cpp -o ./Libraries/PluginSDK/MemWriter.o

./Libraries/PluginSDK/TextureInfo.o: ./Libraries/PluginSDK/TextureInfo.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/TextureInfo.cpp -o ./Libraries/PluginSDK/TextureInfo.o

./Libraries/PluginSDK/Utilities.o: ./Libraries/PluginSDK/Utilities.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/Utilities.cpp -o ./Libraries/PluginSDK/Utilities.o 

./Libraries/PluginSDK/half/half.o: ./Libraries/PluginSDK/half/half.cpp
	$(CC) $(FLAGS) ./Libraries/PluginSDK/half/half.cpp -o ./Libraries/PluginSDK/half/half.o

./Libraries/s3tc-dxt-decompressionr/s3tc.o: ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp
	$(CC) $(FLAGS) ./Libraries/s3tc-dxt-decompressionr/s3tc.cpp -o ./Libraries/s3tc-dxt-decompressionr/s3tc.o

./Libraries/stb_dxt/stb_dxt.o: ./Libraries/stb_dxt/stb_dxt.cpp
	$(CC) $(FLAGS) ./Libraries/stb_dxt/stb_dxt.cpp -o ./Libraries/stb_dxt/stb_dxt.o

./Classes/Object.o: ./Classes/Object.cpp
	$(CC) $(FLAGS) ./Classes/Object.cpp -o ./Classes/Object.o

./Classes/Math/Math_.o: ./Classes/Math/Math_.cpp
	$(CC) $(FLAGS) ./Classes/Math/Math_.cpp -o ./Classes/Math/Math_.o

./Classes/Math/Vec2.o: ./Classes/Math/Vec2.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec2.cpp -o ./Classes/Math/Vec2.o

./Classes/Math/Vec3.o: ./Classes/Math/Vec3.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec3.cpp -o ./Classes/Math/Vec3.o

./Classes/Math/Vec4.o: ./Classes/Math/Vec4.cpp
	$(CC) $(FLAGS) ./Classes/Math/Vec4.cpp -o ./Classes/Math/Vec4.o

./Classes/Math/iVec2.o: ./Classes/Math/iVec2.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec2.cpp -o ./Classes/Math/iVec2.o

./Classes/Math/iVec3.o: ./Classes/Math/iVec3.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec3.cpp -o ./Classes/Math/iVec3.o

./Classes/Math/iVec4.o: ./Classes/Math/iVec4.cpp
	$(CC) $(FLAGS) ./Classes/Math/iVec4.cpp -o ./Classes/Math/iVec4.o

./Classes/String.o: ./Classes/String.cpp
	$(CC) $(FLAGS) ./Classes/String.cpp -o ./Classes/String.o

./Classes/WString.o: ./Classes/WString.cpp
	$(CC) $(FLAGS) ./Classes/WString.cpp -o ./Classes/WString.o

./Classes/Display.o: ./Classes/Display.cpp
	$(CC) $(FLAGS) ./Classes/Display.cpp -o ./Classes/Display.o

./Classes/IDSystem.o: ./Classes/IDSystem.cpp
	$(CC) $(FLAGS) ./Classes/IDSystem.cpp -o ./Classes/IDSystem.o 

./Classes/JSON.o: ./Classes/JSON.cpp
	$(CC) $(FLAGS) ./Classes/JSON.cpp -o ./Classes/JSON.o 

./Functions.o: ./Functions.cpp
	$(CC) $(FLAGS) ./Functions.cpp -o ./Functions.o

./Classes/GUI/Event.o: ./Classes/GUI/Event.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Event.cpp -o ./Classes/GUI/Event.o

./Classes/GUI/EventQueue.o: ./Classes/GUI/EventQueue.cpp
	$(CC) $(FLAGS) ./Classes/GUI/EventQueue.cpp -o ./Classes/GUI/EventQueue.o

./Classes/Language.o: ./Classes/Language.cpp
	$(CC) $(FLAGS) ./Classes/Language.cpp -o ./Classes/Language.o

./Classes/FileSystem/Stream.o: ./Classes/FileSystem/Stream.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/Stream.cpp -o ./Classes/FileSystem/Stream.o

./Classes/FileSystem/BufferStream.o: ./Classes/FileSystem/BufferStream.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/BufferStream.cpp -o ./Classes/FileSystem/BufferStream.o

./Classes/FileSystem/FileSystemWatcher.o: ./Classes/FileSystem/FileSystemWatcher.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/FileSystemWatcher.cpp -o ./Classes/FileSystem/FileSystemWatcher.o

./Classes/GameEngine.o: ./Classes/GameEngine.cpp
	$(CC) $(FLAGS) ./Classes/GameEngine.cpp -o ./Classes/GameEngine.o

./Classes/Clock.o: ./Classes/Clock.cpp
	$(CC) $(FLAGS) ./Classes/Clock.cpp -o ./Classes/Clock.o 

./Classes/Buffer.o: ./Classes/Buffer.cpp
	$(CC) $(FLAGS) ./Classes/Buffer.cpp -o ./Classes/Buffer.o

./Classes/GUI/Interface.o: ./Classes/GUI/Interface.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Interface.cpp -o ./Classes/GUI/Interface.o

./Classes/GUI/Widget.o: ./Classes/GUI/Widget.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Widget.cpp -o ./Classes/GUI/Widget.o

./Classes/GUI/Panel.o: ./Classes/GUI/Panel.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Panel.cpp -o ./Classes/GUI/Panel.o

./Classes/GUI/Slider.o: ./Classes/GUI/Slider.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Slider.cpp -o ./Classes/GUI/Slider.o

./Classes/GUI/Label.o: ./Classes/GUI/Label.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Label.cpp -o ./Classes/GUI/Label.o

./Classes/GUI/Button.o: ./Classes/GUI/Button.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Button.cpp -o ./Classes/GUI/Button.o

./Classes/GUI/TextField.o: ./Classes/GUI/TextField.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TextField.cpp -o ./Classes/GUI/TextField.o

./Classes/GUI/TreeView.o: ./Classes/GUI/TreeView.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TreeView.cpp -o ./Classes/GUI/TreeView.o

./Classes/GUI/TextArea.o: ./Classes/GUI/TextArea.cpp
	$(CC) $(FLAGS) ./Classes/GUI/TextArea.cpp -o ./Classes/GUI/TextArea.o

./Classes/GUI/Tabber.o: ./Classes/GUI/Tabber.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Tabber.cpp -o ./Classes/GUI/Tabber.o

./Classes/GUI/ListBox.o: ./Classes/GUI/ListBox.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ListBox.cpp -o ./Classes/GUI/ListBox.o

./Classes/GUI/ProgressBar.o: ./Classes/GUI/ProgressBar.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ProgressBar.cpp -o ./Classes/GUI/ProgressBar.o

./Classes/GUI/ComboBox.o: ./Classes/GUI/ComboBox.cpp
	$(CC) $(FLAGS) ./Classes/GUI/ComboBox.cpp -o ./Classes/GUI/ComboBox.o

./Classes/GUI/Menu.o: ./Classes/GUI/Menu.cpp
	$(CC) $(FLAGS) ./Classes/GUI/Menu.cpp -o ./Classes/GUI/Menu.o

./Classes/Window/LinuxWindow.o: ./Classes/Window/LinuxWindow.cpp
	$(CC) $(FLAGS) ./Classes/Window/LinuxWindow.cpp -o ./Classes/Window/LinuxWindow.o

./Classes/Timer.o: ./Classes/Timer.cpp
	$(CC) $(FLAGS) ./Classes/Timer.cpp -o ./Classes/Timer.o

./Classes/Process.o: ./Classes/Process.cpp
	$(CC) $(FLAGS) ./Classes/Process.cpp -o ./Classes/Process.o

./Classes/FileSystem/StreamBuffer.o: ./Classes/FileSystem/StreamBuffer.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/StreamBuffer.cpp -o ./Classes/FileSystem/StreamBuffer.o

./Classes/Multithreading/Thread.o: ./Classes/Multithreading/Thread.cpp
	$(CC) $(FLAGS) ./Classes/Multithreading/Thread.cpp -o ./Classes/Multithreading/Thread.o

./Classes/Multithreading/Mutex.o: ./Classes/Multithreading/Mutex.cpp
	$(CC) $(FLAGS) ./Classes/Multithreading/Mutex.cpp -o ./Classes/Multithreading/Mutex.o

./Classes/Loaders/Loader.o: ./Classes/Loaders/Loader.cpp
	$(CC) $(FLAGS) ./Classes/Loaders/Loader.cpp -o ./Classes/Loaders/Loader.o

./Classes/Loaders/DDSTextureLoader.o: ./Classes/Loaders/DDSTextureLoader.cpp
	$(CC) $(FLAGS) ./Classes/Loaders/DDSTextureLoader.cpp -o ./Classes/Loaders/DDSTextureLoader.o

./Classes/Assets/Asset.o: ./Classes/Assets/Asset.cpp
	$(CC) $(FLAGS) ./Classes/Assets/Asset.cpp -o ./Classes/Assets/Asset.o

./Classes/Plugin.o: ./Classes/Plugin.cpp
	$(CC) $(FLAGS) ./Classes/Plugin.cpp -o ./Classes/Plugin.o

./Classes/Assets/Font.o: ./Classes/Assets/Font.cpp
	$(CC) $(FLAGS) ./Classes/Assets/Font.cpp -o ./Classes/Assets/Font.o

./Classes/FileSystem/Package.o: ./Classes/FileSystem/Package.cpp
	$(CC) $(FLAGS) ./Classes/FileSystem/Package.cpp -o ./Classes/FileSystem/Package.o

./Classes/Graphics/Pixmap.o: ./Classes/Graphics/Pixmap.cpp
	$(CC) $(FLAGS) ./Classes/Graphics/Pixmap.cpp -o ./Classes/Graphics/Pixmap.o

./Classes/Graphics/Icon.o: ./Classes/Graphics/Icon.cpp
	$(CC) $(FLAGS) ./Classes/Graphics/Icon.cpp -o ./Classes/Graphics/Icon.o

./Libraries/CppTimer/CppTimer.o: ./Libraries/CppTimer/CppTimer.cpp
	$(CC) $(FLAGS) ./Libraries/CppTimer/CppTimer.cpp -o ./Libraries/CppTimer/CppTimer.o

clean:
	rm -f $(OBJS) $(OUT)

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

You could shorten that a lot:

You don't need the definitions for SOURCE and HEADER at the top and you can replace most of your rules with a generic one:

OBJS	= ./AppKit.o ./Libraries/PluginSDK/GMFSDK.o ./Libraries/PluginSDK/MemReader.o ./Libraries/PluginSDK/MemWriter.o ./Libraries/PluginSDK/TextureInfo.o ./Libraries/PluginSDK/Utilities.o ./Libraries/PluginSDK/half/half.o ./Libraries/s3tc-dxt-decompressionr/s3tc.o ./Libraries/stb_dxt/stb_dxt.o ./Classes/Object.o ./Classes/Math/Math_.o ./Classes/Math/Vec2.o ./Classes/Math/Vec3.o ./Classes/Math/Vec4.o ./Classes/Math/iVec2.o ./Classes/Math/iVec3.o ./Classes/Math/iVec4.o ./Classes/String.o ./Classes/WString.o ./Classes/Display.o ./Classes/IDSystem.o ./Classes/JSON.o ./Functions.o ./Classes/GUI/Event.o ./Classes/GUI/EventQueue.o ./Classes/Language.o ./Classes/FileSystem/Stream.o ./Classes/FileSystem/BufferStream.o ./Classes/FileSystem/FileSystemWatcher.o ./Classes/GameEngine.o ./Classes/Clock.o ./Classes/Buffer.o ./Classes/GUI/Interface.o ./Classes/GUI/Widget.o ./Classes/GUI/Panel.o ./Classes/GUI/Slider.o ./Classes/GUI/Label.o ./Classes/GUI/Button.o ./Classes/GUI/TextField.o ./Classes/GUI/TreeView.o ./Classes/GUI/TextArea.o ./Classes/GUI/Tabber.o ./Classes/GUI/ListBox.o ./Classes/GUI/ProgressBar.o ./Classes/GUI/ComboBox.o ./Classes/GUI/Menu.o ./Classes/Window/LinuxWindow.o ./Classes/Timer.o ./Classes/Process.o ./Classes/FileSystem/StreamBuffer.o ./Classes/Multithreading/Thread.o ./Classes/Multithreading/Mutex.o ./Classes/Loaders/Loader.o ./Classes/Loaders/DDSTextureLoader.o ./Classes/Assets/Asset.o ./Classes/Plugin.o ./Classes/Assets/Font.o ./Classes/FileSystem/Package.o ./Classes/Graphics/Pixmap.o ./Classes/Graphics/Icon.o ./Libraries/CppTimer/CppTimer.o
OUT	= AppKit
CC	 = g++
FLAGS	 = -g -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./ -D_DEBUG -D_ULTRA_APPKIT -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
LFLAGS	 = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl

all: $(OBJS)
	$(CC) -g $(OBJS) -o $(OUT) $(LFLAGS)

%.o: %.cpp
	$(CC) $(FLAGS) $< -o $@

clean:
	rm -f $(OBJS) $(OUT)

This way, whenever you need to add a file, you just need to add it to the OBJS-list. The generic rule in the middle tells make, when it wants to create any file ending with .o to just search for the file ending with .cpp and in the command for that rule the placeholder $< will be replaced with the first prerequisite, whereas $@ will be replaced with the target (see https://www.gnu.org/software/make/manual/html_node/Automatic-Variables.html)

  • Thanks 1
Link to comment
Share on other sites

Much better, thank you:

OBJS = ./AppKit.o ./Libraries/PluginSDK/GMFSDK.o ./Libraries/PluginSDK/MemReader.o ./Libraries/PluginSDK/MemWriter.o ./Libraries/PluginSDK/TextureInfo.o ./Libraries/PluginSDK/Utilities.o ./Libraries/PluginSDK/half/half.o ./Libraries/s3tc-dxt-decompressionr/s3tc.o ./Libraries/stb_dxt/stb_dxt.o ./Classes/Object.o ./Classes/Math/Math_.o ./Classes/Math/Vec2.o ./Classes/Math/Vec3.o ./Classes/Math/Vec4.o ./Classes/Math/iVec2.o ./Classes/Math/iVec3.o ./Classes/Math/iVec4.o ./Classes/String.o ./Classes/WString.o ./Classes/Display.o ./Classes/IDSystem.o ./Classes/JSON.o ./Functions.o ./Classes/GUI/Event.o ./Classes/GUI/EventQueue.o ./Classes/Language.o ./Classes/FileSystem/Stream.o ./Classes/FileSystem/BufferStream.o ./Classes/FileSystem/FileSystemWatcher.o ./Classes/GameEngine.o ./Classes/Clock.o ./Classes/Buffer.o ./Classes/GUI/Interface.o ./Classes/GUI/Widget.o ./Classes/GUI/Panel.o ./Classes/GUI/Slider.o ./Classes/GUI/Label.o ./Classes/GUI/Button.o ./Classes/GUI/TextField.o ./Classes/GUI/TreeView.o ./Classes/GUI/TextArea.o ./Classes/GUI/Tabber.o ./Classes/GUI/ListBox.o ./Classes/GUI/ProgressBar.o ./Classes/GUI/ComboBox.o ./Classes/GUI/Menu.o ./Classes/Window/LinuxWindow.o ./Classes/Timer.o ./Classes/Process.o ./Classes/FileSystem/StreamBuffer.o ./Classes/Multithreading/Thread.o ./Classes/Multithreading/Mutex.o ./Classes/Loaders/Loader.o ./Classes/Loaders/DDSTextureLoader.o ./Classes/Assets/Asset.o ./Classes/Plugin.o ./Classes/Assets/Font.o ./Classes/FileSystem/Package.o ./Classes/Graphics/Pixmap.o ./Classes/Graphics/Icon.o ./Libraries/CppTimer/CppTimer.o
CC = g++
FLAGS = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./ -D_ULTRA_APPKIT
LFLAGS = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
OUT = AppKit

all: $(OBJS)
	$(CC) $(CONFIGFLAGS) $(OBJS) -o $(OUT) $(LFLAGS)

%.o: %.cpp
	$(CC) $(FLAGS) $(CONFIGFLAGS) $< -o $@

clean:
	rm -f $(OBJS) $(OUT)

I have this working with VSCode compile / run / debug now, although their support for this is weird and goes through a different interface than the regular debug / run tools.

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

@Ma-Shell Is there any way to store the .o files in a .build subfolder without explicitly writing each file name again?

I can do this to generate all the .o files in one directory:

%.o: %.cpp
	mkdir -p .build/Debug
	$(CC) $(FLAGS) $(CONFIGFLAGS) $< -o .build/Debug/$(@F)

Is there a way I can pass $(OBJS) to GCC with the file paths modified?

My job is to make tools you love, with the features you want, and performance you can't live without.

Link to comment
Share on other sites

You can just change the rule to say `.build/Debug/%.o: %.cpp` and unfortunately you have to add this path everywhere in the OBJS-list:

OBJS = ./.build/Debug/AppKit.o ./.build/Debug/Libraries/PluginSDK/GMFSDK.o ./.build/Debug/Libraries/PluginSDK/MemReader.o ./.build/Debug/Libraries/PluginSDK/MemWriter.o ./.build/Debug/Libraries/PluginSDK/TextureInfo.o ./.build/Debug/Libraries/PluginSDK/Utilities.o ./.build/Debug/Libraries/PluginSDK/half/half.o ./.build/Debug/Libraries/s3tc-dxt-decompressionr/s3tc.o ./.build/Debug/Libraries/stb_dxt/stb_dxt.o ./.build/Debug/Classes/Object.o ./.build/Debug/Classes/Math/Math_.o ./.build/Debug/Classes/Math/Vec2.o ./.build/Debug/Classes/Math/Vec3.o ./.build/Debug/Classes/Math/Vec4.o ./.build/Debug/Classes/Math/iVec2.o ./.build/Debug/Classes/Math/iVec3.o ./.build/Debug/Classes/Math/iVec4.o ./.build/Debug/Classes/String.o ./.build/Debug/Classes/WString.o ./.build/Debug/Classes/Display.o ./.build/Debug/Classes/IDSystem.o ./.build/Debug/Classes/JSON.o ./.build/Debug/Functions.o ./.build/Debug/Classes/GUI/Event.o ./.build/Debug/Classes/GUI/EventQueue.o ./.build/Debug/Classes/Language.o ./.build/Debug/Classes/FileSystem/Stream.o ./.build/Debug/Classes/FileSystem/BufferStream.o ./.build/Debug/Classes/FileSystem/FileSystemWatcher.o ./.build/Debug/Classes/GameEngine.o ./.build/Debug/Classes/Clock.o ./.build/Debug/Classes/Buffer.o ./.build/Debug/Classes/GUI/Interface.o ./.build/Debug/Classes/GUI/Widget.o ./.build/Debug/Classes/GUI/Panel.o ./.build/Debug/Classes/GUI/Slider.o ./.build/Debug/Classes/GUI/Label.o ./.build/Debug/Classes/GUI/Button.o ./.build/Debug/Classes/GUI/TextField.o ./.build/Debug/Classes/GUI/TreeView.o ./.build/Debug/Classes/GUI/TextArea.o ./.build/Debug/Classes/GUI/Tabber.o ./.build/Debug/Classes/GUI/ListBox.o ./.build/Debug/Classes/GUI/ProgressBar.o ./.build/Debug/Classes/GUI/ComboBox.o ./.build/Debug/Classes/GUI/Menu.o ./.build/Debug/Classes/Window/LinuxWindow.o ./.build/Debug/Classes/Timer.o ./.build/Debug/Classes/Process.o ./.build/Debug/Classes/FileSystem/StreamBuffer.o ./.build/Debug/Classes/Multithreading/Thread.o ./.build/Debug/Classes/Multithreading/Mutex.o ./.build/Debug/Classes/Loaders/Loader.o ./.build/Debug/Classes/Loaders/DDSTextureLoader.o ./.build/Debug/Classes/Assets/Asset.o ./.build/Debug/Classes/Plugin.o ./.build/Debug/Classes/Assets/Font.o ./.build/Debug/Classes/FileSystem/Package.o ./.build/Debug/Classes/Graphics/Pixmap.o ./.build/Debug/Classes/Graphics/Icon.o ./.build/Debug/Libraries/CppTimer/CppTimer.o
CC = g++
FLAGS = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./.build/Debug/ -D_ULTRA_APPKIT
LFLAGS = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
OUT = AppKit

all: $(OBJS)
	$(CC) $(CONFIGFLAGS) $(OBJS) -o $(OUT) $(LFLAGS)

./.build/Debug/%.o: %.cpp
	$(CC) $(FLAGS) $(CONFIGFLAGS) $< -o $@

clean:
	rm -f $(OBJS) $(OUT)

There is probably also a way to add it automatically to every object in the OBJS-list but I don't know it.

That later option is especially interesting, if you want separate debug and release builds:

OBJS_DEBUG = ./.build/Debug/AppKit.o ./.build/Debug/Libraries/PluginSDK/GMFSDK.o ./.build/Debug/Libraries/PluginSDK/MemReader.o ./.build/Debug/Libraries/PluginSDK/MemWriter.o ./.build/Debug/Libraries/PluginSDK/TextureInfo.o ./.build/Debug/Libraries/PluginSDK/Utilities.o ./.build/Debug/Libraries/PluginSDK/half/half.o ./.build/Debug/Libraries/s3tc-dxt-decompressionr/s3tc.o ./.build/Debug/Libraries/stb_dxt/stb_dxt.o ./.build/Debug/Classes/Object.o ./.build/Debug/Classes/Math/Math_.o ./.build/Debug/Classes/Math/Vec2.o ./.build/Debug/Classes/Math/Vec3.o ./.build/Debug/Classes/Math/Vec4.o ./.build/Debug/Classes/Math/iVec2.o ./.build/Debug/Classes/Math/iVec3.o ./.build/Debug/Classes/Math/iVec4.o ./.build/Debug/Classes/String.o ./.build/Debug/Classes/WString.o ./.build/Debug/Classes/Display.o ./.build/Debug/Classes/IDSystem.o ./.build/Debug/Classes/JSON.o ./.build/Debug/Functions.o ./.build/Debug/Classes/GUI/Event.o ./.build/Debug/Classes/GUI/EventQueue.o ./.build/Debug/Classes/Language.o ./.build/Debug/Classes/FileSystem/Stream.o ./.build/Debug/Classes/FileSystem/BufferStream.o ./.build/Debug/Classes/FileSystem/FileSystemWatcher.o ./.build/Debug/Classes/GameEngine.o ./.build/Debug/Classes/Clock.o ./.build/Debug/Classes/Buffer.o ./.build/Debug/Classes/GUI/Interface.o ./.build/Debug/Classes/GUI/Widget.o ./.build/Debug/Classes/GUI/Panel.o ./.build/Debug/Classes/GUI/Slider.o ./.build/Debug/Classes/GUI/Label.o ./.build/Debug/Classes/GUI/Button.o ./.build/Debug/Classes/GUI/TextField.o ./.build/Debug/Classes/GUI/TreeView.o ./.build/Debug/Classes/GUI/TextArea.o ./.build/Debug/Classes/GUI/Tabber.o ./.build/Debug/Classes/GUI/ListBox.o ./.build/Debug/Classes/GUI/ProgressBar.o ./.build/Debug/Classes/GUI/ComboBox.o ./.build/Debug/Classes/GUI/Menu.o ./.build/Debug/Classes/Window/LinuxWindow.o ./.build/Debug/Classes/Timer.o ./.build/Debug/Classes/Process.o ./.build/Debug/Classes/FileSystem/StreamBuffer.o ./.build/Debug/Classes/Multithreading/Thread.o ./.build/Debug/Classes/Multithreading/Mutex.o ./.build/Debug/Classes/Loaders/Loader.o ./.build/Debug/Classes/Loaders/DDSTextureLoader.o ./.build/Debug/Classes/Assets/Asset.o ./.build/Debug/Classes/Plugin.o ./.build/Debug/Classes/Assets/Font.o ./.build/Debug/Classes/FileSystem/Package.o ./.build/Debug/Classes/Graphics/Pixmap.o ./.build/Debug/Classes/Graphics/Icon.o ./.build/Debug/Libraries/CppTimer/CppTimer.o
OBJS_RELEASE = ./.build/Release/AppKit.o ./.build/Release/Libraries/PluginSDK/GMFSDK.o ./.build/Release/Libraries/PluginSDK/MemReader.o ./.build/Release/Libraries/PluginSDK/MemWriter.o ./.build/Release/Libraries/PluginSDK/TextureInfo.o ./.build/Release/Libraries/PluginSDK/Utilities.o ./.build/Release/Libraries/PluginSDK/half/half.o ./.build/Release/Libraries/s3tc-dxt-decompressionr/s3tc.o ./.build/Release/Libraries/stb_dxt/stb_dxt.o ./.build/Release/Classes/Object.o ./.build/Release/Classes/Math/Math_.o ./.build/Release/Classes/Math/Vec2.o ./.build/Release/Classes/Math/Vec3.o ./.build/Release/Classes/Math/Vec4.o ./.build/Release/Classes/Math/iVec2.o ./.build/Release/Classes/Math/iVec3.o ./.build/Release/Classes/Math/iVec4.o ./.build/Release/Classes/String.o ./.build/Release/Classes/WString.o ./.build/Release/Classes/Display.o ./.build/Release/Classes/IDSystem.o ./.build/Release/Classes/JSON.o ./.build/Release/Functions.o ./.build/Release/Classes/GUI/Event.o ./.build/Release/Classes/GUI/EventQueue.o ./.build/Release/Classes/Language.o ./.build/Release/Classes/FileSystem/Stream.o ./.build/Release/Classes/FileSystem/BufferStream.o ./.build/Release/Classes/FileSystem/FileSystemWatcher.o ./.build/Release/Classes/GameEngine.o ./.build/Release/Classes/Clock.o ./.build/Release/Classes/Buffer.o ./.build/Release/Classes/GUI/Interface.o ./.build/Release/Classes/GUI/Widget.o ./.build/Release/Classes/GUI/Panel.o ./.build/Release/Classes/GUI/Slider.o ./.build/Release/Classes/GUI/Label.o ./.build/Release/Classes/GUI/Button.o ./.build/Release/Classes/GUI/TextField.o ./.build/Release/Classes/GUI/TreeView.o ./.build/Release/Classes/GUI/TextArea.o ./.build/Release/Classes/GUI/Tabber.o ./.build/Release/Classes/GUI/ListBox.o ./.build/Release/Classes/GUI/ProgressBar.o ./.build/Release/Classes/GUI/ComboBox.o ./.build/Release/Classes/GUI/Menu.o ./.build/Release/Classes/Window/LinuxWindow.o ./.build/Release/Classes/Timer.o ./.build/Release/Classes/Process.o ./.build/Release/Classes/FileSystem/StreamBuffer.o ./.build/Release/Classes/Multithreading/Thread.o ./.build/Release/Classes/Multithreading/Mutex.o ./.build/Release/Classes/Loaders/Loader.o ./.build/Release/Classes/Loaders/DDSTextureLoader.o ./.build/Release/Classes/Assets/Asset.o ./.build/Release/Classes/Plugin.o ./.build/Release/Classes/Assets/Font.o ./.build/Release/Classes/FileSystem/Package.o ./.build/Release/Classes/Graphics/Pixmap.o ./.build/Release/Classes/Graphics/Icon.o ./.build/Release/Libraries/CppTimer/CppTimer.o
CC = g++
FLAGS_DEBUG = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./.build/Debug/ -D_ULTRA_APPKIT
FLAGS_RELEASE = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./.build/Release/ -D_ULTRA_APPKIT
LFLAGS = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
OUT = AppKit

all: debug release

debug: $(OBJS_DEBUG)
	$(CC) $(CONFIGFLAGS) $(OBJS_DEBUG) -o $(OUT) $(LFLAGS)

release: $(OBJS_RELEASE)
	$(CC) $(CONFIGFLAGS) $(OBJS_RELEASE) -o $(OUT) $(LFLAGS)


./.build/Debug/%.o: %.cpp
	$(CC) $(FLAGS_DEBUG) $(CONFIGFLAGS) $< -o $@

./.build/Release/%.o: %.cpp
	$(CC) $(FLAGS_RELEASE) $(CONFIGFLAGS) $< -o $@


clean:
	rm -f $(OBJS_DEBUG) $(OBJS_RELEASE) $(OUT)

You can use this and then execute either `make debug` or `make release` (Whereas you will probably want to adjust the FLAGS_DEBUG and FLAGS_RELEASE variables). If you only execute `make`, it will create both, debug and release.

Link to comment
Share on other sites

Actually it turns out, there is an easy way for modifying the list of objects, which means, you don't need to hardcode the OBJS_DEBUG and OBJS_RELEASE-list. Instead you can do the following:

OBJS = ./AppKit.o ./Libraries/PluginSDK/GMFSDK.o ./Libraries/PluginSDK/MemReader.o ./Libraries/PluginSDK/MemWriter.o ./Libraries/PluginSDK/TextureInfo.o ./Libraries/PluginSDK/Utilities.o ./Libraries/PluginSDK/half/half.o ./Libraries/s3tc-dxt-decompressionr/s3tc.o ./Libraries/stb_dxt/stb_dxt.o ./Classes/Object.o ./Classes/Math/Math_.o ./Classes/Math/Vec2.o ./Classes/Math/Vec3.o ./Classes/Math/Vec4.o ./Classes/Math/iVec2.o ./Classes/Math/iVec3.o ./Classes/Math/iVec4.o ./Classes/String.o ./Classes/WString.o ./Classes/Display.o ./Classes/IDSystem.o ./Classes/JSON.o ./Functions.o ./Classes/GUI/Event.o ./Classes/GUI/EventQueue.o ./Classes/Language.o ./Classes/FileSystem/Stream.o ./Classes/FileSystem/BufferStream.o ./Classes/FileSystem/FileSystemWatcher.o ./Classes/GameEngine.o ./Classes/Clock.o ./Classes/Buffer.o ./Classes/GUI/Interface.o ./Classes/GUI/Widget.o ./Classes/GUI/Panel.o ./Classes/GUI/Slider.o ./Classes/GUI/Label.o ./Classes/GUI/Button.o ./Classes/GUI/TextField.o ./Classes/GUI/TreeView.o ./Classes/GUI/TextArea.o ./Classes/GUI/Tabber.o ./Classes/GUI/ListBox.o ./Classes/GUI/ProgressBar.o ./Classes/GUI/ComboBox.o ./Classes/GUI/Menu.o ./Classes/Window/LinuxWindow.o ./Classes/Timer.o ./Classes/Process.o ./Classes/FileSystem/StreamBuffer.o ./Classes/Multithreading/Thread.o ./Classes/Multithreading/Mutex.o ./Classes/Loaders/Loader.o ./Classes/Loaders/DDSTextureLoader.o ./Classes/Assets/Asset.o ./Classes/Plugin.o ./Classes/Assets/Font.o ./Classes/FileSystem/Package.o ./Classes/Graphics/Pixmap.o ./Classes/Graphics/Icon.o ./Libraries/CppTimer/CppTimer.o

OBJS_DEBUG=$(foreach obj,$(OBJS),./.build/Debug/$(obj))
OBJS_RELEASE=$(foreach obj,$(OBJS),./.build/Release/$(obj))

 

  • Thanks 1
Link to comment
Share on other sites

And for the topping (as I just found out): If you have want to have .o-files for every .cpp file in your directory, you can even generate the list more easily:

OBJS = $(shell find . -type f -name "*.cpp" | sed s/.cpp/.o/)

OBJS_DEBUG=$(foreach obj,$(OBJS),./.build/Debug/$(obj))
OBJS_RELEASE=$(foreach obj,$(OBJS),./.build/Release/$(obj))

 

  • Upvote 1
Link to comment
Share on other sites

Also when trying it with subfolders, I noticed, you may need to have the subfolders created automatically in your build-directory:

OBJS = $(shell find . -type f -name "*.cpp" | sed s/.cpp/.o/)

OBJS_DEBUG=$(foreach obj,$(OBJS),./.build/Debug/$(obj))
OBJS_RELEASE=$(foreach obj,$(OBJS),./.build/Release/$(obj))

CC = g++
FLAGS_DEBUG = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./.build/Debug/ -D_ULTRA_APPKIT
FLAGS_RELEASE = -w -c -Wall -I/usr/include/freetype2 -I/usr/include/fontconfig -I./.build/Release/ -D_ULTRA_APPKIT
LFLAGS = -no-pie -lm -lX11 -lpthread -lXft -lXext -lXrender -lXcursor -lrt -ldl
OUT = AppKit

all: debug release

debug: $(OBJS_DEBUG)
	$(CC) $(CONFIGFLAGS) $(OBJS_DEBUG) -o $(OUT) $(LFLAGS)

release: $(OBJS_RELEASE)
	$(CC) $(CONFIGFLAGS) $(OBJS_RELEASE) -o $(OUT) $(LFLAGS)


./.build/Debug/%.o: %.cpp
	mkdir -p $(@D)
	$(CC) $(FLAGS_DEBUG) $(CONFIGFLAGS) $< -o $@

./.build/Release/%.o: %.cpp
	mkdir -p $(@D)
	$(CC) $(FLAGS_RELEASE) $(CONFIGFLAGS) $< -o $@


clean:
	rm -f $(OBJS_DEBUG) $(OBJS_RELEASE) $(OUT)

This should now make for a pretty low-maintenance Makefile for your purposes

  • Upvote 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...