need some help with a makefile

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
cndr
Chaos Rift Cool Newbie
Chaos Rift Cool Newbie
Posts: 65
Joined: Sat Apr 24, 2010 7:03 am
Programming Language of Choice: etc.

need some help with a makefile

Post 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.
Long Live The Queen!
User avatar
Falco Girgis
Elysian Shadows Team
Elysian Shadows Team
Posts: 10294
Joined: Thu May 20, 2004 2:04 pm
Current Project: Elysian Shadows
Favorite Gaming Platforms: Dreamcast, SNES, NES
Programming Language of Choice: C/++
Location: Studio Vorbis, AL
Contact:

Re: need some help with a makefile

Post 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.
Post Reply