Page 1 of 1

need some help with a makefile

Posted: Mon Nov 01, 2010 9:06 pm
by cndr
I just started learning how to make makefiles, and am wondering how to move the .o files to their own folder to make everything neater. Below is my working makefile, any ideas?

Code: Select all

CC=gcc
CFLAGS=-I -lSDL -lSDL_image -lSDL_mixer -lGLU -Wall 
DEPS = piece.h engine.h include.h
OBJ = main.o piece.o engine.o include.o

%.o: %.c $(DEPS)
	$(CC) -c -o $@ $< $(CFLAGS)

build: $(OBJ)
	gcc -o $@ $^ $(CFLAGS)
#edit mv main.o engine.o include.o piece.o obj
#edit I sorta solved it by using the mv command.

Re: need some help with a makefile

Posted: Tue Nov 23, 2010 4:29 pm
by Falco Girgis
Or you could have appended the folder name directly to the list of objects... Or you could have had a FOLDER variable and used (forgot the actual command) something to iterate through your list of objects and append it automatically.