-1

My path:

./folder1/folder2/

My makefile is located in folder1.

My makefile:

CC = g++
FLAGS = -o3 -std=c++11

all: prng.o exec

prng.o: ./folder2/prng.cpp
    $(CC) $(FLAGS) -o $@ $<

exec: prng.o
    /$<

prng.o is generated in folder1. I want it to be generated in folder2. How to do that?

1 Answers1

0
CC = g++
FLAGS = -o3 -std=c++11

all: folder1/prng.o exec

folder1/prng.o: folder2/prng.cpp
    $(CC) $(FLAGS) -o $@ $<

exec: prng.o
    /$<

BTW, your C compiler should have a C11 binary, something like /usr/bin/c11. That would let you say,

CC = c11
CFLAGS = -o3

Also, by using CFLAGS (instead of FLAGS), you shouldn't have to mention it in the recipe.

James K. Lowden
  • 7,574
  • 1
  • 16
  • 31