I am having difficulty trying to create a makefile that is in a root directory which will then CD into another directory entitled "code" which is where my code will be compiled. Also the executable then needs to be placed in a new directory which will be created called "bin" which will be in the root directory I have this so far:
all: bin/main
test: bin/main
bin/main: main.cpp
mkdir -p bin
g++ -std=c++11 -Wall -Werror -ansi -pedantic -o bin/program main.cpp
NOTE: I need those two target all and test. However this make (above) will only work if my code is already in the root
UPDATE: renamed code directory to src and here is new makefile
all:
mkdir -p ./bin
g++ -std=c++11 -Wall -Werror -ansi -pedantic ./src/main.cpp -o./bin/prgm
test: mkdir -p ./bin g++ -std=c++11 -Wall -Werror -ansi -pedantic ./src/main.cpp -o ./bin/prgm
however now I get this error "make: *** makefile: Is a directory. Stop." Am I trying to run it right? I do this "$ make"