CONFIG_MAKE = ../../configs/config.make
ifeq ($(wildcard $(CONFIG_MAKE)),$(CONFIG_MAKE))
include $(CONFIG_MAKE)
endif

CC = gcc
# AR = $(CROSS)ar
# LD = $(CROSS)ld
# RANLIB = $(CROSS)ranlib
CFLAGS = -Wall -pipe


.PHONY:	all clean

INCLUDE =  -I../h -I../../configs/h/
DEFINES =
LIBS =

ifeq ($(CONFIG_ELX_HAS_APPS_IMAGE),y)
CFLAGS +=-DCONFIG_ELX_HAS_APPS_IMAGE=1
endif

OBJ =  filesizechk mtdcheck

all: clean build

build: $(OBJ)
	chmod 775 $(OBJ)

filesizechk: filesizechk.c
	$(CC) $(DEFINES) $(INCLUDE) $(CFLAGS) $< -o $@

mtdcheck: mtdcheck.c
	if test -f ../../configs/include/spi_flash_partition.h; then \
		cat ../../configs/include/spi_flash_partition.h > __tmp_flash_map.h; \
			cat _mtd_partition.h > __tmp_flash_map.h; \
			cat ../../configs/include/spi_flash_partition.h  | grep -v '#include <linux/mtd/partitions.h' >> __tmp_flash_map.h; \
		$(CC) $(DEFINES) $(INCLUDE) $(CFLAGS) $< -o $@; \
	fi;

%.o: %.c
	$(CC) $(DEFINES) $(INCLUDE) $(CFLAGS) -c $< -o $@

clean:
	$(RM) $(OBJ) *~	
