Help With Makefile For Pad.h

Discuss the development of software, tools, libraries and anything else that helps make ps2dev happen.

Moderators: cheriff, Herben

Post Reply
jgrimm
Posts: 27
Joined: Sun Nov 29, 2009 2:00 am

Help With Makefile For Pad.h

Post by jgrimm »

i have a library called Pad.h wich is a highlevel interface for libpad when i compile a program w/makefile it says "no rule to make pad.o needed by pad.elf stop." Here is Pad.h:

Code: Select all

 #include <tamtypes.h>
#include <kernel.h>
#include <libpad.h>

namespace Ito
&#123;
	class Pad;
&#125;

/** Wrapper class for libpad. 

	\par About
	This is a highlevel interface for libpad. This has been created
	to make it alot easier to work with pads on a simple level.

	If no other irx's are specificed on creation of the first Pad object,
	the Pad class loads the rom0&#58;SIO2MAN and rom0&#58;PADMAN modules and therefor
	its required to link with libpad.a &#40;not libpadx.a!&#41;

	\par Usage

	Create the Pad object, use Open&#40;..&#41; to open a pad on a specific
	port/slot. Then use ReadButtons&#40;&#41; to read pad buttons/directional buttons.
	
	Please see samples in misc/pad directory for further usage.

*/
class Ito&#58;&#58;Pad
&#123;
	private&#58;
		padButtonStatus	m_ButtonStatus ALIGNED&#40;64&#41;;
		u8* m_PadBuffer;
	public&#58;
		s32 m_Port; 
		s32 m_Slot;
	public&#58;
		
		/** Constructor. */
		Pad&#40;char* sio2manIrx = 0, char* padmanIrx = 0&#41;;
		
		/** Destructor. */
		~Pad&#40;&#41;;
		
		/** Open pad.
			\par port port to which the pad is connected &#40;0 or 1&#41;
			\par slot slot to which the pad is connected in a multitap, always 0 when not using multitap.
		*/
		
		s32 Open&#40;s32 port, s32 slot&#41;;
		/** Close pad. */
		s32 Close&#40;&#41;;

		/** Get pad state. Please see libpad.h for pad states.*/
		u32 GetState&#40;&#41;;
		/** Read buttons. Can be used after opening the pad with Open&#40;..&#41;
		
		\par You can use the following libpad defines to read the pad
		PAD_LEFT, PAD_DOWN, PAD_RIGHT, PAD_UP, PAD_START
		PAD_R3, PAD_L3, PAD_SELECT, PAD_SQUARE, PAD_CROSS     
		PAD_CIRCLE, PAD_TRIANGLE, PAD_R1, PAD_L1, PAD_R2, PAD_L2

		\par Example of usage
		
		u32 buttons = pad.ReadButtons&#40;&#41;;

		if&#40;buttons & PAD_CROSS&#41;
		&#123;	
			.. // Code to execute when cross on the pad was pressed.
		&#125;


		*/
		u16 ReadButtons&#40;&#41;;
&#125;;
And Here Is Makefile:

Code: Select all

 EE_BIN = pad.elf
EE_OBJS = Pad.o paddemo.o libpad.a
EE_LIBS = -ldebug 

all&#58; $&#40;EE_BIN&#41;
	ee-strip --strip-all $&#40;EE_BIN&#41;

clean&#58;
	rm -f *.elf *.o *.a

run&#58; $&#40;EE_BIN&#41;
	ps2client execee host&#58;$&#40;EE_BIN&#41;

reset&#58;
	ps2client reset


include $&#40;PS2SDK&#41;/samples/Makefile.pref
include $&#40;PS2SDK&#41;/samples/Makefile.eeglobal
I think i am linking libpad.a correctly. what do i need to add to the makefile to make a rule for compiling Pad.h ? plz help -jsngrimm
aries2k
Posts: 11
Joined: Sun Jan 13, 2008 4:35 am
Location: Portugal

Post by aries2k »

Well, I´m a newbie at this but I think you need

EE_LIBS = -ldebug -lpad

as far as I know you shouldn´t have it in th EE_OBJS
ragnarok2040
Posts: 202
Joined: Wed Aug 09, 2006 1:00 am

Post by ragnarok2040 »

There isn't a rule for compiling headers in the current ps2sdk makefile system. You can add a custom rule to do it, though.

Code: Select all

EE_H_FLAGS = -D_EE -O2 -G0 -Wall
EE_H_INCS = -I$&#40;PS2SDK&#41;/ee/include -I$&#40;PS2SDK&#41;/common/include -I.

%.gch &#58; %.h
<tab>ee-g++ $&#40;EE_H_FLAGS&#41; $&#40;EE_H_INCS&#41; -c $< -o $@
I've never actually done it before, thinking gcc-3.2.2 didn't have support for it, lol. I'm not sure if that's the proper way to do it, you might need to fiddle around with it a bit.

You should also link in -lstdc++ in EE_LIBS, since you're using Makefile.eeglobal.
jgrimm
Posts: 27
Joined: Sun Nov 29, 2009 2:00 am

Post by jgrimm »

ok thx guys and i hav gcc 3.4.4 so that shouldnt be a problem
Post Reply