# makefile.gcc --
#
# Generic Makefile for building e4XML on UNIX with G++.
#
# NOTE: This Makefile was tested on Solaris 2.6, Solari 7 and Linux 2.x.
#	You may have to edit this Makefile to adapt it to your OS and
#	configuration.
#
# Author: Jacob Levy, jyl@best.com

# What C++ compiler to use:

CC = gcc

# Where to find the e4tree.h include file:

E4INCLUDE = ../../include

# Where to find the Expat include files:

EXPATINCLUDE = ../../../expat/xmlparse

# Where is our own include file:

E4XMLINCLUDE = ../include

# All the includes:

INCLUDES = -I$(E4INCLUDE) -I$(EXPATINCLUDE) -I$(E4XMLINCLUDE)

# Where is our source code:

SOURCES = ../src

# The source files:

SRC = \
	$(SOURCES)/e4xmlparser.cpp

# Object files we produce:

OBJECTS = ./objects

OBJ = \
	$(OBJECTS)/e4xmlparser.o

# What flags to pass to the C++ compiler:

DEFINES = -DPIC
OPTIM = -O2
MISCFLAGS = -fPIC

CCFLAGS = $(DEFINES) $(OPTIM) $(INCLUDES) $(MISCFLAGS)

# Link related flags:

LIBS = -L. -R. -L../../unix -R../../unix -L../../../expat -R../../../expat

###########################################################################
# Main target:
###########################################################################

all: libe4xml.so

test: libe4xml.so $(OBJECTS)/test.o
	$(CC) $(CCFLAGS) -o test $(OBJECTS)/test.o \
	      $(LIBS) -lexpat -le4tree -lmk4 -le4xml

libe4xml.so: $(OBJECTS) $(OBJ)
	$(CC) $(CCFLAGS) -shared -o libe4xml.so $(OBJ)

$(OBJECTS):
	mkdir -p $(OBJECTS)

$(OBJECTS)/e4xmlparser.o: $(SOURCES)/e4xmlparser.cpp \
			  $(E4XMLINCLUDE)/e4xmlparser.h
	$(CC) $(CCFLAGS) -c $(SOURCES)/e4xmlparser.cpp \
			 -o $(OBJECTS)/e4xmlparser.o

$(OBJECTS)/test.o: $(SOURCES)/test.cpp  $(E4XMLINCLUDE)/e4xmlparser.h
	$(CC) $(CCFLAGS) -c $(SOURCES)/test.cpp \
			 -o $(OBJECTS)/test.o
