Newer
Older
cg / Makefile
@glproj03 glproj03 on 3 Feb 2006 1 KB glumodel to its own file - working
PROGNAME := cg

SRCDIR := sources
INCLUDEDIR := include
BINDIR := bin

DEBUG := yes

VPATH = $(SRCDIR) $(INCLUDEDIR)

vpath %.cpp $(SRCDIR)
vpath %.h $(INCLUDEDIR)

ifdef COMSPEC
# windows
	CXX := g++
	CXXFLAGS := -Wall -I$(INCLUDEDIR) -Ic:/SDL/include
	LIBS := -Lc:/SDL/lib -lmingw32 -lSDLmain -lopengl32 -lglu32 -mwindows  
	EXESUFFIX := .exe
	POSTLIBS := -lSDL -lopengl32 -lglu32

	MKDIR := mkdir -p
	ECHO := echo
	RM := rm
else
# better than windows
	CXX := g++
	CXXFLAGS := -DUNIX -Wall `sdl-config --cflags` -I $(INCLUDEDIR)
	LIBS := `sdl-config --libs` -lGL -lGLU
	EXESUFFIX := 
	POSTLIBS :=

	RM := rm -f
	ECHO := echo
	MKDIR := mkdir -p
endif

ifeq "$(DEBUG)" "yes"
	CXXFLAGS := $(CXXFLAGS) -g -DDEBUG
endif

OBJECTS = main.o poly.o model.o glumodel.o light.o vec.o material.o color.o thing.o animation.o

all: $(OBJECTS)
	@if [ ! -d $(BINDIR) ]; then \
		$(call run,$(MKDIR) $(BINDIR)); \
	fi
	$(CXX) $(CXXFLAGS) $(LIBS) $^ -o $(BINDIR)/$(PROGNAME)$(EXESUFFIX) $(POSTLIBS)
run:
	$(BINDIR)/$(PROGNAME)$(EXESUFFIX)
clean:
	$(RM) *.o
distclean: clean
	$(RM) $(BINDIR)/$(PROGNAME)$(EXESUFFIX)

.PHONY: all
.PHONY: clean
.PHONY: distclean

run = $(ECHO) $(1); $(1) || exit $$?