#
# (C) Copyright 2002
# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
#
# See file CREDITS for list of people who contributed to this
# project.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
# MA 02111-1307 USA
#

ifeq ($(Nvram_Driver),)
Nvram_Driver=RT2870STA
endif


PATCHLEVEL := $(shell uname -r | cut -d. -f2)


ifeq ($(PATCHLEVEL), 4)
    KerVer=KerVer_4
else
    KerVer=Kerver_6

endif

CC:=$(CROSS_COMPILE)gcc
AR:=$(CROSS_COMPILE)ar

OBJS	:= crc32.o  nvram_env.o  ram_env.o
HEADERS := nvram_env.h ram_env.h nvram.h ram.h
CFLAGS += -DUSE_HOSTCC -D$(Nvram_Driver) -D$(KerVer) -Wall -g
ARFLAGS :=rc

all:	libnvram exec

libnvram:$(OBJS) $(HEADERS)
	$(AR) $(ARFLAGS) libnvram.a $(OBJS)

$(OBJS): $(HEADERS)

romfs:
	$(ROMFSINST) libnvram.so /lib	
clean:
	rm -f libnvram.a *.o
exec: $(OBJS) 
	$(CC) fw_env_main.c -L. -lnvram -o fw_printenv 
	$(CC) ram_env_main.c $(OBJS) -o ram_printenv 
	$(CC) -g example1.c $(OBJS) -o example1
	$(CC) -g example2.c $(OBJS) -o example2
	$(CC) -D$(Nvram_Driver) $(CFLAGS) make_config_file.c $(OBJS) -o make_config_file
	$(CC) start_wan.c $(OBJS) -o start_wan
	$(CC) -D$(Nvram_Driver) rc.c $(OBJS) -o rc
	#$(CC) -I$(LINUX_SRC)/include throughput.c $(OBJS) -o throughput
	$(CC) throughput.c $(OBJS) -o throughput
	$(CC) set_bridge_mac.c $(OBJS) -o set_bridge_mac
	$(CC) nvram_get.c $(OBJS) -o nvram_get
	$(CC) nvram_set.c $(OBJS) -o nvram_set
	$(CC) ram_get.c $(OBJS) -o ram_get
	$(CC) ram_set.c $(OBJS) -o ram_set
	cp fw_printenv fw_setenv 
	cp fw_printenv fw_bufsetenv
	cp ram_printenv ram_setenv
	#$(STRIP) nvram_get nvram_set ram_get ram_set libnvram.a
