Changing makefile to keep .o files out of src folder
Posted: Sun Feb 25, 2018 6:39 pm
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:
Here's what I'm trying to produce:
Here's what I currently end up with:
Makefiles really aren't my thing. Any suggestions?
Here's my current makefile:
Code: Select all
- makefile
- src
- test.c
- include
- test.h
Code: Select all
- makefile
- src
- test.c
- include
- test.h
- build
- test.o
Code: Select all
- makefile
- src
- test.c
- test.o
- include
- test.h
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