#==============================================================================
# Project:	A Tiny DBMS (Exercise for Course "DBMS-Implementation")
# Filename:	Makefile
# Purpose:	Makefile
# Last Change:	28.01.2012
# Language:	make
# Author:	Stefan Brass
# EMail:	brass@informatik.uni-halle.de
# WWW:		http://www.informatik.uni-halle.de/~brass/
# Address:	Feldschloesschen 15, D-06120 Halle (Saale), GERMANY
# Copyright:	(c) 1995-2012 by Stefan Brass
# Note:		There is no warranty at all - this code may contain bugs.
#==============================================================================


# 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 3 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, see <http://www.gnu.org/licenses/>.


#==============================================================================
# Compiler with Options:
#==============================================================================

CXX      = g++

CXXFLAGS = -Wall -Wextra -Wshadow -Wpointer-arith -Wcast-qual -Wcast-align \
	-Wunreachable-code -pedantic -ggdb

INCPATH  =

#==============================================================================
# Linker with Options:
#==============================================================================

LINK     = g++
LFLAGS   = 
LIBS     = 

#==============================================================================
# Which make depend:
#==============================================================================

MAKEDEP = ./makedep "$(CXX) -M $(CXXFLAGS) $(INCPATH)"

#==============================================================================
# Other Commands:
#==============================================================================

DEL_FILE = rm -f

#==============================================================================
# Files:
#==============================================================================

HEADERS = \
	ver.h \
	str.h \
	check.h \
	bno.h \
	boff.h \
	btype.h \
	block.h

SOURCES = \
	str.cpp \
	check.cpp \
	block.cpp \
	main.cpp

OBJECTS = \
	str.o \
	check.o \
	block.o \
	main.o

MAKEFILE = Makefile

TARGET	= sbdb

DOC	= DOC

DOC_INCLUDE =

#==============================================================================
# Default Target:
#==============================================================================

default_target: $(TARGET)

#==============================================================================
# Implicit Rules:
#==============================================================================

.SUFFIXES: .o .cpp

.cpp.o:
	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
	@echo

#==============================================================================
# Main Build Rules:
#==============================================================================

$(TARGET):  $(OBJECTS)
	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(LIBS)
	@echo

#==============================================================================
# Other Commands for the Software:
#==============================================================================

run:
	./$(TARGET)

clean: clean_doc
	-$(DEL_FILE) $(OBJECTS)
	-$(DEL_FILE) *~ core *.core
	-$(DEL_FILE) alert
	-$(DEL_FILE) testfile
	-$(DEL_FILE) datafile

depend:
	$(MAKEDEP) $(MAKEFILE) $(SOURCES)

#==============================================================================
# Run LaTeX to Make Documentation:
#==============================================================================

doc: $(DOC).dvi

$(DOC).dvi: $(DOC).tex $(DOC_INCLUDE)
	latex $(DOC).tex

again: $(DOC).tex $(DOC_INCLUDE)
	latex $(DOC).tex

clean_doc:
	-$(DEL_FILE) $(DOC).log

#==============================================================================
# Preview DVI-File of Documentation:
#==============================================================================

view: $(DOC).dvi
	xdvi -geometry +810+34 -s 8 -S 20  -paper a4 $(DOC).dvi

#==============================================================================
# Create Postscript File:
#==============================================================================

ps: $(DOC).ps

$(DOC).ps: $(DOC).dvi
	dvips -o $(DOC).ps $(DOC).dvi

half: $(DOC)_2.ps

$(DOC)_2.ps: $(DOC).ps
	psnup -2 $(DOC).ps > $(DOC)_2.ps

quad: $(DOC)_4.ps

$(DOC)_4.ps: $(DOC).ps
	psnup -4 -m10 $(DOC).ps > $(DOC)_4.ps


#==============================================================================
# Create PDF File of the Documentation:
#==============================================================================

pdf: $(DOC).pdf

$(DOC).pdf: $(DOC).tex $(DOC_INCLUDE)
	pdflatex $(DOC).tex

#==============================================================================
# Dependencies:
#==============================================================================

# Begin of dependencies. DO NOT DELETE THIS LINE -- make depend depends on it.
str.o: str.cpp ver.h str.h
check.o: check.cpp ver.h check.h str.h
block.o: block.cpp ver.h check.h str.h btype.h block.h bno.h boff.h
main.o: main.cpp ver.h str.h boff.h block.h check.h bno.h btype.h
# End of dependencies. DO NOT DELETE THIS LINE -- make depend depends on it.


