# LIBDISASM MAKEFILE
#

# ============================================================================
# DEFINES

VERSION = 0.21
DEST	= /usr/local	# install root
DEBUG	= -ggdb -DDEBUG

CC	= gcc
LD	= gcc
AR	= ar
RANLIB	= ranlib

RM	= rm -rf
CP	= cp -r
MKDIR	= mkdir -p
TAR	= tar

X86DIS	= x86dis/x86dis
TESTDIS	= test/testdis
QUIKDIS	= test/quikdis
LIBDIS  = libdisasm/libdisasm.so
LIBDISA = libdisasm/libdisasm.a
DOC	= doc/libdisasm.txt doc/README.TXT

TOP	= $(PWD)
DISTRIB = $(TOP)/distrib
INSTALL = /usr/local
INSTALL_BIN	= $(INSTALL)/bin
INSTALL_LIB	= $(INSTALL)/lib
INSTALL_INC	= $(INSTALL)/include
INSTALL_MAN	= $(INSTALL)/man
INSTALL_SHARE	= $(INSTALL)/share/libdisasm
export TOP DISTRIB INSTALL
export INSTALL_BIN INSTALL_LIB INSTALL_INC INSTALL_MAN INSTALL_SHARE



# ============================================================================
# EXPORTS

export VERSION DEBUG
export CC LD AR RANLIB


# ============================================================================
# TARGETS

all: $(LIBDIS)
dummy: x86dis libdisasm test dist swig-modules install clean

# ------------------------------------------------------- LIBDIS
libdisasm: $(LIBDIS)
$(LIBDIS): 
	cd libdisasm && gmake

# ------------------------------------------------------- X86DIS
x86dis: $(X86DIS)

$(X86DIS): 
	cd x86dis && gmake

x86dis-clean:
	cd x86dis && gmake clean

# ------------------------------------------------------- TEST
test: $(TESTDIS) $(QUIKDIS)

$(TESTDIS):
	cd test && gmake

$(QUIKDIS):
	cd test && gmake

# ------------------------------------------------------- SWIG
swig-modules: $(LIBDIS)
	#cd swig && gmake 

# ------------------------------------------------------- CLEAN
clean:
	cd libdisasm && gmake clean
	cd x86dis && gmake clean
	cd test && gmake clean
	cd swig && gmake clean

# ------------------------------------------------------- INSTALL
install: $(LIBDIS)
#swig-install
	# install bindistrib files to INSTALL_LOC
	cd libdisasm && gmake install
	#cd x86dis && gmake install
	#cd man && gmake install
	#cd doc && gmake install
	#cd perl && gmake install
	#cd swig && gmake install

uninstall:
	cd libdisasm && gmake uninstall
	cd x86dis && gmake uninstall
	cd man && gmake uninstall
	cd doc && gmake uninstall
	cd perl && gmake uninstall
	cd swig && gmake uninstall


# ------------------------------------------------------- DISTRIB
dist: $(LIBDIS) $(X86DIS)
	cd libdisasm && gmake dist
	cd x86dis && gmake dist
	cd man && gmake dist
	cd doc && gmake dist
	cd perl && gmake dist
	cd test && gmake dist
	# handle swig modules
	cd swig && gmake dist || true
	# copy Makefile and License
	cp Makefile distrib/src/libdisasm-$(VERSION)/Makefile
	cp LICENSE distrib/src/libdisasm-$(VERSION)/LICENSE
	cp LICENSE distrib/tgz/usr/local/share/libdisasm/doc/LICENSE
	cp LICENSE distrib/deb/libdisasm/usr/local/share/libdisasm/doc/LICENSE
	cp LICENSE \
	   distrib/deb/libdisasm-dev/usr/local/share/libdisasm/doc/LICENSE
	#cp LICENSE distrib/rpm/libdisasm/usr/local/share/libdisasm/doc/LICENSE
	cd distrib && gmake dist


syntax highlighted by Code2HTML, v. 0.9.1