0
I’m trying to create a Makefile that makes all the files .c
be compiled without me having to add the files line by line in the Makefile.
I tried to keep up with the Creating a Makefile, but I found it very confusing. My interest is the same:
1 - Check all files .c
possess their equivalents .o
;
2 - Not possessing the .o
, create it from the file name .c
, before checking your headers files .h
.
My current Makefile:
BIN = ./bin
OBJ = ./obj
INCLUDE = ./include
SRC = ./src
all:
gcc -c "$(SRC)/Distancias.c" -o "$(OBJ)/Distancias.o"
gcc -c "$(SRC)/ManipulaVetores.c" -o "$(OBJ)/ManipulaVetores.o"
gcc -c "$(SRC)/Classificador.c" -o "$(OBJ)/Classificador.o"
gcc -c "$(SRC)/ManipulaArquivos.c" -o "$(OBJ)/ManipulaArquivos.o"
gcc -c testes.c -o "$(OBJ)/main.o"
gcc -o $(BIN)/main.exe $(OBJ)/*.o -lm
run:
$(BIN)/main.exe
clean:
del /F /Q "$(OBJ)" ".o"
del /F /Q "$(BIN)" ".exe"
I’d like to do something like $(SRC)/*.c
, but I know it’s not that simple because that way it’s not possible to name the .o
.
As to the clean
, I’ve looked for all kinds of commands and I haven’t found a way to make it work on different platforms. As I am on Windows, I am using the del
.