SRC=iperf-2.0.2

.PHONY: all clean distclean openSource install dist_install
all: install 
clean:
	make -C $(SRC) clean
	rm -f $(SRC)/.configured

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

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

$(SRC)/.configured:
	cd $(SRC) \
		&& LDFLAGS='-s' CFLAGS='-Os' ./configure \
			--prefix=$(PREFIX) \
			--target=$(TARGET_TYPE) \
			--host=$(HOST_TYPE) \
			--build=$(BUILD_TYPE) \
			--disable-ipv6 \
			--disable-multicast \
			--disable-web100 \
			--disable-nls \
		&& sed -re 's,^#define malloc .*,,' -i config.h
	touch $(SRC)/.configured

install: openSource
	make -C $(SRC) install-strip
	install -d -m 0755 $(SHADOW-DIR)/sbin
	install -m 0755 $(SRC)/src/iperf $(SHADOW-DIR)/sbin/

dist_install: openSource
	make -C $(SRC) install-strip
