SOURCE=samba-3.0.25c/source

.PHONY: all clean distclean openSource install
all: openSource
clean:
	make -C $(SOURCE) clean

distclean:
	-make -C $(SOURCE) distclean
	rm -f $(SOURCE)/.configured

openSource: $(SOURCE)/.configured
	make -C $(SOURCE)

$(SOURCE)/.configured:
	[ "$$PJ_PREFIX" != "" ]
	[ "$$PJ_TARGET" != "" ]
	[ "$$PJ_HOST" != "" ]
	cd $(SOURCE) \
		&& LDFLAGS="-s -L$(PJ_PREFIX)/lib -lpcre" \
		   CFLAGS="-Os" \
		   CPPFLAGS="-I$(PJ_PREFIX)/include" \
		   ./configure \
			--prefix=$(PJ_PREFIX) \
            --target=$(PJ_TARGET) \
            --host=$(PJ_TARGET) \
            --build=$(PJ_HOST) \
			--disable-cups \
			--disable-iprint \
			--disable-pie \
			--disable-fam \
			--with-ads=no \
			--with-ldap=no \
			--with-cifsmount=no \
			--with-logfilebase=/var/log \
			--with-libdir=/usr/lib  \
			--with-swatdir=/usr/local/swat \
			--with-rootsbindir=/sbin \
			--with-lockdir=/var/lock \
			--with-piddir=/var/lock \
			--with-privatedir=/etc/samba \
			--with-configdir=/etc/samba \
			--enable-static=yes \
			--enable-shared=no \
			--with-smbmount \
			--bindir=/bin \
			--sbindir=/sbin
	touch $(SOURCE)/.configured

BIN_DIR := $(PJ_PREFIX)/bin
CONF_DIR := $(PJ_PREFIX)/etc/samba
install:openSource
	install -d -m 0755 $(BIN_DIR)/
	install -m 0755 $(SOURCE)/bin/smbmount $(SOURCE)/bin/smbmnt $(BIN_DIR)
	install -d -m 0755 $(CONF_DIR)/
	install -m 0644 $(SOURCE)/smb.conf $(CONF_DIR)/
