I'm trying to create a Makefile that will compile and run 3 different implementations of a markov algorithm all at once. I'm new to makefiles so if there's multiple mistakes, please let me know. Also, if I wanted to optimize the compiles with -O3, where would I do that?
When I run, I currently get these errors:
Makefile:28: warning: overriding commands for target `markov.o'
Makefile:22: warning: ignoring old commands for target `markov.o'
make: * No rule to make target
Markov.java', needed by
java_markov.class'. Stop.
Here is the code for my makefile:
javaC=javac
javaR=java
CC=g++
CC=gcc
CFLAGS=-O0
OPT=-deprecation
TARGET1=./java_markov
TARGET2=./markov_cpp
TARGET3=./markov_c
INFILE=./alice30.txt
OUTFILE1=./markov_java_out.txt
OUTFILE2=./output/markov_cpp_out.txt
OUTFILE3=./output/markov_c_out.txt
$(TARGET1).class: Markov.java
$(javaC) Markov.java
$(TARGET2): markov.o
$(CC) $(CFLAGS) -o $(TARGET2) markov.o
markov.o: markov.cpp
$(CC) $(CFLAGS) -c markov.cpp
$(TARGET3) : markov.o eprintf.o
$(CC) $(CFLAGS) -o $(TARGET3) markov.o eprintf.o
markov.o : markov.c
$(CC) $(CFLAGS) -c markov.c
eprintf.o : eprintf.c eprintf.h
$(CC) $(CFLAGS) -c eprintf.c
clean:
rm -f *.class $(OUTFILE1)
rm -f *.o $(TARGET2) $(OUTFILE2)
rm -f *.o $(TARGET3) $(OUTFILE3)
run: $(TARGET1).class
$(javaR) $(TARGET1) < $(INFILE) > $(OUTFILE1)
$(TARGET2)
$(TARGET2) <$(INFILE) >$(OUTFILE2)
$(TARGET3)
$(TARGET3) < $(INFILE) > $(OUTFILE3)