#
# Router rc control scripts Makefile
#
# Copyright 2005, Broadcom Corporation
# All Rights Reserved.
# 
# THIS SOFTWARE IS OFFERED "AS IS", AND BROADCOM GRANTS NO WARRANTIES OF ANY
# KIND, EXPRESS OR IMPLIED, BY STATUTE, COMMUNICATION OR OTHERWISE. BROADCOM
# SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS
# FOR A SPECIFIC PURPOSE OR NONINFRINGEMENT CONCERNING THIS SOFTWARE.
#
# $Id$
#

include $(TOP)/.config

CFLAGS	+= -I. -I$(TOP)/shared -I$(TOP)/busybox -I$(SRCBASE)/include -Wall
#CFLAGS	+= -g -DDEBUG
CFLAGS	+= -s -O2
LDFLAGS	+= -L$(TOP)/nvram -L$(INSTALLDIR)/nvram/usr/lib -lnvram -L$(TOP)/shared -L$(INSTALLDIR)/shared/usr/lib -lshared

##OBJS := rc.o init.o interface.o network.o services.o udhcpc.o http.o stats.o crc.o mtd.o
OBJS := rc.o init.o interface.o network.o services.o udhcpc.o http.o stats.o crc.o mtd.o ap.o ap_shared.o

ifeq ($(CONFIG_NAT),y)
OBJS += firewall.o
LDFLAGS += -L$(TOP)/netconf -L$(INSTALLDIR)/netconf/usr/lib -lnetconf
endif

ifeq ($(CONFIG_NAT),y)
OBJS += ppp.o
endif

vpath %.c $(TOP)/shared $(SRCBASE)/rts/src

all: rc

clean:
	rm -f *.o rc

install: all
	install -d $(INSTALLDIR)/sbin
	install rc $(INSTALLDIR)/sbin
	$(STRIP) $(INSTALLDIR)/sbin/rc
	cd $(INSTALLDIR)/sbin && ln -sf rc init
	cd $(INSTALLDIR)/sbin && ln -sf rc erase
	cd $(INSTALLDIR)/sbin && ln -sf rc write
	cd $(INSTALLDIR)/sbin && ln -sf rc stats
	cd $(INSTALLDIR)/sbin && ln -sf rc hotplug
#DanielAdd
	cd $(INSTALLDIR)/sbin && ln -sf rc assoclistd
#	cd $(INSTALLDIR)/sbin && ln -sf rc UpgradePmon
#	cd $(INSTALLDIR)/sbin && ln -sf rc fcc
	cd $(INSTALLDIR)/sbin && ln -sf rc mem_test
	cd $(INSTALLDIR)/sbin && ln -sf rc test
#	cd $(INSTALLDIR)/sbin && ln -sf rc sitesurvay
#	cd $(INSTALLDIR)/sbin && ln -sf rc wlget
#	cd $(INSTALLDIR)/sbin && ln -sf rc sprom
	cd $(INSTALLDIR)/sbin && ln -sf rc restart_httpd
	cd $(INSTALLDIR)/sbin && ln -sf rc kill_easyconf
#	cd $(INSTALLDIR)/sbin && ln -sf rc read_mtd
	cd $(INSTALLDIR)/sbin && ln -sf rc RestoreDefaults
	cd $(INSTALLDIR)/sbin && ln -sf rc lan
	cd $(INSTALLDIR)/sbin && ln -sf rc gpio
	cd $(INSTALLDIR)/sbin && ln -sf rc AutoScanOnBtn
	cd $(INSTALLDIR)/sbin && ln -sf rc DetectWDSLink
	cd $(INSTALLDIR)/sbin && ln -sf rc AutoScanBlinking
	cd $(INSTALLDIR)/sbin && ln -sf rc APRepeaterDaemon

rc: $(OBJS)
	$(CC) -o $@ $^ $(LDFLAGS)

%.o: .%.depend
.%.depend: %.c
	$(CC) $(CFLAGS) -M $< > $@

-include $(OBJS:%.o=.%.depend)
