# 
# This is the makefile for the Linux trace visualizer.
#
# Initial creation date : 3/1999 K.Y.
#
# 2000/08/22 K.Y., Modularized support for the GTK front-end and removed Makefile.nogtk
#                  since it wasn't needed anymore.
#

# Support
# If 1, will compile with graphic front-end
GTK_ENV   = 1
# If 1, will support RTAI (www.rtai.org) traces 
SUPP_RTAI = 1
# If 1, the visualizer will only support native traces
TARGET_NATIVE = 0
# If 1, visualizer will read structs as unpacked
LTT_UNPACKED_STRUCTS = 0

# Definitions
PREFIX      = /usr
EXEC_PREFIX = $(PREFIX)
CC          = gcc
DEBUG       = -g
DEFFLAGS    = -DGTK_ENV=$(GTK_ENV) -DSUPP_RTAI=$(SUPP_RTAI) -DTARGET_NATIVE=$(TARGET_NATIVE)
DEFFLAGS    += -DLTT_UNPACKED_STRUCTS=$(LTT_UNPACKED_STRUCTS)
INCLUDEDIRS = -I../Include
CFLAGS      = -O2 -Wall $(DEFFLAGS) $(DEBUG)
LFLAGS      = -lltt
DEPFILE     = .depend

# Files (note that the INCLUDES variable isn't used anywhere, it's there for reference's sake)
INCLUDES = TraceVisualizer.h LTTTypes.h LinuxEvents.h Tables.h LinuxTables.h EventDBI.h EventDB.h
OBJS = TraceVisualizer.o

ifeq ($(GTK_ENV),1)
INCLUDES += MainWindow.h OpenTrace.h ColorSelect.h EventGraph.h Pixmap.h ViewTime.h GotoEvent.h DumpToFile.h
OBJS     += MainWindow.o OpenTrace.o ColorSelect.o EventGraph.o Pixmap.o ViewTime.o GotoEvent.o DumpToFile.o
CFLAGS   += `gtk-config --cflags`
LFLAGS   += `gtk-config --libs`
endif

ifeq ($(SUPP_RTAI),1)
INCLUDES += RTAIEvents.h RTAITables.h RTAIDB.h
endif

# Installation variables
EXEC_NAME    = tracevisualizer
SCRIPT_DIR   = ./Scripts
INSTALL_DIR  = $(EXEC_PREFIX)/sbin
INSTALL      = install

# Rules
all: TraceVisualizer

.depend:
	@echo "Building dependencies"
	rm -rf .depend
	touch .depend
	makedepend -f .depend $(DEFFLAGS) $(INCLUDEDIRS) *.c
	@echo "Dependencies built"

depend dep: .depend

.c.o:
	$(CC) $(CFLAGS) $(INCLUDEDIRS) -c $<

TraceVisualizer: ${OBJS}
	$(CC) -o $(EXEC_NAME) ${OBJS} $(LFLAGS)

install: TraceVisualizer
	test -d $(INSTALL_DIR) || $(INSTALL) -d -m 755 $(INSTALL_DIR)
	$(INSTALL) -m 755 $(EXEC_NAME) $(INSTALL_DIR)
	$(INSTALL) -m 755 $(SCRIPT_DIR)/* $(INSTALL_DIR)

clean: 
	rm -rf *.o tracevisualizer core

distclean:
	rm -rf *~
	rm -rf .depend .depend.bak
	rm -rf *.o tracevisualizer core

-include .depend
