Page 1 of 1

Changing makefile to keep .o files out of src folder

Posted: Sun Feb 25, 2018 6:39 pm
by ant512
I'm trying to figure out how to change my PSP makefile to put its .o files in a "build" folder instead of dumping them all in my "src" folder. Here's my folder structure:

Code: Select all

 - makefile
 - src
   - test.c
 - include
   - test.h
Here's what I'm trying to produce:

Code: Select all

 - makefile
 - src
   - test.c
 - include
   - test.h
 - build
   - test.o
Here's what I currently end up with:

Code: Select all

 - makefile
 - src
   - test.c
   - test.o
 - include
   - test.h
Makefiles really aren't my thing. Any suggestions?

Here's my current makefile:

Code: Select all

TARGET_LIB	:=	test.a
LIBDIR		:=	
INCDIR		:=	include
SRCDIR		:=	src

BUILD		:= build

CFILES		:= $(foreach dir,$(SRCDIR),$(notdir $(wildcard $(dir)/*.c)))

OBJS 		:= $(addprefix $(SRCDIR)/,$(CFILES:%.c=%.o))
#OBJS 		:= $(CFILES:%.c=%.o)

CFLAGS		= -O2 -G0 -Wall -std=gnu99 -DTARGET_PSP -Wno-unknown-pragmas -I.
CXXFLAGS	= $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS		= $(CFLAGS)

LDFLAGS		=

LIBS		= -lm

PSPSDK		=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

Re: Changing makefile to keep .o files out of src folder

Posted: Mon Feb 26, 2018 12:07 am
by crimsonwolf8439
I'm very sorry I can't help but I just want to say I'm glad there are still people out there who use the pspdev kits. :shock: :D :lol:

As a side note, maybe could try adding a path to the make?
EG OBJS = src\make.o? :cry: