# Simple Makefile for Highlight
# This file will compile the highlight binary.
# See INSTALL for instructions. 

CC=c++

# Add -DCUSTOM_INSTALL_DIR=\"/your/path/\" to CFLAGS if you want to define a custom 
# installation directory not listed in INSTALL. Copy ./langDefs/extensions.conf to /your/path/.

ifeq ($(DISABLE_GETOPT),true)
	CFLAGS=-O3 -Wall -pedantic -DUSE_PORTABLE_CMDLINE_PARSER 
else
	CFLAGS=-O3 -Wall -pedantic -fno-exceptions
endif

LDFLAGS=-L/usr/lib -s 

GCC_COMPILE = ${CC} ${CFLAGS} -c 
GCC_LINK = ${CC} ${LDFLAGS} ${CFLAGS} -o highlight ${OBJECTFILES}

OBJECTFILES := configurationreader.o texcode.o \
	stylecolour.o stringtools.o rtfcode.o main.o latexcode.o \
	languagedefinition.o htmlcode.o xslfocode.o help.o elementstyle.o \
	documentstyle.o directoryreader.o datadir.o codeparser.o \
	cmdlineoptions.o linewrapper.o ASStreamIterator.o ASResource.o \
	ASFormatter.o ASBeautifier.o

ifeq ($(DISABLE_GETOPT),true)
	OBJECTFILES:=${OBJECTFILES} win32cmdline.o
endif

highlight: ${OBJECTFILES}
	${GCC_LINK}

ASBeautifier.o: ASBeautifier.cpp compiler_defines.h ASBeautifier.h \
  ASResource.h ASStreamIterator.h ASSourceIterator.h
	${GCC_COMPILE} ASBeautifier.cpp

ASFormatter.o: ASFormatter.cpp compiler_defines.h ASFormatter.h \
  ASBeautifier.h ASResource.h ASStreamIterator.h ASSourceIterator.h \
  enums.h
	${GCC_COMPILE} ASFormatter.cpp

ASResource.o: ASResource.cpp compiler_defines.h ASResource.h \
  ASStreamIterator.h ASSourceIterator.h
	${GCC_COMPILE} ASResource.cpp

ASStreamIterator.o: ASStreamIterator.cpp compiler_defines.h \
  ASStreamIterator.h ASSourceIterator.h
	${GCC_COMPILE} ASStreamIterator.cpp

cmdlineoptions.o: cmdlineoptions.cpp cmdlineoptions.h stringtools.h \
  configurationreader.h datadir.h directoryreader.h enums.h
	${GCC_COMPILE} cmdlineoptions.cpp

codeparser.o: codeparser.cpp codeparser.h languagedefinition.h \
  configurationreader.h stringtools.h enums.h documentstyle.h \
  elementstyle.h stylecolour.h ASFormatter.h ASBeautifier.h ASResource.h \
  compiler_defines.h ASStreamIterator.h ASSourceIterator.h linewrapper.h
	${GCC_COMPILE} codeparser.cpp

configurationreader.o: configurationreader.cpp configurationreader.h \
  stringtools.h
	${GCC_COMPILE} configurationreader.cpp

datadir.o: datadir.cpp datadir.h stringtools.h
	${GCC_COMPILE} datadir.cpp

directoryreader.o: directoryreader.cpp dirstream.h dirstreamimpl.inl \
  directoryreader.h
	${GCC_COMPILE} directoryreader.cpp

documentstyle.o: documentstyle.cpp documentstyle.h configurationreader.h \
  stringtools.h elementstyle.h stylecolour.h
	${GCC_COMPILE} documentstyle.cpp

elementstyle.o: elementstyle.cpp elementstyle.h stylecolour.h
	${GCC_COMPILE} elementstyle.cpp

help.o: help.cpp help.h
	${GCC_COMPILE} help.cpp

htmlcode.o: htmlcode.cpp htmlcode.h version.h charcodes.h stylecolour.h \
  elementstyle.h stringtools.h codeparser.h languagedefinition.h \
  configurationreader.h enums.h documentstyle.h ASFormatter.h \
  ASBeautifier.h ASResource.h compiler_defines.h ASStreamIterator.h \
  ASSourceIterator.h linewrapper.h
	${GCC_COMPILE} htmlcode.cpp

languagedefinition.o: languagedefinition.cpp languagedefinition.h \
  configurationreader.h stringtools.h enums.h
	${GCC_COMPILE} languagedefinition.cpp

latexcode.o: latexcode.cpp latexcode.h codeparser.h languagedefinition.h \
  configurationreader.h stringtools.h enums.h documentstyle.h \
  elementstyle.h stylecolour.h ASFormatter.h ASBeautifier.h ASResource.h \
  compiler_defines.h ASStreamIterator.h ASSourceIterator.h linewrapper.h \
  version.h charcodes.h
	${GCC_COMPILE} latexcode.cpp

linewrapper.o: linewrapper.cpp linewrapper.h stringtools.h
	${GCC_COMPILE} linewrapper.cpp

main.o: main.cpp main.h cmdlineoptions.h stringtools.h \
  configurationreader.h datadir.h directoryreader.h enums.h \
  languagedefinition.h htmlcode.h version.h charcodes.h stylecolour.h \
  elementstyle.h codeparser.h documentstyle.h ASFormatter.h \
  ASBeautifier.h ASResource.h compiler_defines.h ASStreamIterator.h \
  ASSourceIterator.h linewrapper.h rtfcode.h latexcode.h texcode.h \
  xslfocode.h help.h
	${GCC_COMPILE} main.cpp

rtfcode.o: rtfcode.cpp rtfcode.h codeparser.h languagedefinition.h \
  configurationreader.h stringtools.h enums.h documentstyle.h \
  elementstyle.h stylecolour.h ASFormatter.h ASBeautifier.h ASResource.h \
  compiler_defines.h ASStreamIterator.h ASSourceIterator.h linewrapper.h \
  charcodes.h version.h
	${GCC_COMPILE} rtfcode.cpp

stringtools.o: stringtools.cpp stringtools.h
	${GCC_COMPILE} stringtools.cpp

stylecolour.o: stylecolour.cpp stylecolour.h
	${GCC_COMPILE} stylecolour.cpp

texcode.o: texcode.cpp texcode.h charcodes.h version.h codeparser.h \
  languagedefinition.h configurationreader.h stringtools.h enums.h \
  documentstyle.h elementstyle.h stylecolour.h ASFormatter.h \
  ASBeautifier.h ASResource.h compiler_defines.h ASStreamIterator.h \
  ASSourceIterator.h linewrapper.h
	${GCC_COMPILE} texcode.cpp

win32cmdline.o: win32cmdline.cpp win32cmdline.h includeme.h
	${GCC_COMPILE} win32cmdline.cpp

xslfocode.o: xslfocode.cpp xslfocode.h codeparser.h languagedefinition.h \
  configurationreader.h stringtools.h enums.h documentstyle.h \
  elementstyle.h stylecolour.h ASFormatter.h ASBeautifier.h ASResource.h \
  compiler_defines.h ASStreamIterator.h ASSourceIterator.h linewrapper.h \
  version.h
	${GCC_COMPILE} xslfocode.cpp


clean: 
	@rm -f *.o
	@rm -f highlight
	@rm -f ./.deps/*
	#@rmdir ./.deps
