# Expected Environent:
#
# CIAOBASE:    directory with the CiAO os source (i.e., the trunk/os subdirectory)

CIAOVARIANT := $(CIAOBASE)/kconf/config

ifeq ($(CIAOBASE),)
  CIAOBASE := $(error Environment variable CIAOBASE is not set)
endif

# default target 
default : all

APP     := $(shell basename $(PWD))

KCONF_ROOT := $(CIAOBASE)/kconf
CONFIGDIR=$(KCONF_ROOT)/config

QCONF=$(KCONF_ROOT)/ciao-kconfig/scripts/kconfig/qconf
CAM=$(KCONF_ROOT)/common/scripts/app_create_model.pl
TRANSFORM=$(KCONF_ROOT)/common/scripts/transform.pl

.PHONY: all clean distclean xconfig transform
all:

xconfig: SystemObjects.fm $(APP).fm
	$(QCONF) $(APP).fm $(APP).config

transform:
	$(TRANSFORM) -f $(APP).config -s $(APP).configspace.pl -i $(CIAOBASE)/os -o $(CONFIGDIR)

SystemObjects.fm: $(APP).profile.pl $(KCONF_ROOT)/common/ciaoApp.scheme.pl $(CAM)
	$(CAM) $(APP).profile.pl $(KCONF_ROOT)/common/ciaoApp.scheme.pl SystemObjects.fm

$(APP).config: SystemObjects.fm $(APP).fm
	$(QCONF) $(APP).fm $(APP).config

