# Author: Tobi Vollebregt

#   Bataafje -- A small game written for the Allegro SpeedHack 2003
#   Copyright (C) 2003  Tobi Vollebregt
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
#   See `License.txt', which contains a verbatim copy of the
#   GNU General Public License, for details.
#
#   Please send your reaction to: tobivollebregt@hotmail.com
#
#
#   Makefile for DJGPP/linux
#   ------------------------
#
# Makefile targets:
#   make            - Compile my speedhack-2003 entry.
#   make nibbles    - Compile the "nibbles" program separately
#   make intro      - Compile the 3d intro program separately
#   make fractal    - Compile the 3d fractal program separately
#   make all        - Compile all the programs
#   make clean      - Erase all object files and dependency files
#   make distclean  - Erase also the executable files
#

.PHONY: all clean distclean fractal life nibbles

ifdef DJGPP
CXX=gpp
LD=gpp
EXE_SUFFIX=.exe
else
CXX=g++
LD=g++
EXE_SUFFIX=
endif

RM=rm -f
CC=gcc
CXXFLAGS=-O3
CFLAGS=-O3
CPPFLAGS=-DDEBUGMODE=1
LDFLAGS=-s
LDLIBS=-lalleg

SH_EXE=bataafje$(EXE_SUFFIX)
SH_SRC=anim.cpp cloud.cpp enemy.cpp fade16.c intro.c main.cpp nibbles.c object.cpp player.cpp
SH_OBJ=$(addsuffix .o,$(basename $(SH_SRC)))

$(SH_EXE): $(SH_OBJ)
	$(LD) -o $@ $^ $(LDLIBS) $(LDFLAGS)
all: $(SH_EXE) nibbles fractal intro ;

nibbles: nibbles.c
	$(CC) -DSTANDALONE_NIBBLES=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o nibbles$(EXE_SUFFIX) $(LDLIBS)
fractal: intro.c fade16.c
	$(CC) -DSTANDALONE_FRACTAL=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o fractal$(EXE_SUFFIX) $(LDLIBS)
intro: intro.c fade16.c
	$(CC) -DSTANDALONE_INTRO=1 $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $^ -o intro$(EXE_SUFFIX) $(LDLIBS)

%.o: %.cpp
	$(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^
%.o: %.c
	$(CC) $(CPPFLAGS) $(CFLAGS) -c $^

clean: ; $(RM) *.o
distclean: clean ; $(RM) allegro.log nibbles$(EXE_SUFFIX) fractal$(EXE_SUFFIX) intro$(EXE_SUFFIX) $(SH_EXE)
