#
# The compilation of software known as FreeBSD GraphicBoot is distributed under
# the following terms:
#
# Copyright (C) 2005 Matthew Holder. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
# 1. Redistributions of source code must retain the above copyright
#    notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
#    notice, this list of conditions and the following disclaimer in the
#    documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
# graphicboot - Provides graphical X Window startup to FreeBSD during 'rc'.
# $SixXGate: motifapps/graphicboot/Makefile.in,v 1.11 2005/08/11 07:43:15 matthew Exp $
#

ifndef ETCDIR
ETCDIR			= /etc
endif

ifndef RC_DDIR
RC_DDIR 		= $(ETCDIR)/rc.d
endif

ifndef XBCONF
XBCONF			= $(ETCDIR)/Xboot
endif

srcdir			= @srcdir@
prefix			= @prefix@
mandir			= @mandir@

CC			= @CC@
CPP			= @CPP@
LINK			= $(CC) $(CFLAGS)

CFLAGS			= @CFLAGS@
X_CFLAGS		= @X_CFLAGS@
CPPFLAGS		= -Wall $(X_CFLAGS) @CPPFLAGS@

LDFLAGS 		= $(X_LIBS) @LDFLAGS@
LIBS			= @LIBS@
X_LIBS			= @X_LIBS@
X_EXTRA_LIBS		= @X_EXTRA_LIBS@

MKINSTALLDIRS		= ./mkinstalldirs
MKDIRHIER		= $(MKINSTALLDIRS)
INSTALL			= @INSTALL@
INSTALL_DATA		= @INSTALL_DATA@
INSTALL_PROGRAM		= @INSTALL_PROGRAM@
INSTALL_SCRIPT		= @INSTALL_SCRIPT@
INSTALL_MAN		= $(INSTALL) -m 0444
RM			= @RM@
LN			= @LN_S@
COMPRESSCMD		= @COMPRESSCMD@

PROGRAMS		= graphicboot sendgbmsg

PREHEADER		= common.h
PREHEADER_OBJ		= common.h.gch

GB_SRCS 		= graphicboot.c gbserver.c console.c
GB_OBJS 		= graphicboot.o gbserver.o console.o

MSG_SRCS		= sendgbmsg.c
MSG_OBJS		= sendgbmsg.o

MANPAGES		= graphicboot.8 sendgbmsg.8

# Programs
XLOADIMAGE		= @XLOADIMAGE@
XRDB			= @XRDB@
XSETROOT		= @XSETROOT@

# =============================================================================
# Make sure we have all the needed programs
# =============================================================================
ifeq ($(XLOADIMAGE), no)
$(error You do not have xloadimage installed)
endif

ifeq ($(XRDB), no)
$(error You do not have xrdb installed)
endif

ifeq ($(XSETROOT), no)
$(error You do not have xsetroot installed)
endif

ifeq ($(RM), no)
$(error You do not have the rm program)
else
RM += -f
endif

# Autoconf discovered paths
CPPFLAGS += \
	-DXLOADIMAGE=\"$(XLOADIMAGE)\" \
	-DXRDB=\"$(XRDB)\" \
	-DXSETROOT=\"$(XSETROOT)\"

all:: $(PROGRAMS)

$(PREHEADER_OBJ): $(PREHEADER)
	$(CC) $(CFLAGS) -o $@ $(CPPFLAGS) $(PREHEADER)

graphicboot: $(PREHEADER_OBJ) $(GB_OBJS)
	$(RM) $@
	$(LINK) -o $@ $(GB_OBJS) $(LIBS) $(LDFLAGS) $(X_EXTRA_LIBS)

sendgbmsg: $(PREHEADER_OBJ) $(MSG_OBJS)
	$(RM) $@
	$(LINK) -o $@ $(MSG_OBJS) $(LIBS)

graphicboot.c: graphicboot.h $(PREHEADER_OBJ)
gbserver.c: graphicboot.h $(PREHEADER_OBJ)
console.c: graphicboot.h $(PREHEADER_OBJ)
sendgbmsg.c: $(PREHEADER_OBJ)

install: $(PROGRAMS) install.man
	$(INSTALL_PROGRAM) graphicboot $(prefix)/bin/
	$(INSTALL_PROGRAM) sendgbmsg $(prefix)/bin/
	
	$(INSTALL_SCRIPT) -m 0555 startgraphicboot $(RC_DDIR)/
	$(INSTALL_SCRIPT) -m 0555 endgraphicboot $(RC_DDIR)/
	$(INSTALL_SCRIPT) -m 0555 MSG.* $(RC_DDIR)/
	
	$(MKDIRHIER) $(XBCONF)
	
	$(INSTALL_DATA) Xsplash.jpg $(XBCONF)/
	$(INSTALL_DATA) Xresources $(XBCONF)/
	$(INSTALL_DATA) xorg.conf $(XBCONF)/
	
	$(LN) -f $(prefix)/bin/X $(DESTDIR)$(XBCONF)/Xserver
	
install.man:: $(MANPAGES)

graphicboot.8: graphicboot.man
	$(RM) $(mandir)/man8/graphicboot.8*
	$(RM) $(mandir)/cat8/graphicboot.8*
	$(INSTALL_MAN) graphicboot.man $(mandir)/man8/graphicboot.8
	$(COMPRESSCMD) $(mandir)/man8/graphicboot.8

sendgbmsg.8: sendgbmsg.man
	$(RM) $(mandir)/man8/sendgbmsg.8*
	$(RM) $(mandir)/cat8/sendgbmsg.8*
	$(INSTALL_MAN) sendgbmsg.man $(mandir)/man8/sendgbmsg.8
	$(COMPRESSCMD) $(mandir)/man8/sendgbmsg.8

clean:: cleandir
	$(RM) $(PREHEADER_OBJ)

cleandir::
	$(RM) *.s
	$(RM) *.CKP *.ln *.BAK *.bak *.o core errs ,* *~ *.a .emacs_* tags TAGS make.log MakeOut *.core  "#"*

distclean:: clean
	$(RM) Makefile .depend
	$(RM) $(PROGRAMS)
	$(RM) configure.lineno config.status config.h *.scan *.log
	$(RM) -r autom4te.cache


syntax highlighted by Code2HTML, v. 0.9.1