
PROGS= aftershow aftershow_pipe

AFTERSHOW_OBJS= aftershow.o xmlutil.o xutil.o

AFTERSHOW_PIPE_OBJS= aftershow_pipe.o xutil.o

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) -I..

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 =..
LIB_STATIC      = $(LIBAFTERIMAGE_PATH)/libAfterImage.a
LIB_SHARED      = $(LIBAFTERIMAGE_PATH)/libAfterImage.so


all:    $(PROGS)

install.bin:	$(PROGS)
		@echo "installing libAfterImage apps using command - "; \
		if [ ! -d $(BIN_DIR) ] ; then 	$(MKDIR) -p $(BIN_DIR); fi; \
		echo "    \"$(INSTALL_PROGRAM) <app> $(BIN_DIR)\" :"; \
		for p in $(PROGS); do \
			echo -n "$$p "; \
	  		$(INSTALL_PROGRAM) $$p $(BIN_DIR); \
		done; \
		echo ""; echo "Done."; \

install.man:
		@if [ ! -d $(MAN_DIR) ] ; then 	$(MKDIR) -p $(MAN_DIR); fi; \
		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:
		@for p in $(PROGS); do \
			echo "$(RMF) $(BIN_DIR)/$$p"; \
			$(RMF) $(BIN_DIR)/$$p; \
		done

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

aftershow: $(AFTERSHOW_OBJS) @LIBPROG@
		$(CC) $(AFTERSHOW_OBJS) $(LIBRARIES) $(EXTRA_LIBRARIES) -o aftershow


aftershow_pipe: $(AFTERSHOW_PIPE_OBJS) @LIBPROG@
		$(CC) $(AFTERSHOW_PIPE_OBJS) $(LIBRARIES) $(EXTRA_LIBRARIES) -o aftershow_pipe


.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
