forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Usual makefile

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
Rav



Joined: 01 Jun 2007
Posts: 11
Location: France

PostPosted: Thu Jul 05, 2007 5:12 am    Post subject: Usual makefile Reply with quote

I wonder if it's possible to use a standard makefile : I mean something with

Code:

all: main.o
  gcc main.o

main.o: a.c
  gcc -c a.c -o a.o


Because it's hard for me to understand this one :
Code:

TARGET = Sprite
OBJS = Fonctions/framebuffer.o Fonctions/graphics.o Sprite.o

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

LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lstdc++
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sprite

PSPSDK = /usr/local/pspdev/psp/sdk/
include $(PSPSDK)/lib/build.mak


Can someone give me a file with the structure explained above ? Thanks
Back to top
View user's profile Send private message Visit poster's website
TyRaNiD



Joined: 18 Jan 2004
Posts: 918

PostPosted: Thu Jul 05, 2007 6:00 am    Post subject: Reply with quote

Sure it is but the end result will be little different to what you have already, in fact it will probably be worse :)
Back to top
View user's profile Send private message
Rav



Joined: 01 Jun 2007
Posts: 11
Location: France

PostPosted: Thu Jul 05, 2007 6:05 am    Post subject: Hum... Reply with quote

I think that I should play with this :
Code:

all: $(EXTRA_TARGETS) $(FINAL_TARGET)

kxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
   mkdir -p "$(TARGET)"
   $(STRIP) $(TARGET).elf -o $(TARGET)/$(PSP_EBOOT)
   mkdir -p "$(TARGET)%"
   $(PACK_PBP) "$(TARGET)%/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

SCEkxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
   mkdir -p "__SCE__$(TARGET)"
   $(STRIP) $(TARGET).elf -o __SCE__$(TARGET)/$(PSP_EBOOT)
   mkdir -p "%__SCE__$(TARGET)"
   $(PACK_PBP) "%__SCE__$(TARGET)/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
   $(LINK.c) $^ $(LIBS) -o $@
   $(FIXUP) $@

$(TARGET_LIB): $(OBJS)
   $(AR) cru $@ $(OBJS)
   $(RANLIB) $@

$(PSP_EBOOT_SFO):
   $(MKSFO) '$(PSP_EBOOT_TITLE)' $@

ifeq ($(BUILD_PRX),1)
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
   $(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0)  $(TARGET).prx $(PSP_EBOOT_PSAR)
else
$(PSP_EBOOT): $(TARGET).elf $(PSP_EBOOT_SFO)
   $(STRIP) $(TARGET).elf -o $(TARGET)_strip.elf
   $(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0)  $(TARGET)_strip.elf $(PSP_EBOOT_PSAR)
   -rm -f $(TARGET)_strip.elf
endif

%.prx: %.elf
   psp-prxgen $< $@

%.c: %.exp
   psp-build-exports -b $< > $@


But I guess I'll need time to understand all these vars ^^.

But with that, I'll have a better understanding of what is hapenning.
Back to top
View user's profile Send private message Visit poster's website
Rav



Joined: 01 Jun 2007
Posts: 11
Location: France

PostPosted: Fri Jul 06, 2007 5:31 am    Post subject: Here is my usual makefile Reply with quote

I've modified the makefile in a way I better understand, here it comes :
Code:

TARGET = Sprite2D
OBJS = Functions/framebuffer.o Functions/graphics.o ISprite.o Sprite2D.o TestSprite2D.o

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

LIBDIR =
LIBS = -lpspgu -lpng -lz -lm -lstdc++
LDFLAGS =

EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = Sprite

PSPSDK = /usr/local/pspdev/psp/sdk

###########################################################################################################
# PSP Software Development Kit - http://www.pspdev.org
# -----------------------------------------------------------------------
# Licensed under the BSD license, see LICENSE in PSPSDK root for details.
#
# build.mak - Base makefile for projects using PSPSDK.
#
# Copyright (c) 2005 Marcus R. Brown <mrbrown@ocgnet.org>
# Copyright (c) 2005 James Forshaw <tyranid@gmail.com>
# Copyright (c) 2005 John Kelley <ps2dev@kelley.ca>
#
# $Id: build.mak 2214 2007-04-12 20:04:48Z jim $

# Note: The PSPSDK make variable must be defined before this file is included.
ifeq ($(PSPSDK),)
$(error $$(PSPSDK) is undefined.  Use "PSPSDK := $$(shell psp-config --pspsdk-path)" in your Makefile)
endif

CC       = psp-gcc
CXX      = psp-g++
AS       = psp-gcc
LD       = psp-gcc
AR       = psp-ar
RANLIB   = psp-ranlib
STRIP    = psp-strip
MKSFO    = mksfo
PACK_PBP = pack-pbp
FIXUP    = psp-fixup-imports

# Add in PSPSDK includes and libraries.
INCDIR   := $(INCDIR) . $(PSPSDK)/include
LIBDIR   := $(LIBDIR) . $(PSPSDK)/lib

CFLAGS   := $(addprefix -I,$(INCDIR)) $(CFLAGS)
CXXFLAGS := $(CFLAGS) $(CXXFLAGS)
ASFLAGS  := $(CFLAGS) $(ASFLAGS)

ifeq ($(PSP_FW_VERSION),)
PSP_FW_VERSION=150
endif

CFLAGS += -D_PSP_FW_VERSION=$(PSP_FW_VERSION)

ifeq ($(BUILD_PRX),1)
LDFLAGS  := $(addprefix -L,$(LIBDIR)) -specs=$(PSPSDK)/lib/prxspecs -Wl,-q,-T$(PSPSDK)/lib/linkfile.prx $(LDFLAGS)
EXTRA_CLEAN += $(TARGET).elf
# Setup default exports if needed
ifdef PRX_EXPORTS
EXPORT_OBJ=$(patsubst %.exp,%.o,$(PRX_EXPORTS))
EXTRA_CLEAN += $(EXPORT_OBJ)
else
EXPORT_OBJ=$(PSPSDK)/lib/prxexports.o
endif
else
LDFLAGS  := $(addprefix -L,$(LIBDIR)) $(LDFLAGS)
endif

# Library selection.  By default we link with Newlib's libc.  Allow the
# user to link with PSPSDK's libc if USE_PSPSDK_LIBC is set to 1.

ifeq ($(USE_KERNEL_LIBC),1)
# Use the PSP's kernel libc
PSPSDK_LIBC_LIB =
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
ifeq ($(USE_PSPSDK_LIBC),1)
# Use the pspsdk libc
PSPSDK_LIBC_LIB = -lpsplibc
CFLAGS := -I$(PSPSDK)/include/libc $(CFLAGS)
else
# Use newlib (urgh)
PSPSDK_LIBC_LIB = -lc
endif
endif


# Link with following default libraries.  Other libraries should be specified in the $(LIBS) variable.
# TODO: This library list needs to be generated at configure time.
#
ifeq ($(USE_KERNEL_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay_driver -lpspctrl_driver -lpspsdk
LIBS     := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspkernel
else
ifeq ($(USE_USER_LIBS),1)
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS     := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
         -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
         -lpspuser
else
PSPSDK_LIBS = -lpspdebug -lpspdisplay -lpspge -lpspctrl -lpspsdk
LIBS     := $(LIBS) $(PSPSDK_LIBS) $(PSPSDK_LIBC_LIB) -lpspnet \
         -lpspnet_inet -lpspnet_apctl -lpspnet_resolver -lpsputility \
         -lpspuser -lpspkernel
endif
endif

# Define the overridable parameters for EBOOT.PBP
ifndef PSP_EBOOT_TITLE
PSP_EBOOT_TITLE = $(TARGET)
endif

ifndef PSP_EBOOT_SFO
PSP_EBOOT_SFO = PARAM.SFO
endif

ifndef PSP_EBOOT_ICON
PSP_EBOOT_ICON = NULL
endif

ifndef PSP_EBOOT_ICON1
PSP_EBOOT_ICON1 = NULL
endif

ifndef PSP_EBOOT_UNKPNG
PSP_EBOOT_UNKPNG = NULL
endif

ifndef PSP_EBOOT_PIC1
PSP_EBOOT_PIC1 = NULL
endif

ifndef PSP_EBOOT_SND0
PSP_EBOOT_SND0 = NULL
endif

ifndef PSP_EBOOT_PSAR
PSP_EBOOT_PSAR = NULL
endif

ifndef PSP_EBOOT
PSP_EBOOT = EBOOT.PBP
endif

ifeq ($(BUILD_PRX),1)
ifneq ($(TARGET_LIB),)
$(error TARGET_LIB should not be defined when building a prx)
else
FINAL_TARGET = $(TARGET).prx
endif
else
ifneq ($(TARGET_LIB),)
FINAL_TARGET = $(TARGET_LIB)
else
FINAL_TARGET = $(TARGET).elf
endif
endif

###########################################################################################################

all: $(EXTRA_TARGETS) $(FINAL_TARGET)

include Functions/Makefile
   
#Functions/graphics.o: Functions/graphics.c Functions/graphics.h  Functions/framebuffer.o
#   $(CC) -o $@ -c $< $(CFLAGS)
   
ISprite.o: ISprite.cpp ISprite.hpp
   $(CC) -o $@ -c $< $(CFLAGS)
   
Sprite2D.o: Sprite2D.cpp Sprite2D.hpp Functions/graphics.o
   $(CC) -o $@ -c $< $(CFLAGS)
   
TestSprite2D.o: TestSprite2D.cpp Sprite2D.hpp Sprite2D.cpp
   $(CC) -o $@ -c $< $(CFLAGS)
   
###########################################################################################################

kxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
   mkdir -p "$(TARGET)"
   $(STRIP) $(TARGET).elf -o $(TARGET)/$(PSP_EBOOT)
   mkdir -p "$(TARGET)%"
   $(PACK_PBP) "$(TARGET)%/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

SCEkxploit: $(TARGET).elf $(PSP_EBOOT_SFO)
   mkdir -p "__SCE__$(TARGET)"
   $(STRIP) $(TARGET).elf -o __SCE__$(TARGET)/$(PSP_EBOOT)
   mkdir -p "%__SCE__$(TARGET)"
   $(PACK_PBP) "%__SCE__$(TARGET)/$(PSP_EBOOT)" $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0) NULL $(PSP_EBOOT_PSAR)

$(TARGET).elf: $(OBJS) $(EXPORT_OBJ)
   $(LINK.c) $^ $(LIBS) -o $@
   $(FIXUP) $@

$(TARGET_LIB): $(OBJS)
   $(AR) cru $@ $(OBJS)
   $(RANLIB) $@

$(PSP_EBOOT_SFO):
   $(MKSFO) '$(PSP_EBOOT_TITLE)' $@

ifeq ($(BUILD_PRX),1)
$(PSP_EBOOT): $(TARGET).prx $(PSP_EBOOT_SFO)
   $(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0)  $(TARGET).prx $(PSP_EBOOT_PSAR)
else
$(PSP_EBOOT): $(TARGET).elf $(PSP_EBOOT_SFO)
   $(STRIP) $(TARGET).elf -o $(TARGET)_strip.elf
   $(PACK_PBP) $(PSP_EBOOT) $(PSP_EBOOT_SFO) $(PSP_EBOOT_ICON)  \
      $(PSP_EBOOT_ICON1) $(PSP_EBOOT_UNKPNG) $(PSP_EBOOT_PIC1)  \
      $(PSP_EBOOT_SND0)  $(TARGET)_strip.elf $(PSP_EBOOT_PSAR)
   -rm -f $(TARGET)_strip.elf
endif

%.prx: %.elf
   psp-prxgen $< $@

%.c: %.exp
   psp-build-exports -b $< > $@

clean:
   -rm -f $(FINAL_TARGET) $(EXTRA_CLEAN) $(OBJS) $(PSP_EBOOT_SFO) $(PSP_EBOOT) $(EXTRA_TARGETS)

rebuild: clean all


I had to put my rules above the "exotic" ones in order to have them used. I tried adding my rules at the end of the original makefile but it didn't work.
Back to top
View user's profile Send private message Visit poster's website
Wally



Joined: 26 Sep 2005
Posts: 672

PostPosted: Fri Jul 06, 2007 3:42 pm    Post subject: Reply with quote

i like that one, it makes much more sense
Back to top
View user's profile Send private message AIM Address
ufoz



Joined: 10 Nov 2005
Posts: 86
Location: Tokyo

PostPosted: Fri Jul 06, 2007 4:49 pm    Post subject: Reply with quote

TyRaNiD wrote:
Sure it is but the end result will be little different to what you have already, in fact it will probably be worse :)


Lo and behold...
Back to top
View user's profile Send private message Visit poster's website AIM Address MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group