PREFIX ?= /mnt/utmp/bubbletrain
DATA_DIR ?= $(PREFIX)/share/games/bubbletrain

MODE = 

LDFLAGS = $(shell sdl-config --libs) -lSDL_mixer -lSDL_image $(shell xml2-config --libs)
CXXFLAGS = -DPANDORA -DHAVE_GLES -O3 -pipe -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize -ffast-math -fsingle-precision-constant -fsigned-char -Wall $(shell sdl-config --cflags) -ffast-math $(MODE) $(shell xml2-config --cflags)
CXX = arm-angstrom-linux-gnueabi-g++

PRG = bubbletrain

SRCS = \
  src/AboutUs.cpp \
  src/Bubble.cpp \
  src/BubbleTrainWorld.cpp \
  src/Bullet.cpp \
  src/BulletFactory.cpp \
  src/Button.cpp \
  src/Cannon.cpp \
  src/Carriage.cpp \
  src/CarriageFactory.cpp \
  src/CheckBox.cpp \
  src/Control.cpp \
  src/ExplodingBubble.cpp \
  src/FastestTime.cpp \
  src/FastestTimeScreen.cpp \
  src/FastestTimeText.cpp \
  src/FileLoadSaveBox.cpp \
  src/Font.cpp \
  src/Game.cpp \
  src/GameEnd.cpp \
  src/GameSelect.cpp \
  src/General.cpp \
  src/Label.cpp \
  src/Level.cpp \
  src/LevelEditor.cpp \
  src/LevelTimer.cpp \
  src/ListBox.cpp \
  src/Log.cpp \
  src/MainMenu.cpp \
  src/MessageBox.cpp \
  src/Options.cpp \
  src/OptionsScreen.cpp \
  src/Slider.cpp \
  src/SplashScreen.cpp \
  src/TextBox.cpp \
  src/TextExplodingBubble.cpp \
  src/Theme.cpp \
  src/Track.cpp \
  src/TrackArc.cpp \
  src/TrackLine.cpp \
  src/TrackSpiral.cpp \
  src/Train.cpp \
  src/TrainStation.cpp \
  src/Window.cpp \
  src/WindowManager.cpp \
  src/XDGPath.cpp

OBJS = $(SRCS:.cpp=.o)

@echo "OBJS=" $OBJS

all: $(PRG)

$(PRG): $(OBJS)
	$(CXX) $(CXXFLAGS) -o $(PRG) $(OBJS) $(LDFLAGS)

.SUFFIXES: .cpp .o

.cpp.o:
	$(CXX) -c -DDATA_DIR=\"$(DATA_DIR)\" $(CXXFLAGS) -o $@ $<

clean:
	rm -f src/*.o $(PRG)

install:
	install -d "$(DESTDIR)$(DATA_DIR)"
	cp -a gfx snd themes levels doc "$(DESTDIR)$(DATA_DIR)"
	install -d "$(DESTDIR)$(PREFIX)/games"
	install $(PRG) "$(DESTDIR)$(PREFIX)/games"
