# Copyright (C) by
# Jaap Taal
# The Hague, 16 October 2004

# This file autocompiles all .cc files to executables
# - It gets all .cc files using the function wildcard
# - gets the basename from these .cc files

.PHONY: clean all forceall touchall
# yank all src files
sourcefiles = $(wildcard *.c) $(wildcard *.cpp) $(wildcard *.cc) $(wildcard *.pp) $(wildcard *.pas)
# derive basenames from sourcesfiles
basenames = $(basename $(sourcefiles))

# set cxx compile flags (this variable is used with Make's rules to compile a .cc to a .o)
CFLAGS = -Wall -O2
CXXFLAGS = -Wall -O2

# set link flags to include ncurses (this variable is used with Make's rules to link .o files)
# LDFLAGS= -lncurses

%: %.pas
	fpc -O2 $<
	@rm $@.o

%: %.pp
	fpc -O2 $<
	@rm $@.o


execnames=$(basenames)
# uncomment next line when on Windows OS
#execnames = $(addsuffix .exe, $(basenames))

all: $(basenames)
	cp $(execnames) ../../bin

touchall:
	touch $(sourcefiles)

forceall: touchall all
	

clean:
	rm -f $(basenames)
