#
# bmon Makefile
#

ifeq ($(shell [ ! -r Makefile.opts ] && echo 1),)
    include Makefile.opts
endif


######################################################################
# Variables
######################################################################
BMON := bmon intf draw conf


######################################################################
# subst
######################################################################
BMON_OBJ := $(BMON:%=src/%.o)

export

######################################################################
# general
######################################################################
all: Makefile.opts bmon

Makefile.opts:
	@echo "**** No configuration found, please run ./configure"
	@exit 1

######################################################################
# bmon
######################################################################
bmon: Makefile.opts Makefile $(BMON_OBJ)
	$(CC) $(CFLAGS) -o $@ $(BMON_OBJ) $(LDFLAGS)


######################################################################
# clean
# ####################################################################
clean: bmon-clean

bmon-clean:
	rm -f $(BMON_OBJ)
	rm -f bmon

distclean: clean
	rm -f Makefile.opts
	rm -f defs.h
	rm -Rf .dep
	rm -f config*status config*cache config*log
	rm -f *~
	rm -rf autom4te.cache

######################################################################
# release
######################################################################
release: distclean
	echo "Building release..."
	@./release ${VERSION}

######################################################################
# show
######################################################################
show:
	@echo CC: $(CC)
	@echo CFLAGS: $(CFLAGS)
	@echo LDFLAGS: $(LDFLAGS)
	@echo BMON_OBJ: $(BMON_OBJ)

######################################################################
# install
######################################################################
install: all
	mkdir -p $(DESTDIR)$(prefix)/bin/
	install -o 0 -g 0 -m 0755 -s bmon $(DESTDIR)$(prefix)/bin/
	mkdir -p $(DESTDIR)$(prefix)/share/man/man1/
	install -o 0 -g 0 -m 0644 bmon.1 $(DESTDIR)$(prefix)/share/man/man1/
