Help ~ makefile problems

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
viridite
Posts: 16
Joined: Thu Nov 08, 2007 4:28 am

Help ~ makefile problems

Post by viridite »

i want to make some folders for my project and i want the compiler to compile *.c under /src and output objs to /obj folder.

i checked the build.mak but never found where CC and CFLAGS are used. so i'm confused that where is the rule which makes *.c to *.o?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

viridite
Posts: 16
Joined: Thu Nov 08, 2007 4:28 am

Post by viridite »

jimparis wrote:Implicit rules
http://web.mit.edu/6.033/labdoc/make_10.html
i don't think so. because if so how does the make command know which flags are the wanted one?
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Because the implicit rules invoke $CC and use $CFLAGS.
viridite
Posts: 16
Joined: Thu Nov 08, 2007 4:28 am

Post by viridite »

ok... thanks
that means i just need to write down the rules directly then i can get what i want?

ok.. could you please check this condition?

there are two folders under the root:
src
obj

then my makefile will be like this:

Code: Select all


ROOT := $(shell pwd)
MODULE_OBJS	=
ZOUT		= $(ROOT)/zout
INCDIR +=$(ROOT)/include
OUTDIR = $(ROOT)/out
OBJDIR =$(ROOT)/obj
SRCDIR =$(ROOT)/src
VPATH =$(OBJDIR)

OBJS = $(OBJDIR)/main.o $(OBJDIR)/kernel.o $(OBJDIR)/graphics.o $(OBJDIR)/menulogic.o
LIBS += -lSDLmain -lSDL -lSDL_ttf -lfreetype -lSDL_image -ljpeg -lpng -lz -lg -lstdc++ -lm -lpsppower -lpspgum_vfpu -lpspgu
TARGET = UI



CFLAGS = -O2 -G0 -Wall
CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
ASFLAGS = $(CFLAGS)

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = UI

PSPSDK=$(shell psp-config --pspsdk-path)
PSPBIN = $(PSPSDK)/../bin
CFLAGS += $(shell $(PSPBIN)/sdl-config --cflags)
LIBS += $(shell $(PSPBIN)/sdl-config --libs)


%.o : $(SRCDIR)/%.c
	$&#40;CC&#41; -c $&#40;CFLAGS&#41; $&#40;CPPFLAGS&#41; $< -o $&#40;OBJDIR&#41;/$@
include $&#40;PSPSDK&#41;/lib/build.mak
but when i type "make" , the screen outputs:

Code: Select all

make&#58; *** No rule to make target `D&#58;/docs/psp/UI/obj/main.o', needed by `UI.elf'
could you check for me the reason?

. Stop.
jimparis
Posts: 1145
Joined: Fri Jun 10, 2005 4:21 am
Location: Boston

Post by jimparis »

Use something like

Code: Select all

OBJS=obj/asdf.o

obj/%.o&#58; src/%.c
        $&#40;COMPILE.c&#41; -o $@ $<
Post Reply