
#
# This is spigot/makefile
#

ifeq ($(suffix $(MAKE)),.exe) # switch for MS DOS options
	CXX=gxx                    # MS DOS options
	XSUFFIX=.exe
	RM=-del
	COPY=copy
else                          # LINUX options
	CC=gcc -static
	XSUFFIX=.elf
	LIBS=-lm
	COPY=cp
endif

CXXFLAGS=-ansi -O   # all programs are ansi c compliant

TARGETS= \
pitiny$(XSUFFIX) \
pifull$(XSUFFIX) \
etiny$(XSUFFIX)  \
efull$(XSUFFIX)


.PHONY: all runall new

all:  $(TARGETS)

# avoid warnings when compiling pitiny.c and etiny.c , so use -w (no warnings)
%tiny$(XSUFFIX) : %tiny.c
	$(CC) $(CXXFLAGS) -w $(LIBS) -o $@  $(filter %.c, $+)
	strip $@

# pifull and efull shouldn't issue warnings
%full$(XSUFFIX) : %full.c %check.c %check.h
	$(CC) $(CXXFLAGS)  -Wall $(LIBS) -o $@  $(filter %.c, $+) 
	strip $@

new:
	$(RM) *tiny$(XSUFFIX)
	$(RM) *full$(XSUFFIX)
	$(MAKE) all

runall : $(TARGETS)
	pifull$(XSUFFIX)
	-pitiny$(XSUFFIX) 
	pifull$(XSUFFIX)
	-etiny$(XSUFFIX)
	efull$(XSUFFIX)
