TOPDIR = $(shell pwd)
DESTLIB = ${TOPDIR}/lib
DESTBIN = ${TOPDIR}/bin
DESTSBIN = ${TOPDIR}/sbin

export TOPDIR DESTLIB DESTSBIN DESTBIN


CFLAGS += -O2
CFLAGS += -DEMBED

#-----------------------------------------------------------------------------
SUBDIRS += bridge-utils
SUBDIRS += amit_open_lib
SUBDIRS += amit_dhcpcd
SUBDIRS += amit_dhcpd
ifeq (${_STORAGE},1)
	SUBDIRS += amit_fs			#added by Laroche
endif
ifeq ($(_USB_PRINTER), 1)
	SUBDIRS += mini-lpd		#added by Laroche 2006/02/06
endif
ifeq (${_SAMBA},1)
	SUBDIRS += samba-3.0.20		#added by Laroche
endif
SUBDIRS += amit_script
SUBDIRS += amit_syslogd
SUBDIRS += wireless_tools	#added by Laroche
SUBDIRS += ntpclient   # ntp client
################################################
ifeq (${_8021X}, 1)
	SUBDIRS += amit_802.1x
endif
ifeq (${_FTP_SERVER}, 1)
	SUBDIRS += vsftpd-2.0.3
endif
ifeq (${_QUOTA}, 1)
	SUBDIRS += quota-tools
endif
SUBDIRS += wget-1.7.1
SUBDIRS += Transmission-0.8.2
SUBDIRS += mt-daapd-0.2.4
SUBDIRS += amit_bin
SUBDIRS += amit_sbin
#-----------------------------------------------------------------------------
test:
	echo ar=$(AR)
	echo cc=$(CC)
	echo destbin=$(DESTSBIN)
	echo topdir=$(TOPDIR)
	for i in $(SUBDIRS) ; do ${MAKE} ${MFLAGS} -C $$i test || exit 1; done
#-----------------------------------------------------------------------------
all:
	@echo make usr_src all
	@if [ -d $(DESTLIB) ]; then echo lib dir exist; else mkdir $(DESTLIB); fi
	@if [ -d $(DESTBIN) ]; then echo bin dir exist; else mkdir $(DESTBIN); fi
	@if [ -d $(DESTSBIN) ]; then echo sbin dir exist; else mkdir $(DESTSBIN); fi
	@for i in $(SUBDIRS) ; do ${MAKE} ${MFLAGS} -C $$i all || exit 1; done

#-----------------------------------------------------------------------------
install:
	@echo make usr_src install
	@if [ -d $(DESTLIB) ]; then echo lib dir exist; else mkdir $(DESTLIB); fi
	@if [ -d $(DESTBIN) ]; then echo bin dir exist; else mkdir $(DESTBIN); fi
	@if [ -d $(DESTSBIN) ]; then echo sbin dir exist; else mkdir $(DESTSBIN); fi
	@for i in $(SUBDIRS) ; do ${MAKE} ${MFLAGS} -C $$i install || exit 1; done
	@cp -d amit_bin/* bin; cp -d amit_sbin/* sbin;
	@cd libexec/ipsec; i386-linux-strip *; cd ..;

#-----------------------------------------------------------------------------
GPL:
	@echo make usr_src GPL
	@for i in $(SUBDIRS) ; do ${MAKE} ${MFLAGS} -C $$i GPL || exit 1; done

#-----------------------------------------------------------------------------
clean:
	@echo make usr_src clean
	rm -rf $(DESTLIB)
	rm -rf $(DESTBIN)
	rm -rf $(DESTSBIN)
	rm -rf libexec
	rm -rf lib
	for i in $(SUBDIRS) ; do ${MAKE} ${MFLAGS} -C $$i clean || exit 1; done


	
