# duilder header starts #
export PRJ := pwatch
export VER := 0.0.2
export REV := 1
export DESTDIR

export I_ETC := $(DESTDIR)/etc
export I_BIN := $(DESTDIR)/bin
export I_SBIN := $(DESTDIR)/usr/sbin
export I_USR_BIN := $(DESTDIR)/usr/bin
export I_USR_SBIN := $(DESTDIR)/usr/sbin
export I_USR_INCLUDE := $(DESTDIR)/usr/include
export I_USR_INC := $(DESTDIR)/usr/include
export I_USR_SHARE_DOC := $(DESTDIR)/usr/share/doc/pwatch-0.0.2
export I_USR_LIB := $(DESTDIR)/usr/lib
export I_LIB := $(DESTDIR)/usr/lib
export I_VAR_LOG := $(DESTDIR)/var/log/pwatch

# DB stuff
export DB_SUPPORT := 1
# PG
export PG_FOUND := 1
export PG_INC :=  -I/usr/include
export PG_LIB :=  -L/usr/lib -lpq

# duilder header ends #

export CC := gcc
export INCS += -I. -I$(PWD)/
export CFLAGS += -ggdb3 -Wall -Wextra -pedantic -Wno-long-long -pipe \
	-Wswitch-enum -D_GNU_SOURCE -O0 #-O2


.PHONY: all
all:
	@echo "-------- Build... -----------"
	@$(MAKE) -C src build
	@echo "------- Done build ----------"


.PHONY: clean
clean:
	@echo "--- Cleaning... ---"
	@rm -fv $(PRJ)-*.rpm $(PRJ)-*-i386-1.tgz $(PRJ)-*.tar.gz
	@$(MAKE) -C src clean


install: all
	@$(MAKE) -C src install

# duilder tail starts #

# This is to allow exporting only the git tree
dist_git:
	@./duilder git "$(PRJ)" "" "1" "/data/www/umbrella/kernel/us/pwatch" "1"

.PHONY: dist
dist: clean
	@./duilder git "$(PRJ)" "" "1" "/data/www/umbrella/kernel/us/pwatch" "1"
	@./duilder tar "$(PRJ)" "$(VER)" "/data/www/umbrella/kernel/us/pwatch" ""
	@./duilder srpm "$(PRJ)" "$(VER)" "/data/www/umbrella/kernel/us/pwatch" "1" "../dinorepo/fedora/SRPMS" "/usr/local/bin/submit_package"
	@./duilder docs "$(PRJ)" "$(VER)" "/data/www/umbrella/kernel/us/pwatch"
	@rm -f "$(PRJ)-$(VER).tar.gz"

