# Hobbit main Makefile
#
# This file is included from the Makefile created by the "configure" script



#####################
# Build targets
#####################

CFLAGS += -I. -I$(BUILDTOPDIR)/include

ifeq ($(CLIENTONLY),yes)
	BUILDTARGETS = client
	CFLAGS += -DCLIENTONLY=1
ifeq ($(LOCALCLIENT),yes)
	CLIENTTARGETS = lib-client common-client build-build hobbitd-client
	INSTALLTARGETS = install-client install-localclient install-clientmsg
	CFLAGS += -DLOCALCLIENT=1 $(PCREINCDIR)
else
	CLIENTTARGETS = lib-client common-client build-build
	INSTALLTARGETS = install-client install-clientmsg
endif
else
	BUILDTARGETS = lib-build common-build bbdisplay-build bbnet-build bbproxy-build docs-build build-build hobbitd-build web-build client
	CLIENTTARGETS = lib-client common-client build-build
	INSTALLTARGETS = install-bbdisplay install-bbnet install-bbproxy install-man install-hobbitd install-web install-docs install-client install-servermsg
	CFLAGS += $(PCREINCDIR)
endif

ifndef INSTALLBINDIR
INSTALLBINDIR = $(BBHOME)/bin
endif
ifndef INSTALLETCDIR
INSTALLETCDIR = $(BBHOME)/etc
endif
ifndef INSTALLEXTDIR
INSTALLEXTDIR = $(BBHOME)/ext
endif
ifndef INSTALLTMPDIR
INSTALLTMPDIR = $(BBHOME)/tmp
endif
ifndef INSTALLWEBDIR
INSTALLWEBDIR = $(BBHOME)/web
endif
ifndef INSTALLWWWDIR
INSTALLWWWDIR = $(BBHOME)/www
endif

ARESVER = 1.2.1

IDTOOL := $(shell if test `uname -s` = "SunOS"; then echo /usr/xpg4/bin/id; else echo id; fi)

ifdef RPATH
RPATHOPT := $(RPATH)$(shell echo $(RPATHVAL) | sed -e 's/ / $(RPATH)/g')
endif

all: include/config.h $(BUILDTARGETS)
	@echo ""
	@echo "Build complete. Now run '${MAKE} install' as root"
	@echo ""

client: include/config.h $(CLIENTTARGETS)
	CC="$(CC)" CFLAGS="$(CFLAGS)" BBHOME="$(BBTOPDIR)/client" BBHOSTIP="$(BBHOSTIP)" LOCALCLIENT="$(LOCALCLIENT)" NETLIBS="$(NETLIBS)" $(MAKE) -C client all

include/config.h:
	MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" $(BUILDTOPDIR)/build/genconfig.sh

build-build:
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" $(MAKE) -C build all

lib-build: include/config.h
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" OSDEF="$(OSDEF)" RPATHOPT="$(RPATHOPT)" PCREINCDIR="$(PCREINCDIR)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBTOPDIR="$(BBTOPDIR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" $(MAKE) -C lib all

lib-client:
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" OSDEF="$(OSDEF)" RPATHOPT="$(RPATHOPT)" PCREINCDIR="$(PCREINCDIR)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBTOPDIR="$(BBTOPDIR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" LOCALCLIENT="$(LOCALCLIENT)" $(MAKE) -C lib client

common-build: lib-build
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" $(MAKE) -C common all

common-client: lib-client
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" $(MAKE) -C common client

bbdisplay-build: lib-build common-build
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" HISTGRAPHDEF="$(HISTGRAPHDEF)" RUNTIMEDEFS="$(RUNTIMEDEFS)" PCREINCDIR="$(PCREINCDIR)" PCRELIBS="$(PCRELIBS)" $(MAKE) -C bbdisplay all


bbnet-build: lib-build common-build
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" SSLFLAGS="$(SSLFLAGS)" SSLINCDIR="$(SSLINCDIR)" SSLLIBS="$(SSLLIBS)" LDAPFLAGS="$(LDAPFLAGS)" LDAPINCDIR="$(LDAPINCDIR)" LDAPLIBS="$(LDAPLIBS)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" ARESVER="$(ARESVER)" RUNTIMEDEFS="$(RUNTIMEDEFS)" PCREINCDIR="$(PCREINCDIR)" PCRELIBS="$(PCRELIBS)" $(MAKE) -C bbnet all

bbproxy-build: lib-build common-build
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" NETLIBS="$(NETLIBS)" BBHOME="$(BBHOME)" $(MAKE) -C bbproxy all

hobbitd-build: lib-build build-build common-build 
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" RRDDEF="$(RRDDEF)" RRDINCDIR="$(RRDINCDIR)" PCREINCDIR="$(PCREINCDIR)" NETLIBS="$(NETLIBS)" RRDLIBS="$(RRDLIBS)" PCRELIBS="$(PCRELIBS)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" BBUSER="$(BBUSER)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBHOSTURL="$(BBHOSTURL)" BBCGIURL="$(BBCGIURL)" SECUREBBCGIURL="$(SECUREBBCGIURL)" MAILPROGRAM="$(MAILPROGRAM)" FPING="$(FPING)" RUNTIMEDEFS="$(RUNTIMEDEFS)" INSTALLWWWDIR="$(INSTALLWWWDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" $(MAKE) -C hobbitd all

web-build: lib-build build-build common-build 
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" RRDDEF="$(RRDDEF)" RRDINCDIR="$(RRDINCDIR)" PCREINCDIR="$(PCREINCDIR)" NETLIBS="$(NETLIBS)" RRDLIBS="$(RRDLIBS)" PCRELIBS="$(PCRELIBS)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" BBUSER="$(BBUSER)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBHOSTURL="$(BBHOSTURL)" BBCGIURL="$(BBCGIURL)" SECUREBBCGIURL="$(SECUREBBCGIURL)" MAILPROGRAM="$(MAILPROGRAM)" RUNTIMEDEFS="$(RUNTIMEDEFS)" INSTALLWWWDIR="$(INSTALLWWWDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" $(MAKE) -C web all

hobbitd-client: lib-client build-build common-client 
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" RRDDEF="$(RRDDEF)" RRDINCDIR="$(RRDINCDIR)" PCREINCDIR="$(PCREINCDIR)" NETLIBS="$(NETLIBS)" RRDLIBS="$(RRDLIBS)" PCRELIBS="$(PCRELIBS)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" BBUSER="$(BBUSER)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBHOSTURL="$(BBHOSTURL)" BBCGIURL="$(BBCGIURL)" SECUREBBCGIURL="$(SECUREBBCGIURL)" MAILPROGRAM="$(MAILPROGRAM)" RUNTIMEDEFS="$(RUNTIMEDEFS)" INSTALLWWWDIR="$(INSTALLWWWDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" $(MAKE) -C hobbitd client

docs-build:
	BBHOSTURL="$(BBHOSTURL)" $(MAKE) -C docs all

custom-build: lib-build
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" RRDDEF="$(RRDDEF)" RRDINCDIR="$(RRDINCDIR)" PCREINCDIR="$(PCREINCDIR)" NETLIBS="$(NETLIBS)" RRDLIBS="$(RRDLIBS)" PCRELIBS="$(PCRELIBS)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" BBLOGDIR="$(BBLOGDIR)" BBHOSTNAME="$(BBHOSTNAME)" BBHOSTIP="$(BBHOSTIP)" BBHOSTOS="$(BBHOSTOS)" BBUSER="$(BBUSER)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBHOSTURL="$(BBHOSTURL)" BBCGIURL="$(BBCGIURL)" SECUREBBCGIURL="$(SECUREBBCGIURL)" MAILPROGRAM="$(MAILPROGRAM)" RUNTIMEDEFS="$(RUNTIMEDEFS)" INSTALLWWWDIR="$(INSTALLWWWDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" $(MAKE) -C custom all || echo "Skipped custom modules"

demo-build:
	CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" RPATHOPT="$(RPATHOPT)" NETLIBS="$(NETLIBS)" $(MAKE) -C demotool all


#####################
# Cleanup targets
#####################
distclean: allclean
	rm -f Makefile
	rm -rf bbnet/c-ares
	rm -rf debbuild rpmbuild

allclean: clean
	(cd bbnet/c-ares && $(MAKE) clean) || true

clean:
	$(MAKE) -C build clean
	$(MAKE) -C lib clean
	$(MAKE) -C common clean
	$(MAKE) -C bbdisplay clean
	$(MAKE) -C bbnet clean
	$(MAKE) -C bbproxy clean
	$(MAKE) -C hobbitd clean
	$(MAKE) -C web clean
	$(MAKE) -C docs clean
	$(MAKE) -C client clean
	$(MAKE) -C demotool clean
	$(MAKE) -C custom clean || echo ""
	rm -f ./*~ include/config.h include/*~ debian/*~ rpm/*~ contrib/*~


####################
# Install targets
####################

install: $(INSTALLTARGETS)

install-servermsg:
	@echo ""
	@echo "Installation complete."
	@echo ""
	@echo "You must configure your webserver for the Hobbit webpages and CGI-scripts."
	@echo "A sample Apache configuration is in ${BBHOME}/etc/hobbit-apache.conf"
	@echo "If you have your Administration CGI scripts in a separate directory,"
	@echo "then you must also setup the password-file with the htpasswd command."
	@echo ""
	@echo "To start Hobbit, as the $(BBUSER) user run '${BBHOME}/bin/hobbit.sh start'"
	@echo "To view the Hobbit webpages, go to http://${BBHOSTNAME}${BBHOSTURL}"

install-dirs:
	mkdir -p $(INSTALLROOT)$(BBHOME) $(INSTALLROOT)$(BBHOME)/download $(INSTALLROOT)$(BBVAR)

	mkdir -p $(INSTALLROOT)$(INSTALLBINDIR)
ifneq ($(INSTALLBINDIR),$(BBHOME)/bin)
	ln -sf $(INSTALLBINDIR) $(INSTALLROOT)$(BBHOME)/bin
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLBINDIR)
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(INSTALLBINDIR)
endif

	mkdir -p $(INSTALLROOT)$(INSTALLETCDIR)
ifneq ($(INSTALLETCDIR),$(BBHOME)/etc)
	ln -sf $(INSTALLETCDIR) $(INSTALLROOT)$(BBHOME)/etc
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLETCDIR)
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(INSTALLETCDIR)
endif

	mkdir -p $(INSTALLROOT)$(INSTALLEXTDIR)
ifneq ($(INSTALLEXTDIR),$(BBHOME)/ext)
	ln -sf $(INSTALLEXTDIR) $(INSTALLROOT)$(BBHOME)/ext
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLEXTDIR)
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(INSTALLEXTDIR)
endif

	mkdir -p $(INSTALLROOT)$(INSTALLTMPDIR)
ifneq ($(INSTALLTMPDIR),$(BBHOME)/tmp)
	ln -sf $(INSTALLTMPDIR) $(INSTALLROOT)$(BBHOME)/tmp
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLTMPDIR)
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(INSTALLTMPDIR)
endif

	mkdir -p $(INSTALLROOT)$(INSTALLWEBDIR)
ifneq ($(INSTALLWEBDIR),$(BBHOME)/web)
	ln -sf $(INSTALLWEBDIR) $(INSTALLROOT)$(BBHOME)/web
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLWEBDIR)
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(INSTALLWEBDIR)
endif

	mkdir -p $(INSTALLROOT)$(INSTALLWWWDIR) $(INSTALLROOT)$(INSTALLWWWDIR)/gifs $(INSTALLROOT)$(INSTALLWWWDIR)/help $(INSTALLROOT)$(INSTALLWWWDIR)/html $(INSTALLROOT)$(INSTALLWWWDIR)/menu $(INSTALLROOT)$(INSTALLWWWDIR)/notes $(INSTALLROOT)$(INSTALLWWWDIR)/rep $(INSTALLROOT)$(INSTALLWWWDIR)/snap $(INSTALLROOT)$(INSTALLWWWDIR)/wml
ifneq ($(INSTALLWWWDIR),$(BBHOME)/www)
	ln -sf $(INSTALLWWWDIR) $(INSTALLROOT)$(BBHOME)/www
endif
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(INSTALLWWWDIR) $(INSTALLROOT)$(INSTALLWWWDIR)/gifs $(INSTALLROOT)$(INSTALLWWWDIR)/help $(INSTALLROOT)$(INSTALLWWWDIR)/html $(INSTALLROOT)$(INSTALLWWWDIR)/menu $(INSTALLROOT)$(INSTALLWWWDIR)/notes $(INSTALLROOT)$(INSTALLWWWDIR)/rep $(INSTALLROOT)$(INSTALLWWWDIR)/snap $(INSTALLROOT)$(INSTALLWWWDIR)/wml
	chgrp `$(IDTOOL) -g $(BBUSER)`  $(INSTALLROOT)$(INSTALLWWWDIR) $(INSTALLROOT)$(INSTALLWWWDIR)/gifs $(INSTALLROOT)$(INSTALLWWWDIR)/help $(INSTALLROOT)$(INSTALLWWWDIR)/html $(INSTALLROOT)$(INSTALLWWWDIR)/menu $(INSTALLROOT)$(INSTALLWWWDIR)/notes $(INSTALLROOT)$(INSTALLWWWDIR)/rep $(INSTALLROOT)$(INSTALLWWWDIR)/snap $(INSTALLROOT)$(INSTALLWWWDIR)/wml
ifdef HTTPDGID
# The www/rep and www/snap directories must be writable by the apache daemon
	chgrp $(HTTPDGID) $(INSTALLROOT)$(INSTALLWWWDIR)/rep $(INSTALLROOT)$(INSTALLWWWDIR)/snap
endif
	chmod g+w $(INSTALLROOT)$(INSTALLWWWDIR)/rep $(INSTALLROOT)$(INSTALLWWWDIR)/snap
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/acks
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/acks
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/acks
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/data
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/data
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/data
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/disabled
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/disabled
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/disabled
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/hist
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/hist
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/hist
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/histlogs
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/histlogs
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/histlogs
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/hostdata
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/hostdata
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/hostdata
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/logs
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/logs
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/logs
endif

	mkdir -p $(INSTALLROOT)$(BBVAR)/rrd
ifndef PKGBUILD
	chown $(BBUSER) $(INSTALLROOT)$(BBVAR)/rrd
	chgrp `$(IDTOOL) -g $(BBUSER)` $(INSTALLROOT)$(BBVAR)/rrd
endif

install-common: install-dirs
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C common install

install-bbdisplay: install-common
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C bbdisplay install

install-bbdisplay-nocgi: install-common
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C bbdisplay install-nocgi

install-bbnet: install-common
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" ARESVER="$(ARESVER)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" PKGBUILD="$(PKGBUILD)" $(MAKE) -C bbnet install

install-bbproxy: install-common
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C bbproxy install

install-hobbitd: install-common
	MANROOT="$(MANROOT)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBLOGDIR="$(BBLOGDIR)" BBUSER="$(BBUSER)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" HTTPDGID="$(HTTPDGID)" $(MAKE) -C hobbitd install

install-web: install-common
	MANROOT="$(MANROOT)" BBTOPDIR="$(BBTOPDIR)" BBHOME="$(BBHOME)" BBVAR="$(BBVAR)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" BBLOGDIR="$(BBLOGDIR)" BBUSER="$(BBUSER)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C web install


# NOTE: This one is normally not used - man-page install is done by the sub-Makefiles during "make install"
install-man:
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C common install-man
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" CGIDIR="$(CGIDIR)" SECURECGIDIR="$(SECURECGIDIR)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C bbdisplay install-man
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C bbnet install-man
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C bbproxy install-man
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C hobbitd install-man
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" $(MAKE) -C web install-man

install-docs:
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C docs install

install-custom:
	BBHOME="$(BBHOME)" MANROOT="$(MANROOT)" INSTALLROOT="$(INSTALLROOT)" INSTALLBINDIR="$(INSTALLBINDIR)" INSTALLETCDIR="$(INSTALLETCDIR)" INSTALLEXTDIR="$(INSTALLEXTDIR)" INSTALLTMPDIR="$(INSTALLTMPDIR)" INSTALLWEBDIR="$(INSTALLWEBDIR)" INSTALLWWWDIR="$(INSTALLWWWDIR)" $(MAKE) -C custom install || echo "Skipped custom modules"


client-install: install-client

install-client: client
	BBHOME="$(BBTOPDIR)/client" INSTALLROOT="$(INSTALLROOT)" BBUSER="$(BBUSER)" LOCALCLIENT="$(LOCALCLIENT)" $(MAKE) -C client install

install-clientmsg:
	@echo ""
	@echo "Installation complete."
	@echo ""
	@echo "To start the Hobbit client, as the $(BBUSER) user run '${BBHOME}/runclient.sh start'"

install-localclient:
	BBHOME="$(BBTOPDIR)/client" INSTALLROOT="$(INSTALLROOT)" BBUSER="$(BBUSER)" LOCALCLIENT="$(LOCALCLIENT)" $(MAKE) -C client install-localclient

