I am trying to creat a makefile for my project, but I really don't understand this devil thing.
When I was doing it in Java, with ant, it was much more simplier.
The structure of my program is: http://imageshack.com/a/img39/6592/jsxa.png
I read about creating makefiles but, when they answer a question similiar, they just put the done makefile and don't explain a lot about what they're doing.
So, what I need to do is create a makefile that stay in a folder named foo (foo/makefile) together with the src folder(foo/src/). The makefile needs to create a folder named bin (foo/bin/) and put *.o files in there. Then build the program (DisqueRango.cpp contais the main function) and run it using 4 arguments: "-e couriers.csv -c menu.csv".
I'm not asking for the done makefile. What I need is an explanation about what I need to do it by myself.
Thank you indeed.
makefile of src/clients/
CC := g++
OBJ = *.cpp
all: prog
prog:
$(CC) -c $(OBJ)
makefile of src/disquerango/ (contais main function)
CC := g++
BASEDIR := ..
MODULES := clients couriers products read requests
OBJS := $(addsuffix /*.o, $(addprefix $(BASEDIR)/,$(MODULES)))
.PHONY: clean
all:
$(CC) -o disquer DisqueRango.cpp $(OBJS)
and the makefile who call them all (same folder of src):
CC := g++
BASEDIR := src
PROJN := disquerango
MODULES := clients couriers products read requests disquerango
OBJS := $(addprefix $(BASEDIR)/,$(MODULES))
all: compila run limpa
compila:
for dir in $(OBJS); do (cd $$dir; ${MAKE} all); done
run: compila
./$(BASEDIR)/$(PROJN)/disquer -e entregadores.csv -c cardapio.csv
limpa:
rm -f $(BASEDIR)/$(PROJN)/disquer
for dir in $(OBJS); do (cd $$dir; rm -f *.o); done