Jan 31, 2017 at 1:12am UTC
I tried to make a makefile for a program I am working on, and it isn't behaving how it should. If I run "make serial" it will recompile the code, no matter what. Is there anything visibly wrong with the makefile?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
CFLAGS = -Wall -O3
LFLAGS = -Wall
DEFAULTC = -DOMP -fopenmp
SERIALC = -Wno-pragmas
bam: main.o Model.o
g++ $(LFLAGS) Model.o main.o -o bam
serial: main.serial.o Model.serial.o
g++ $(LFLAGS) Model.serial.o main.serial.o -o bam
Model.o: Model.h
g++ $(CFLAGS) $(DEFAULTC) -o Model.o -c Model.cpp
main.o: Model.h
g++ $(CFLAGS) $(DEFAULTC) -o main.o -c main.cpp
Model.serial.o: Model.h
g++ $(CFLAGS) $(SERIALC) -o Model.serial.o -c Model.cpp
main.serial.o: Model.h
g++ $(CFLAGS) $(SERIALC) -o main.serial.o -c main.cpp
Model.h: Point.h Atom.h
Atom.h: Partner.h Vector.h
Last edited on Jan 31, 2017 at 1:12am UTC
Jan 31, 2017 at 7:44am UTC
the `serial' rule does not create a `serial' file
https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
If you write a rule whose recipe will not create the target file, the recipe will be executed every time the target comes up for remaking.
By the way, you should include the *.cpp files as prerequisites.
Also
Model.h: Point.h Atom.h
, ¿why is a header file a target?
Last edited on Jan 31, 2017 at 7:45am UTC