MODULES = message.o
ifneq ($(KERNELRELEASE), )
obj-m := $(MODULES)
#CFLAGS_MODULE += -DDEBUG
else
ROOTDIR ?= ../atmark-dist-20080717
ROMFSDIR = $(ROOTDIR)/romfs
include $(ROOTDIR)/.config
include $(ROOTDIR)/config.arch
MAKEARCH = $(MAKE) ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE)

LINUXDIR = $(CONFIG_LINUXDIR)
KERNELRELEASE = ${shell make -sC $(ROOTDIR)/$(LINUXDIR) kernelrelease}

all: modules romfs

modules:
	$(MAKEARCH) -C $(ROOTDIR)/$(LINUXDIR) M=${shell pwd} modules

romfs:
	make -C $(ROOTDIR) INSTALL_MOD_DIR=kernel/drivers/char \
	M=${shell pwd} modules_install
	$(ROOTDIR)/user/busybox/examples/depmod.pl -b \
	$(ROMFSDIR)/lib/modules/$(KERNELRELEASE) &> /dev/null

clean:
	-rm -f *.[oas] *.ko *.mod.c .*.d .*.tmp .*.cmd *.symvers
	-rm -rf .tmp_versions

distclean: clean
	-rm -f *~
endif