# avoids problems with non-gnu makes
SHELL = /bin/sh

# suffix Definitions
.SUFFIXES:		# Delete the default suffixes
.SUFFIXES: .cpp .o .h	# Define our suffix list

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

CXX		= /usr/bin/g++
CC		= /usr/bin/gcc
RM		= /bin/rm -f
MV		= /bin/mv
ED		= /bin/ed
SYNC		= /bin/sync

# build specific variables
APPNAME = edisassm

DEFINES =       -DNDEBUG 
INCLUDES =	-I.
CXXFLAGS =	-g -O2 -W -Wall -ansi -pedantic $(INCLUDES) -pipe
LDFLAGS =	-Wl,-O1
VPATH = . 

H_FILES =	edisassm_exception.h edisassm_types.h edisassm_util.h Instruction.h ModRM.h Operand.h REX.h SIB.h
CXX_FILES =	edisassm.cpp  Instruction64.cpp
TCC_FILES =	Instruction.tcc Operand.tcc OPTable_1byte.tcc OPTable_2byte.tcc OPTable_3byte.tcc OPTable_FPU.tcc OPTable_Group10.tcc OPTable_Group11.tcc OPTable_Group12.tcc OPTable_Group13.tcc OPTable_Group14.tcc OPTable_Group15.tcc OPTable_Group16.tcc OPTable_Group17.tcc OPTable_Group1.tcc OPTable_Group2.tcc OPTable_Group3.tcc OPTable_Group4.tcc OPTable_Group5.tcc OPTable_Group6.tcc OPTable_Group7.tcc OPTable_Group8.tcc OPTable_Group9.tcc
O_FILES =	$(CXX_FILES:.cpp=.o)
SOURCEFILES =	$(H_FILES) $(CXX_FILES) $(TCC_FILES)
.PRECIOUS:	$(SOURCEFILES)

# main targets
all:	$(APPNAME)

$(APPNAME):	$(O_FILES)
	$(CXX) $(O_FILES) $(LDFLAGS) -o  $@

clean:
	$(RM) $(O_FILES) $(APPNAME) core *~  2> /dev/null

depend: $(CXX_FILES)
	@echo "Building Dependency Information..."
	@$(CXX) $(CXXFLAGS) $(DEFINES) -MM $? > makedep
	@echo '/^# DO NOT DELETE THIS LINE/+2,$$d' >eddep
	@echo '$$r makedep' >>eddep
	@echo 'w' >>eddep
	@$(ED) - Makefile < eddep
	@$(RM) eddep makedep 
	@echo '# DEPENDENCIES MUST END AT END OF FILE' >> Makefile
	@echo '# IF YOU PUT STUFF HERE IT WILL GO AWAY' >> Makefile
	@echo '# see make depend above' >> Makefile
	@echo "Done"
        
#-----------------------------------------------------------------
# DO NOT DELETE THIS LINE -- make depend uses it
#-----------------------------------------------------------------
edisassm.o: edisassm.cpp Instruction.h edisassm_types.h edisassm_util.h \
 edisassm_exception.h Operand.h Operand.tcc REX.h Instruction.tcc \
 OPTable_FPU.tcc OPTable_1byte.tcc OPTable_2byte.tcc OPTable_3byte.tcc \
 OPTable_Group1.tcc OPTable_Group2.tcc OPTable_Group3.tcc \
 OPTable_Group4.tcc OPTable_Group5.tcc OPTable_Group6.tcc \
 OPTable_Group7.tcc OPTable_Group8.tcc OPTable_Group9.tcc \
 OPTable_Group10.tcc OPTable_Group11.tcc OPTable_Group12.tcc \
 OPTable_Group13.tcc OPTable_Group14.tcc OPTable_Group15.tcc \
 OPTable_Group16.tcc OPTable_Group17.tcc ModRM.h SIB.h
Instruction64.o: Instruction64.cpp Instruction.h edisassm_types.h \
 edisassm_util.h edisassm_exception.h Operand.h Operand.tcc REX.h \
 Instruction.tcc OPTable_FPU.tcc OPTable_1byte.tcc OPTable_2byte.tcc \
 OPTable_3byte.tcc OPTable_Group1.tcc OPTable_Group2.tcc \
 OPTable_Group3.tcc OPTable_Group4.tcc OPTable_Group5.tcc \
 OPTable_Group6.tcc OPTable_Group7.tcc OPTable_Group8.tcc \
 OPTable_Group9.tcc OPTable_Group10.tcc OPTable_Group11.tcc \
 OPTable_Group12.tcc OPTable_Group13.tcc OPTable_Group14.tcc \
 OPTable_Group15.tcc OPTable_Group16.tcc OPTable_Group17.tcc ModRM.h \
 SIB.h
# DEPENDENCIES MUST END AT END OF FILE
# IF YOU PUT STUFF HERE IT WILL GO AWAY
# see make depend above
