#	This file is part of Gnomesort
#	Written by Dick Grune, Vrije Universiteit, Amsterdam.
#	$Id: Makefile,v dick Exp $
#

#	S Y S T E M
SYSTEM =	MSDOS#
EXE =		.exe#
ZIP =		pkzip

SYSTEM =	UNIX#
EXE =		#
ZIP =		zip -o

# Entry points:
test_gnomesort:

help:
	@echo  'Entry points:'
	@echo  'test_gnomesort	compile gnomesort and run a simple test'
	@echo  'gnomesort[.exe]	compile gnomesort'
	@echo  ''
	@echo  'package.zip	create publication package'
	@echo  'lint		check sources'
	@echo  ''
	@echo  'clean		remove created files'
	@echo  'fresh		remove created + imported files'

# Compiler Options
C_OPT =		#-O2#		# C optimization level
LIBFLAGS =	#		# library flags
LINTFLAGS =	-h#		# lint flags

# Compilers: GNU + DJGPP v2
CC =		gcc
CFLAGS =	-pedantic -D$(SYSTEM) $(C_OPT)
LINT =		lint -ansi -D$(SYSTEM)

# Parameters for testing 'gnomesort'
## GNOMESORT_FLAGS describes the non-file parameters, GNOMESORT_INPUT the files
GNOMESORT_FLAGS =
GNOMESORT_INPUT =	input

test_gnomesort:	gnomesort$(EXE) $(GNOMESORT_INPUT)
		./gnomesort $(GNOMESORT_FLAGS) $(GNOMESORT_INPUT)

# Definition of 'gnomesort'
GNOMESORT_SRC =	gnomesort.c test.c
GNOMESORT_OBJ =	gnomesort.o test.o
GNOMESORT_HDR =	gnomesort.h
GNOMESORT_GRB =	gnomesort gnomesort.exe

gnomesort$(EXE):	$(GNOMESORT_OBJ)
		$(CC) $(GNOMESORT_OBJ) -o $@ $(LIBFLAGS)


# Installation
install:	$(BINDIR)/gnomesort$(EXE)

$(BINDIR)/gnomesort$(EXE):	gnomesort$(EXE)
		cp -p gnomesort$(EXE) $@

# Publication Package
ZIPS =		src.zip dosexe.zip
ALLFILES =	readme.1st read_me $(ZIPS)
ALLSRC =	Makefile $(GNOMESORT_SRC) $(GNOMESORT_HDR) $(GNOMESORT_INPUT)
DOSEXE =	gnomesort.exe
ZIPS_GRB =	package.zip $(ZIPS)

package.zip:	$(ALLFILES)
		$(ZIP) package $(ALLFILES)

src.zip:	$(ALLSRC)
		$(ZIP) src $(ALLSRC)

dosexe.zip:	$(DOSEXE)
		$(ZIP) dosexe $(DOSEXE)

# Miscellaneous
lint:		$(GNOMESORT_SRC) $(GNOMESORT_HDR)
		$(LINT) $(LINTFLAGS) $(GNOMESORT_SRC)

clean:
		rm -f *.o
		rm -f $(GNOMESORT_GRB)
		rm -f $(ZIPS_GRB)
		rm -f a.out core

fresh:		clean
		rm -f $(LIB_GRB)

# DO NOT DELETE THIS LINE -- make depend depends on it.
gnomesort.o:	gnomesort.h
test.o:		gnomesort.h
