#!/usr/local/bin/gmake

# targets:
#    program|$(TARGET): build the program
#    doc: builds the documentation
#    all: builds program and doc
#    clean: removes cruft (does *not* remove $(TARGET) or docs
#    distclean: removes everything this Makefile builds plus backup files
#    tardist: builds a tarball in .. named $USER

# The name of the application binary
TARGET := ./miniQTcyg

# Modifications beyond this point are unlikely required unless a) you
# actually know what you are doing and b) you are customizing this
# Makefile for a new environment.

SHELL := /bin/sh

OS := Linux

# set compiler flags up

# --- Linux ---
ifeq ($(OS),Linux)
  CXX      := gcc
  CXXFLAGS := -g -Wall -DQT_CLEAN_NAMESPACE
  LDFLAGS  :=
  CPPFLAGS := 
  QT_LIBS  := 
  GL_LIBS  := -lopengl32 -lglut32 -lglu32 -lstdc++
  X11_LIBS := 
  SYS_LIBS := 
  DOXYGEN  := doxygen
endif

MOC        := 

CPPFLAGS   += 
LDLIBS     := $(GL_LIBS) $(X11_LIBS) $(SYS_LIBS)

# Fetch all source files
SOURCES    := $(wildcard *.cpp)
HEADERS    := $(wildcard *.h)

OBJECTS    := $(SOURCES:.cpp=.o)
OBJ        := $(OBJECTS)

program: $(TARGET)

all: program doc

$(TARGET): $(OBJ)
	$(CXX) -o $@ $(LDFLAGS) $^ $(LDLIBS)

doc: doxygen.conf $(wildcard *.h)
	$(DOXYGEN) doxygen.conf

clean:
	$(RM) -r $(OBJECTS) $(MOCOBJS) $(MOCSRCS) ii_files

distclean: clean
	$(RM) -r $(TARGET) doc
	$(RM) -r *~ Makedepend

%.o: %.cpp
	$(CXX) -c $(CPPFLAGS) $(CXXFLAGS) $<

Makedepend: $(SOURCES) $(HEADERS) 
	$(CXX) -M $(CPPFLAGS) $(SOURCES) > $@

include Makedepend

.PHONY: clean distclean program tardist
