bin_PROGRAMS = quoted 
quoted_LDFLAGS = -lm
quoted_SOURCES = quoted.c
man1_MANS = @MAN_PAGES@

# additional CPP defines go here
AM_CPPFLAGS = -DQUOTES_FILE_PATH="\"$(sysconfdir)/quotes\""


# 'quotes' goes into /etc or /usr/local/etc, aka 'sysconfdir'
sysconf_DATA = quotes

if USE_DAEMON

# conditional section, for 'rc#.d' and links
# COPY_RC_FILE always copies to the specified directory
# UPDATE_RC runs the 'update-rc.d script;
# if CREATE_RC_LINK is false, assume I'm running a system that
# uses /usr/local/etc/rc.d scripts, like FreeBSD
# otherwise, if CREATE_RC_LINK is true, I assume it's running
# a system that uses 'init.d' but doesn't have update-rc.d
# for now I only allow a single link to be created.  Later I'll
# need a 'for each' to handle it better

install-data-hook:
if COPY_RC_FILE
	if test -d "$(RC_COPY_DIR)/$(RC_FILE)" ; then \
	  rm -rf "$(RC_COPY_DIR)/$(RC_FILE)" ; \
	elif test -e "$(RC_COPY_DIR)/$(RC_FILE)" ; then \
	  rm -f "$(RC_COPY_DIR)/$(RC_FILE)" ; \
	fi
	cp -f "$(RC_FILE_SRC)" "$(RC_COPY_DIR)/$(RC_FILE)" \
	  && chmod a+x "$(RC_COPY_DIR)/$(RC_FILE)"
if UPDATE_RC
	$(SHELL) -c 'update-rc.d '"$(RC_FILE)"' defaults'
else !UPDATE_RC
if CREATE_RC_LINK
	if test -d "$(RC_LN_DIR)/$(RC_FILE)" ; then \
	  rm -rf "$(RC_LN_DIR)/S50$(RC_FILE)" ; \
	elif test -e "$(RC_LN_DIR)/S50$(RC_FILE)" ; then \
	  rm -f "$(RC_LN_DIR)/S50$(RC_FILE)" ; \
	fi
	$(LN_S) "$(RC_COPY_DIR)/$(RC_FILE)" "$(RC_LN_DIR)/S50$(RC_FILE)"
	@echo ""
	@echo ""
	@echo "The 'quoted' application is now configured to run as a daemon."
	@echo ""
	@echo ""
else !CREATE_RC_LINK
	@echo ""
	@echo ""
	@echo "To run 'quoted' as a daemon at system startup, you will need to update"
	@echo "your rc.conf file to include the following line:"
	@echo ""
	@echo "  quoted_enable=\"YES\""
	@echo ""
	@echo ""
endif !CREATE_RC_LINK
endif !UPDATE_RC
else !COPY_RC_FILE
	@echo ""
	@echo ""
	@echo "To run 'quoted' as a daemon, you should adapt one of the 'rc' shell scripts"
	@echo "to your operating system, and copy it to the appropriate directory.  Most"
	@echo "operating systems, such as Linux, will have an '/etc/init.d' directory that"
	@echo "contains shell scripts that run during startup.  Additionally, there would"
	@echo "be '/etc/rc#.d' directories containing symbolic links to the shell scripts"
	@echo "in '/etc/init.d', and names such as 'S99scriptname' or 'K99scriptname'."
	@echo "For more information, see your operating system documentation, and the"
	@echo "following man pages:  init inittab init.d rc.d"
	@echo "Not all of these pages will contain relevant documentation, but one or more"
	@echo "of them should be sufficient to document the startup process and lead you"
	@echo "in the right direction to configure 'quoted' to run as a daemon."
	@echo ""
	@echo ""
endif !COPY_RC_FILE

uninstall-hook:
if COPY_RC_FILE
if UPDATE_RC
	$(SHELL) -c 'update-rc.d -f '"$(RC_FILE)"' remove'
else !UPDATE_RC
if CREATE_RC_LINK
	rm -f "$(RC_LN_DIR)/S50$(RC_FILE)"
endif CREATE_RC_LINK
endif !UPDATE_RC
	rm -f "$(RC_COPY_DIR)/$(RC_FILE)"
endif COPY_RC_FILE

# make sure that the 'custom stop daemon' doesn't echo a lot
# of unnecessary stuff by declaring it 'silent'

.SILENT: custom-stop-daemon

custom-stop-daemon:
	if test -e "$(DESTDIR)$(bindir)/quoted" \
	   -a -e "$(RC_COPY_DIR)/$(RC_FILE)" ; then \
	  "$(RC_COPY_DIR)/$(RC_FILE)" stop || echo "" ; fi


else !USE_DAEMON

# for this section we need to let the user know to update 'inetd.conf'

install-data-hook:
	@echo ""
	@echo ""
	@echo "Installation is complete; however, to use 'quoted' you will need to add"
	@echo "the following lines (or their equivalent) to 'inetd.conf' and restart"
	@echo "inetd (see the documentation for 'inetd' for more information)."
	@echo ""
	@echo "  qotd  stream  tcp nowait  nobody  /usr/local/bin/quoted  quoted"
	@echo "  qotd  dgram   udp wait    nobody  /usr/local/bin/quoted  quoted"
	@echo ""
	@echo "You should also review information contained in the 'README' file that"
	@echo "was included with this distribution."
	@echo ""
	@echo ""

custom-stop-daemon:


endif !USE_DAEMON


EXTRA_DIST = quotes quoted.1 quoted.interix quoted.rc.linux quoted.rc.interix quoted.sh.rc.freebsd $(man1_MANS) 



syntax highlighted by Code2HTML, v. 0.9.1