############################################################################
#									   #
# Instructions:								   #
# -------------								   #
# 1. Select the appropriate OS-specific options for your system		   #
# 2. Choose from the options section					   #
# 3. Type "make" and all should (hopefully) work...			   #
#									   #
############################################################################

############################################################################
############################################################################
##									  ##
##			OS-SPECIFIC DEFINITIONS				  ##
##									  ##
############################################################################
############################################################################

############################################################################
#
# Linux/FreeBSD/OSS definitions
#
# for output on linux and FreeBSD Open Sound System (OSS) (/dev/dsp) or 
# Ultrasound driver (/dev/gus)
#
############################################################################

OSDEF=-DOSS
CC = gcc

# if you want to use the Ultra driver uncomment the 3 lines below. 
# You need a Gravis Ultrasound and the library from the Linux Ultrasound 
# project to do this, from http://romeo.pf.jcu.cz/~perex/ultra/
#ULTRA=-DULTRA
#ULTRALIB=-lgus
#ULTRADRV=drv_ultra.o

OSFLAGS = -O2 $(OSDEF) $(ULTRA)
#debug options
#OSFLAGS = -g $(OSDEF) $(ULTRA)

LIBS=-lncurses -lm $(ULTRALIB)
DRIVERS = drv_nos.o drv_raw.o drv_vox.o $(ULTRADRV)

############################################################################
#
# SUN / Solaris definitions (including Solaris/i386)
#
# for output on the Sun audio device (/dev/audio)
#
############################################################################

# for SunOS 4.1.x, enable -DSUNOS, for Solaris 2.x, enable -DSOLARIS
#OSDEF=-DSUNOS -I/usr/5include
#OSDEF=-DSOLARIS

#CC = gcc

# defines
# For Solaris/i386, remove the -DMM_BIG_ENDIAN
#CDEFS=-DNEED_UNISTD -DMM_BIG_ENDIAN -DSUN $(OSDEF)

# Enable this for speed on v8 sparc (microSPARC and newer)
#OSFLAGS = -g -O2 -mv8 -msupersparc -I./include $(CDEFS)
# Enable this to work on v7 sparc
#OSFLAGS = -g -O2 -I./include $(CDEFS)
# SPARCompiler C 4.0 options
#OSFLAGS = -Iinclude -fast -s $(CDEFS)

# Use SysV curses. Gets us the lame SysV libc too. Oh well
#LIBS=-L/usr/5lib -lcurses -lm
# Disable the above and use this on Solaris
#LIBS=-lcurses -lm -lposix4

#DRIVERS = drv_nos.o drv_raw.o drv_sun.o

############################################################################
#
# DEC Alpha / AudioFile definitions
#
# systems using Digital AudioFile library, available from 
# ftp://crl.dec.com/pub/DEC/AF
#
############################################################################

#OSDEF=-DALPHA

# Choose between DEC cc
#CC = cc -g3

# and GNU gcc
#CC = gcc -g


# On my system I have to do
#INCDIR=-I/usr/local/vol/AudioFile/include
#LIBDIR=-L/usr/local/vol/AudioFile/lib

#OSFLAGS = -O2 $(OSDEF) $(INCDIR)
#DRIVERS = drv_nos.o drv_raw.o drv_AF.o
#LIBS=$(LIBDIR) -lcurses -lm -lAF

############################################################################
#
#   AIX definitions
#
############################################################################
 
#OSDEF=-DAIX
#CC = gcc

#OSFLAGS = -O3 -fsigned-char $(OSDEF) -DMM_BIG_ENDIAN

#LIBS=-lcurses -lm
#DRIVERS = drv_nos.o drv_aix.o drv_raw.o

############################################################################
#
#   HP 9000 series / HP-UX definitions
#
############################################################################

#OSDEF=-DHPUX

# To use gcc instead of HP's cc, uncomment the following two lines.
# HP's cc (NOT THE BUNDLED ONE) produces about 6% faster code here 
#CC = gcc
#OSFLAGS = -O3 -funroll-loops -mpa-risc-1-1 -mschedule=7100 $(OSDEF) -DMM_BIG_ENDIAN

# OR use HP's CC:

#CC = cc
#OSFLAGS = -Ae +O3 $(OSDEF) -DMM_BIG_ENDIAN

# Both need these:
#LIBS = -lcurses -L/lib/pa1.1 -lm
#DRIVERS = drv_nos.o drv_raw.o drv_hp.o

############################################################################
#
#   SGI definitions
#
############################################################################

#OSDEF=-DSGI
#CC = gcc

#CFLAGS = -O2 $(OSDEF) $(ZIP) $(USLEEP) $(NCURSES) -DMM_BIG_ENDIAN
#
#LIBS=-lcurses -laudio -lm 
#DRIVERS = drv_nos.o drv_raw.o drv_sgi.o

############################################################################
############################################################################
##									  ##
##			OPTIONS DEFINITIONS				  ##
##									  ##
############################################################################
############################################################################

# if you have unzip etc. installed, enable this for transparent loading of
# zipped mods. If you define this, you may need programs to extract zip,
# lha, gz, arj and zoo archives. Define the locations for these in mikmod.h
ZIP=-DUSE_ZIP

# -s will renice the program to -19, -S will attempt to give it a
# realtime priority (ie. it'll get all the cpu it wants) using
# sched_setscheduler(). Default behaviour remains the same, i.e. to not use
# these
SNAG=-DCPUTIME_SNAGGER

# Does your system have usleep()? If not, you'll need to uncomment this...
#USLEEP=-DNEEDS_USLEEP

# Does your system have curses or ncurses? If the latter, define NCURSES.
#NCURSES=-DNCURSES

CFLAGS = $(OSFLAGS) $(ZIP) $(SNAG) $(USLEEP) $(NCURSES)

############################################################################
############################################################################
##									  ##
##  Common / standard definitions - shouldn't need to touch below here!   ##
##									  ##
############################################################################
############################################################################

LOADERS = load_mod.o load_m15.o load_mtm.o load_s3m.o load_stm.o load_xm.o load_ult.o load_uni.o load_669.o
OBJ = mikcvt.o mloader.o munitrk.o mmio.o
OBJ2 = mikmodux.o virtch.o mloader.o mdriver.o mplayer.o munitrk.o mmio.o ui.o display.o
ARC = marchive.o

all:	mikmod mikcvt

debug:	mikmod-debug

mikmod: $(OBJ2) $(LOADERS) $(DRIVERS) $(ARC)
	$(CC) -Dunix $(CFLAGS) $(ARC) $(OBJ2) $(LOADERS) $(DRIVERS) -o $@ $(LIBS)
	strip $@

mikmod-debug: $(OBJ2) $(LOADERS) $(DRIVERS) $(ARC)
	$(CC) -Dunix $(CFLAGS) $(ARC) $(OBJ2) $(LOADERS) $(DRIVERS) -o $@ $(LIBS)

mikmod-e: $(OBJ2) $(LOADERS) $(DRIVERS) $(ARC)
	$(CC) -Dunix $(CFLAGS) $(ARC) $(OBJ2) $(LOADERS) $(DRIVERS) -o mikmod-debug -lefence $(LIBS)

mikcvt: $(OBJ) $(LOADERS) $(ARC)
	$(CC) -Dunix $(CFLAGS) $(ARC) $(OBJ) $(LOADERS) -o $@ $(LIBS)
	strip $@

clean:
	rm -f $(OBJ) $(OBJ2) $(DRIVERS) $(ARC) $(LOADERS) mikmod mikcvt mikmod-debug *~

tgz:	clean
	(cd ../../ ;tar -cvf - mikmod-2.14-unix/* |gzip -9 >mikmod-2.14-unix.tar.gz)
	cp ../docs/Changes ../docs/ToDo ../..
