
# include dir
IOP_INCS := -I$(PS2LIB_TOP_DIR)/iop/include -I$(PS2LIB_TOP_DIR)/common/include \
	-I. $(IOP_INCS)

# C compiler flags
IOP_CFLAGS := -O2 -G0 -c $(IOP_INCS) $(IOP_CFLAGS)

# linker flags
IOP_LDFLAGS := -nostdlib -L$(PS2LIB_TOP_DIR)/iop/lib $(IOP_LDFLAGS)

# asssembler flags
IOP_ASFLAGS := -mcpu=r3000 -EL -G0 $(IOP_ASFLAGS)

# link with following libraries (libs need to be defined multiple times in order for linking to work!!)
IOP_LIBS += -lkernel

# Externally defined variables: IOP_BIN, IOP_OBJS, IOP_LIB

%.o : %.c
	$(IOP_CC) $(IOP_CFLAGS) $< -o $@

%.o : %.S
	$(IOP_CC) $(IOP_CFLAGS) $< -o $@

%.o : %.s
	$(IOP_AS) $(IOP_ASFLAGS) $< -o $@

$(IOP_BIN) : $(IOP_OBJS)
	$(IOP_CC) $(IOP_LDFLAGS) -o $(IOP_BIN) $(IOP_OBJS) $(IOP_LIBS)

$(IOP_LIB) : $(IOP_OBJS)
	$(IOP_AR) cru $(IOP_LIB) $(IOP_OBJS)
