#
# Makefile for 'mod'. Requires GNU-make (at least I think it does).
#
# (C) 1994 Mikael Nordqvist (d91mn@efd.lth.se, mech@df.lth.se)
#

#
# Targets:
#
# all:       Create the executable(s).
# install:   Installs the executable and the manual-page(s).
# clean:     Remove all object-files.
# distclean: All unnecessary files (except protos.h) are removed.
#

MODVERSION = 0.61

CC = gcc

#
# Below you can configure 'mod' to your needs.
#

# Make sure that your ncurses-directory is searched for include-files.

CFLAGS  = -pipe -Wall -I/usr/include/ncurses
LDFLAGS = -lncurses

#
# Select a sutiable set of CFLAGS below.
#

# Optimized

CFLAGS  += -fomit-frame-pointer -m486 -O2 
LDFLAGS += -s

# Normal options

#CFLAGS  +=
#LDFLAGS += -s

# Debugging and optimization

#CFLAGS += -g -O2

# Debugging

#CFLAGS += -g

#
# Compile-time configurable options. Comment/uncomment to your wishes.
#

# Enable if you want to check for color-support before trying to use it.
# If disabled, we bypass the check and just hope it works.

CFLAGS+=-DNCURSES_CHECK_FOR_COLOR

# On slow machines you might get "lagged behind" when scrolling the file-list
# as screen-updating is slow. Define FLUSH_INPUT if you always want to be
# in sync, even if file-selection gets a bit more sluggish. (This is actually
# a general switch that will flush the input after whatever operation
# was requested has finished).

#CFLAGS+=-DFLUSH_INPUT

#
# Installation paths (no trailing /).
#

BINDIR = /usr/local/bin
MANDIR = /usr/local/man/man1

#
# Dependencies. Nothing below this line needs changing for a normal
# installation.
#

OBJS= main.o controller.o player.o screen.o options.o init.o myseq.o \
      file.o play.o sample.o load.o load_mod.o load_ult.o load_mtm.o \
      load_s3m.o effects.o tables.o util.o debug.o mklist.o help.o

all: mod

mod: $(OBJS)
	gcc -o mod $(OBJS) $(LDFLAGS)

clean:
	rm -f $(OBJS)

distclean: clean
	rm -f mod

install:
	install mod $(BINDIR); ln -sf $(BINDIR)/mod $(BINDIR)/mod_mklist;\
        install -m 644 mod.1 $(MANDIR); install -m 644 mod_mklist.1 $(MANDIR)

#
# These targets are used only while maintaining 'mod'.
#

pmod: $(OBJS)
	gcc -o pmod $(OBJS) $(LDFLAGS) -p

protos:
	./make_protos > protos.h

dist: distclean
	ls > FILES; cd ..; tar zcvf mod-$(MODVERSION).tgz mod

bak:
	cd ..; tar zcvf mod.`date +"%y%m%d"`.tgz mod

# No dependence on protos.h (I handle that manually)

$(OBJS): mod.h
controller.o play.o player.o util.o: message.h
