(First off I'm sorry if it's in the wrong category but I think it's the most appropriate category)
A couple of days ago, I figured I should try learning how to make a makefile and stuff that's related to it. As of yet, I have a very basic knowledge of makefiles, but I've already made a working one based off a tutorial.
However, bigger projects use subdirectories (like /include, /bin, /src etc.)
so now I've put my project into one root directory (with the makefile, readme, install instructions etc.) with 3 subdirectories (/bin, /obj and /src)
Should be obvious what they're used for.
Now I've made a little makefile for this project, and it works perfectly fine.
Here's my makefile:
running the make command creates a working executable file in the /bin directory, executing the command ./bin/main runs that program and no errors occur.
main: main.o mathex.o
g++ obj/main.o obj/mathex.o -o bin/main
g++ -c src/main.cpp -o obj/main.o
g++ -c src/mathex.cpp -o obj/mathex.o
rm -f bin/*
rm -f obj/*
Now I've stumbled upon the autotools, and they're really useful. So I learned how to apply the autotools to a project, and now I'm super proud that my project is not a simple stupid (and totally platform dependent) makefile, BUT there's a problem:
building the program like this:
creates all the .o files and the main executable file in the root directory,
but I want the .o files to be in the /obj directory, and the executable file should be in /bin
Before I forget, here's the makefile.am I use (according to the tutorial I've read it's necessary to write it yourself):
I don't know what to do anymore
I am grateful for any advice