
PROGS= asview asscale astile asmerge asgrad asflip asi18n astext ascompose asvector


CC		= @CC@
CCFLAGS         = @CFLAGS@
# -march=pentiumpro -mcpu=pentiumpro
EXTRA_DEFINES	= @DEFINE_XLOCALE@

RANLIB		= @RANLIB@
AR		= ar clq
CP		= @CP@
MV		= @MV@
RM		= @RM@
RMF		= @RM@ -f
MKDIR		= @MKDIR@
FIND		= @FIND@
XARGS		= @XARGS@
LDCONFIG	= @LDCONFIG@

INSTALL		= @INSTALL@
INSTALL_PROGRAM	= @INSTALL@ -m 755
INSTALL_DATA	= @INSTALL@ -m 644

INCS_X		= @X_CFLAGS@
INCS_PRIVATE    = 
INCLUDES	= $(INCS_X) $(INCS_PRIVATE)

USER_LD_FLAGS	= @user_ldflags@
LIBS_X		= @x_libs@
LIBS_XEXTS	=
LIBS_AFTERIMAGE = @AFTERIMAGE_APPS_LIBS@
LIBRARIES	= $(USER_LD_FLAGS) $(LIBS_AFTERIMAGE) $(LIBS_X) $(LIBS_XEXTS)

prefix          = @prefix@
exec_prefix     = @exec_prefix@
LIBDIR		= $(DESTDIR)@libdir@
BIN_DIR		= $(DESTDIR)@bindir@
MAN_DIR		= $(DESTDIR)@mandir@/man1
AFTER_DIR	= @with_afterdir@

# need this for dependancies :
LIBAFTERIMAGE_PATH = ../../libAfterImage
LIB_STATIC      = $(LIBAFTERIMAGE_PATH)/libAfterImage.a
LIB_SHARED      = $(LIBAFTERIMAGE_PATH)/libAfterImage.so


all:    $(PROGS)

install.bin:	$(PROGS)
		@for p in $(PROGS); do \
	  		$(INSTALL_PROGRAM) $$p $(BIN_DIR) ; \
		done

install.man:
		@for f in *.man; do \
		  echo $(INSTALL_DATA) $$f $(MAN_DIR)/`basename $$f`.1x; \
		  $(INSTALL_DATA) $$f $(MAN_DIR)/`basename $$f`.1x; \
		done

uninstall.bin:
		$(RMF) $(AFTER_BIN_DIR)/$(PROGS)

uninstall.man:
		$(RMF) $(AFTER_MAN_DIR)/$(PROGS).1x

clean:
		$(RMF) $(PROGS) *.o *~ *% *.bak \#* core

distclean:
		$(RMF) $(PROGS) *.o *~ *% *.bak \#* *.orig core Makefile

indent:
		@SRCS=`find . -name "*.c"`; \
		if test "x$$SRCS" == "x"; then exit; fi; \
		for i in $$SRCS; do \
		  if (indent -di14 -ts4 -i4 -l100 -lc80 -bad -nbbb -bli0 -c48 -cd48 -ce -cli1 -ncs -nbs -nbbo -hnl < $$i > /tmp/$$i); then \
		    echo "indent $$i"; \
		    mv /tmp/$$i $$i; \
		  fi; \
		done

deps:
		echo -n > .depend ; \
		buf="" ; \
		for f in `find . -name "*.h"` ; do \
		  if test "x$$buf" != "x"; then \
		      echo $$buf >>.depend ; \
		      echo "" >>.depend ; \
		  fi; \
		  buf="$$f:"; \
		  for d in `grep "#include \"" <$$f | awk -F \" '{print $$2}'`; do \
		      if test "x$$buf" != "x"; then \
		         echo $$buf \\ >>.depend ; \
		      fi; \
		      echo -n "		" >>.depend ; \
		      buf="$$d "; \
		  done; \
		done; \
		if test "x$$buf" != "x"; then \
		  echo $$buf >>.depend ; \
		  buf="" ; \
		  echo "" >>.depend ; \
		fi ; \
		for file in `find . -name "*.c"` ; do \
		  if test "x$$buf" != "x"; then \
		      echo $$buf >>.depend ; \
		      echo >>.depend ; \
		  fi; \
		  buf="."`echo $$file | awk -F . '{print $$2}'`".o:" ; \
		  for d in `grep "#include \"" < $$file | awk -F \" '{print $$2}'`; do \
		      if test "x$$buf" != "x"; then \
		         echo $$buf \\ >>.depend ; \
		      fi; \
		      echo -n "		" >>.depend ; \
		      buf="$$d "; \
		  done; \
		done; \
		if test "x$$buf" != "x"; then \
		  echo $$buf >>.depend ; \
		fi

asview: asview.o common.o @LIBPROG@
		$(CC) asview.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asview

asscale: asscale.o common.o @LIBPROG@
		$(CC) asscale.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asscale

astile: astile.o common.o @LIBPROG@
		$(CC) astile.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o astile

asmerge: asmerge.o common.o @LIBPROG@
		$(CC) asmerge.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asmerge

asgrad: asgrad.o common.o @LIBPROG@
		$(CC) asgrad.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asgrad

asflip: asflip.o common.o @LIBPROG@
		$(CC) asflip.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asflip

asi18n: asi18n.o common.o @LIBPROG@
		$(CC) asi18n.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asi18n

astext: astext.o common.o @LIBPROG@
		$(CC) astext.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o astext

ascompose: ascompose.o common.o @LIBPROG@
		$(CC) ascompose.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o ascompose

asvector: asvector.o common.o $(LIB_STATIC)
		$(CC) asvector.o common.o $(LIBRARIES) $(EXTRA_LIBRARIES) -o asvector



.c.o:
		$(CC) $(CCFLAGS) $(EXTRA_DEFINES) $(INCLUDES) $(EXTRA_INCLUDES) -c $*.c

.c.s:
		$(CC) $(CCFLAGS) $(EXTRA_DEFINES) $(INCLUDES) $(EXTRA_INCLUDES) -S $*.c

.lo:	$*.c


install:	install.bin

uninstall:	uninstall.bin

include .depend

@LIBAFTERIMAGEFILES@

$(LIBAFTERIMAGE_PATH)/libAfterImage.a: $(LIBAFTERIMAGE_OBJS) $(LIBAFTERIMAGE_INCS)
		cd $(LIBAFTERIMAGE_PATH)/; ${MAKE} libAfterImage.a

$(LIBAFTERIMAGE_PATH)/libAfterImage.so: $(LIBAFTERIMAGE_OBJS) $(LIBAFTERIMAGE_INCS)
		cd $(LIBAFTERIMAGE_PATH)/; ${MAKE} libAfterImage.so
