# Makefile for the DND Xt library
#
# Cesar Crusius - 1996

CC = @CC@
CFLAGS = -I. @CFLAGS@ @X_CFLAGS@

CXX = @CXX@
CXXFLAGS = -I. @CXXFLAGS@ @X_CFLAGS@

LDFLAGS = @LDFLAGS@

RANLIB = @RANLIB@

LIBS = @LIBS@@X_LIBS@ @X_PRE_LIBS@ -lXmu -lXaw -lXt -lX11 @X_EXTRA_LIBS@

DYN_FLAGS = -fPIC

prefix = @prefix@
exec_prefix = @exec_prefix@
LIB_DIR = @libdir@
INC_DIR = @includedir@/OffiX

LINK = $(CC) $(LDFLAGS) -o $@

default: all

all: libC libCpp dndtest

%.lo: %.c
	${CC} ${DYN_FLAGS} ${CFLAGS} -o $@ -c $<

%.o: %.c
	${CC} ${CFLAGS} -o $@ -c $<

%.lo: %.cxx
	${CXX} ${DYN_FLAGS} ${CXXFLAGS} -o $@ -c $<

%.o: %.cxx
	${CXX} ${CXXFLAGS} -o $@ -c $<

install: libCpp libC
	install -d $(INC_DIR)
	install DragAndDrop.h DragAndDropTypes.h $(INC_DIR)
	install -d $(LIB_DIR)
	install libDnd.a libDnd++.a $(LIB_DIR)

libC: libDnd.a libDnd.so.${VERSION}

libCpp: libDnd++.a libDnd++.so.${VERSION}

dndtest: dndtest.o libDnd.a
	rm -f dndtest
	$(LINK) dndtest.o -L. -lDnd $(LIBS)

dndtest.o: dndtest.c

libDnd.a: DragAndDrop.o
	rm -f libDnd.a
	$(AR) cru libDnd.a DragAndDrop.o
	$(RANLIB) libDnd.a

DragAndDrop.o: DragAndDrop.c

libDnd.so.${VERSION}: DragAndDrop.lo
	$(CC) -shared -Wl,-soname,libDnd.so.$(MAJOR) -o libDnd.so.$(VERSION)\
		DragAndDrop.lo

DragAndDrop.lo: DragAndDrop.c

libDnd++.a: DragAndDropCxx.o
	rm -f libDnd++.a
	$(AR) cru libDnd++.a DragAndDropCxx.o
	$(RANLIB) libDnd++.a

DragAndDropCxx.o: DragAndDropCxx.cxx

DragAndDropCxx.lo: DragAndDropCxx.cxx

DragAndDropCxx.cxx: DragAndDrop.c
	ln -s DragAndDrop.c DragAndDropCxx.cxx

libDnd++.so.${VERSION}: DragAndDropCxx.lo
	$(CXX) -shared -Wl,-soname,libDnd++.so.$(MAJOR) -o libDnd++.so.$(VERSION)\
		DragAndDropCxx.lo

clean:
	rm -f *.o *.lo *.cxx *.a dndtest *~ *bak *.so.* config.status config.cache

