# Makefile for sdir
# (c) 1997 Stephan Fuhrmann

# path/system settings
DEST=/bin		# here we'll install the sdir binary
MANDEST=/usr/man/man1	# here we'll install the sdir manual page
# POSIX commands
CP=cp
RM=rm
# Option for rm to ignore nonexistent files
RMFORCE=-f
INSTALL=install
MKDIR=mkdir

# Compiler settings
# gnu-c compiler
CC=gcc
# compile for 486, full optimization
CCOPTS=-m486 -O3 -Wall
# link with math library
LDOPTS=-lm
# specification for output name
TO=-o

# optional strip command to remove symbols from executable
STRIP=strip
#STRIP=echo >/dev/nul

#
# No need to change anything beyond this line!
#
DIST=./distribution
CD=cd
MV=mv
MAKE=make
MAKECHDIR=-C
RMRECURSIVE=-r
TAR=tar
TARFLAGS=-czvf
VERSION=0.50

all: sdir

clean:
	$(RM) $(RMFORCE) *.o
	$(RM) $(RMFORCE) sdir

install: all sdir-man/sdir.1
	$(INSTALL) sdir $(DEST)
	$(INSTALL) sdir-man/sdir.1 $(MANDEST)

sdir: sdir.c
	$(CC) sdir.c $(CCOPTS) $(LDOPTS) $(TO) sdir
	$(STRIP) sdir

# Stuff beyond this line is only for private use
# by the author!
dist-clean: clean
	$(MAKE) $(MAKECHDIR) sdir-tex/english clean
	$(MAKE) $(MAKECHDIR) sdir-tex/german clean

sdir-tex/english/sdir.dvi:
	$(MAKE) $(MAKECHDIR) sdir-tex/english sdir

sdir-tex/german/sdir.dvi:
	$(MAKE) $(MAKECHDIR) sdir-tex/german sdir

archive: distribution
# Delete old archive dir
	$(RM) $(RMFORCE) $(RMRECURSIVE) sdir-$(VERSION)
	$(MV) $(DIST) sdir-$(VERSION)
# Create Dir to put the archive in
	$(RM) $(RMFORCE) $(RMRECURSIVE) sdir-arc
	$(MKDIR) sdir-arc
	$(TAR) $(TARFLAGS) sdir-arc/sdir-$(VERSION).tgz sdir-$(VERSION)
	$(CP) sdir.lsm sdir-arc/sdir-$(VERSION).lsm

distribution: all sdir-man/sdir.1 sdir-tex/english/sdir.dvi sdir-tex/german/sdir.dvi
# Delete old, create new dist-directory
	$(RM) $(RMFORCE) $(RMRECURSIVE) $(DIST)
	$(MKDIR) $(DIST)
# Copy the lsm-file
	$(CP) sdir.lsm $(DIST)/sdir-$(VERSION).lsm
# Copy the source
	$(CP) sdir.c $(DIST)
# Copy the Makefile
	$(CP) Makefile $(DIST)
# Copy the manual page to the dist-dir
	$(MKDIR) $(DIST)/sdir-man
	$(CP) sdir-man/sdir.1 $(DIST)/sdir-man
# Copy the LaTeX-dvi-files
	$(MKDIR) $(DIST)/sdir-tex
	$(CP) sdir-tex/english/sdir.dvi $(DIST)/sdir-tex/sdir-english.dvi
	$(CP) sdir-tex/german/sdir.dvi $(DIST)/sdir-tex/sdir-german.dvi
