samedi 25 juin 2016

Makefile in C - no rule to make target

I'm trying to make a Makefile, even tough I can do a simple Makefile, I can't get it working when I need to sort the files in different folders, what I need is /translator folder with: Makefile, src folder with all .c and .h files, files folder with the files to translate, and bin folder for all .o files and the executable.

This is the makefile I made:

CC = gcc
CFLAGS = -Wall -Werror -Wextra -pedantic -std=c99 -g 
OBJECTS = word.o pair.o list.o dict.o set.o

translate : $(OBJECTS)
    mkdir ./files
    mkdir ./bin
    cd ./src; $(CC) $(CFLAGS) -o translate $(OBJECTS) main.c; mv *.o ../bin; mv translate ../bin

word.o: word.c word.h
    cd ./src; $(CC) $(CFLAGS) -c word.c -o word.o

pair.o: pair.c pair.h word.h
    cd ./src; $(CC) $(CFLAGS) -c pair.c -o pair.o

list.o: list.c list.h word.h pair.h
    cd ./src; $(CC) $(CFLAGS) -c list.c -o list.o

dict.o: dict.c dict.h word.h list.h
    cd ./src; $(CC) $(CFLAGS) -c dict.c -o dict.o

set.o: set.c set.h word.h list.h
    cd ./src; $(CC) $(CFLAGS) -c set.c -o set.o

.PHONY : clean

clean  :
    $(RM) ./bin/*.*
    rmdir ./bin

But as soon as I type make the terminal shows:

make: *** No rule to make target `word.c', needed by `word.o'.  Stop.

I previously made a Makefile for Java this way and it worked, and there is, for sure, a file word.h and word.c inside the src folder, so why is it not finding it?

Aucun commentaire:

Enregistrer un commentaire