################################################################################
# $Id: Makefile,v 1.2 1999/01/30 06:38:37 andrewk Exp $
################################################################################
# 
# piocons - PSX PIO console utility for linux
# Copyright (C) 1997,1998 by "The PIOCONS Team" (see AUTHORS)
# All Rights Reserved.
# 
################################################################################

CC		= gcc 
MAKE	= make
TARGET	= piocons

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

SRCS = main.c rom.c pio.c vram.c caetla.c ezoray.c cpe.c bfd.c psx.c card.c \
	tim.c error.c ppm.c getint.c

OBJS = $(SRCS:.c=.o)

################################################################################
# do a 'DEBUG=1 make' to get a debug version.

ifeq ($(DEBUG),1)
  CFLAGS   = -g -O
  DEFINES  = -DDEBUG 
  LDFLAGS  =
else
  CFLAGS   = -O3 -fomit-frame-pointer
  DEFINES  =  
  LDFLAGS  = -s
endif

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

SONY = /usr/local
INCPATH = -I$(SONY)/include
LIBPATH = -L$(SONY)/lib

CFLAGS   += -pipe -Wall $(INCPATH) $(DEFINES)
LDFLAGS  += $(LIBPATH) -Wl,-Bstatic -lbfd -liberty -Wl,-Bdynamic

FTPTARGET = $(TARGET)-$(shell cat VERSION).tar.gz

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

all: $(TARGET)
	su -c "chown root.root $(TARGET) ; chmod 4755 $(TARGET) ; mv $(TARGET) /usr/local/bin "

$(TARGET): .deps $(OBJS)
	$(CC) -o $(TARGET) $(OBJS) $(LDFLAGS) 

clean::
	rm -rf core .deps $(TARGET) $(OBJS)

ftp:: clean
	cd .. ; $(RM) $(FTPTARGET) ; tar zcpf $(FTPTARGET) $(TARGET)

.deps:
	makedepend -f- $(DEFINES) $(INCPATH) $(SRCS) > .deps

-include .deps

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