TOPDIR=../
include $(TOPDIR)Make.in

BINDIR = bin/
DEPSDIR = deps/
OBJECT = $(subst .S,.o,$(wildcard *.S)) $(subst .c,.o,$(wildcard *.c))
DEPS = $(addprefix $(DEPSDIR), $(OBJECT:.o=.d))


#********************************************* Make ****************************************************


all: deps compile_console compile compile_mii compile_if_rl compile_fxp compile_usb $(BINDIR)$(DRIVER)
	$(LD) -r -o $(BINDIR)$(DRIVER) $(wildcard $(BINDIR)*.o)


compile: $(addprefix $(BINDIR), $(OBJECT))

compile_console:
	cd console; make

compile_mii:
	cd mii; make

compile_if_rl:
	cd if_rl; make

compile_fxp:
	cd fxp; make

compile_usb:
#	cd usb; make

deps: $(DEPS)


include $(DEPS)


$(DEPSDIR)%.d: %.c
	(echo -n $(BINDIR); $(DEP) $<) > $@

$(DEPSDIR)%.d: %.S
	(echo -n $(BINDIR); $(DEP) $<) > $@

$(BINDIR)%.o: %.S
	$(CC) $(CFLAG) -o $@ $<

$(BINDIR)%.o: %.c
	$(CC) $(CFLAG) -o $@ $<


clean:
	rm -f $(BINDIR)*
	rm -f $(DEPSDIR)*
