#
# Makefile for Perex's player...
#
# Copyright (c) by Jaroslav Kysela (Perex soft)
#

FLAGS	=
DEBUG	=
#DEBUG	= on

########################## read this section #################################

# enable / disable use of shared libraries

STATIC =
#STATIC = ON

# use floating point on/off (maybe better result)
# define this only if you _have_ FPU

#FLOATING_POINT =
FLOATING_POINT = ON

# enable jump effect as default (for loop only)

#FLAGS := $(FLAGS)
FLAGS := $(FLAGS) -DENABLE_JUMP

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

ifdef FLOATING_POINT
FLAGS	:= $(FLAGS) -DUSE_FLOATING_POINT -I/usr/include/ncurses
XM_TBL	= 
else
XM_TBL	= xm_table.inc
endif

ifdef STATIC
STAT	= -static
else
STAT	=
endif

CC	= gcc
LIBS   	= -L/usr/local/lib -lgus
ifdef DEBUG
CFLAGS	= -g -Wall -pipe -DDEBUG
else
CFLAGS	= -O2 -Wall -pipe -m486
endif

CFILES = conv.c \
         load_mod.c load_xm.c load_s3m.c load_mtm.c load_669.c \
         instr.c spline.c misc.c gus.c timer.c effects.c play.c signal.c \
	 detect.c playlist.c pmod.c

OFILES = conv.o \
         load_mod.o load_xm.o load_s3m.o load_mtm.o load_669.o \
         instr.o spline.o misc.o gus.o timer.o effects.o play.o signal.o \
	 detect.o playlist.o pmod.o

.c.o:
	$(CC) $(CFLAGS) $(FLAGS) -c $<

all: pmod

xm_table.inc: compute_xm_table.o
	$(CC) -o compute_xm_table compute_xm_table.o -lm
	compute_xm_table > xm_table.inc

pmod: .depend $(XM_TBL) $(OFILES)
	$(CC) $(STAT) -o pmod $(OFILES) -lm -lncurses $(LIBS)
ifndef DEBUG
	strip pmod
endif
	ls -l pmod

clean:
	rm -f .depend *.o *~ pmod

pack:
	cd ..; tar rvf pgmod.tar \
		pmod/README pmod/POLICY pmod/Makefile pmod/*.c pmod/*.h

install:
	install pmod /usr/local/bin

.depend:
	$(CPP) $(FLAGS) -M $(CFILES) > .depend

dep:	.depend

# ----------------------------------------------------------------------------
#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif
