#
#
# Makefile for g2 library
#
#

#
# g2 installation directories
#
LIBDIR = @prefix@/lib
INCDIR = @prefix@/include

#LIBDIR = $(HOME)/local/lib
#INCDIR = $(HOME)/local/include

#
#------------------------ do not edit ------------------------
#
SHELL = /bin/sh

CC           = @CC@
CFLAGS       = -I./src @CFLAGS@ @DEFS@
INSTALL      = @INSTALL@
INSTALL_DATA = @INSTALL_DATA@
FIND         = @FIND@
MAKEDEPEND   = @MAKEDEPEND@
AR           = ar
ARFLAGS      = -rs

BASE_DIR = ./src
BASE_SRC = $(BASE_DIR)/g2_device.c         $(BASE_DIR)/g2_ui_control.c \
           $(BASE_DIR)/g2_util.c           $(BASE_DIR)/g2_fif.c \
           $(BASE_DIR)/g2_virtual_device.c $(BASE_DIR)/g2_physical_device.c \
           $(BASE_DIR)/g2_graphic_pd.c     $(BASE_DIR)/g2_control_pd.c \
           $(BASE_DIR)/g2_ui_graphic.c     $(BASE_DIR)/g2_ui_virtual_device.c \
           $(BASE_DIR)/g2_ui_device.c
BASE_INS = $(BASE_DIR)/g2.h


@DO_PS@PS_DIR = ./src/PS
@DO_PS@PS_SRC = $(PS_DIR)/g2_PS.c
@DO_PS@PS_INS = $(PS_DIR)/g2_PS.h


@DO_X11@X11_DIR = ./src/X11
@DO_X11@X11_SRC = $(X11_DIR)/g2_X11.c
@DO_X11@X11_INS = $(X11_DIR)/g2_X11.h


@DO_GIF@GIF_DIR = ./src/GIF
@DO_GIF@GIF_SRC = $(GIF_DIR)/g2_GIF.c
@DO_GIF@GIF_INS = $(GIF_DIR)/g2_GIF.h


SRC = $(BASE_SRC) $(PS_SRC) $(X11_SRC) $(GIF_SRC)
OBJ = $(SRC:.c=.o)

INS =  $(BASE_INS) $(PS_INS) $(X11_INS) $(GIF_INS)

.c.o:  
	$(CC) $(CFLAGS) -c $< -o $@


all: libg2.a
	test -d ./include || mkdir ./include
	cp $(INS) ./include/

shared: libg2.so
	@echo

libg2.a: $(OBJ)
	$(AR) $(ARFLAGS) libg2.a $(OBJ)
	ln -s libg2.a libg2.0.40.a

libg2.so: $(OBJ)
	$(CC) -shared -o libg2.so $(OBJ) -lc -lm

install: libg2.a
	test -d $(LIBDIR) || mkdir -p $(LIBDIR)
	test -d $(INCDIR) || mkdir -p $(INCDIR)
	$(INSTALL_DATA) libg2.a $(LIBDIR)
	for IFILE in $(INS); do \
		$(INSTALL_DATA) $$IFILE  $(INCDIR); \
	done

clean:
	-(cd ./demo ; make clean)
	-rm -f $(OBJ)
	-rm -f libg2.a config.cache config.log Makefile.bak config.status
	-rm -f ./include/*.h
	-$(FIND) . -name "*~" -exec rm -f {} \;
	-(cd ./g2_perl ; make clean)
	-rm -f ./g2_perl/test.ps ./g2_perl/test.gif
	-rm -f ./libg2.0.40.a

demo:	libg2.a
	(cd ./demo ; make)

depend:
	$(MAKEDEPEND) -- $(CFLAGS) -- $(SRC)
	@echo
	@echo "Run 'make' to build g2 library."
	@echo


# DO NOT DELETE THIS LINE -- make  depend  depends  on it.

