#CFLAGS = `sdl-config --cflags` -g -Wall -Werror
OPTIMIZATIONS = -O2 -march=i686
CFLAGS = `sdl-config --cflags` -I./ -IInterface -IStarCraft -IGame $(OPTIMIZATIONS)
#CFLAGS = `sdl-config --cflags` -I./ -IInterface -IStarCraft -IGame -g
LIBS = `sdl-config --libs` -lSDL_mixer
OBJFILES = \
SDL_rotozoom.o \
StarCraft/blizzard/decryption/sub_42AE90.o \
StarCraft/blizzard/decryption/sub_44E420.o \
StarCraft/blizzard/decryption/sub_44E4A0.o \
StarCraft/blizzard/decryption/sub_44E550.o \
StarCraft/blizzard/decryption/sub_44E780.o \
StarCraft/blizzard/decryption/sub_44E8D0.o \
StarCraft/blizzard/decryption/sub_4816B0.o \
StarCraft/blizzard/decryption/sub_4818C0.o \
StarCraft/blizzard/extract/Wav_unp.o \
StarCraft/blizzard/extract/explode.o \
StarCraft/blizzard/TBL.o \
StarCraft/blizzard/CV5.o \
StarCraft/blizzard/VF4.o \
StarCraft/blizzard/VX4.o \
StarCraft/blizzard/VR4.o \
StarCraft/blizzard/CHK.o \
StarCraft/blizzard/LO.o \
StarCraft/blizzard/Palette.o \
StarCraft/blizzard/MPQ_extract.o \
StarCraft/blizzard/MPQ.o \
StarCraft/SMK/BitStream.o \
StarCraft/SMK/BinaryTree.o \
StarCraft/SMK/HuffmanTree.o \
StarCraft/SMK/SMK.o \
StarCraft/DAT.o \
StarCraft/GRP.o \
StarCraft/PCX.o \
StarCraft/FNT.o \
StarCraft/Tileset.o \
StarCraft/Map.o \
StarCraft/Cursor.o \
StarCraft/StarCraft.o \
Interface/MapView.o \
Interface/MiniMap.o \
Interface/Portrait.o \
Interface/GameView.o \
Game/SpriteEngine.o \
Game/Sprite.o \
Game/Image.o \
Game/Image_run.o \
Game/IScript.o \
Game/IScript_run.o \
Game/Game.o \
Game/Unit.o \
Game/Selection.o \
FPSCounter.o \
main.o

TARGET = starlite

all: $(TARGET)

$(TARGET): $(OBJFILES)
	g++ -o $(TARGET) $(OBJFILES) $(LIBS)

SDL_rotozoom.o:
	g++ -o $@ -c SDL_rotozoom.c `sdl-config --cflags` $(OPTIMIZATIONS)

pklib/explode.o:
	g++ -o $@ -c pklib/explode.c $(CFLAGS)

%.o: %.c
	gcc -o $@ -c $< $(CFLAGS)

%.o: %.cpp
	g++ -o $@ -c $< $(CFLAGS)

clean:
	rm -f $(OBJFILES)
	rm -f $(TARGET) $(TARGET).exe

pack:
	make
	mv $(TARGET).exe _$(TARGET).exe
	make clean
	mv _$(TARGET).exe $(TARGET).exe
	strip $(TARGET).exe
	upx $(TARGET).exe
