$(src)/../us_manager/Module.symvers \
$(src)/../driver/Module.symvers
+
+
+
+
+###############################################################################
+### swap energy module description ###
+###############################################################################
obj-m := swap_energy.o
swap_energy-y := energy_module.o \
energy.o \
lcd/lcd_base.o
+
+
+
+###############################################################################
+### description register functions ###
+###############################################################################
+REG_ARGS := void
+REG_RET := void
+
+
+
+
+
+###############################################################################
+### description unregister functions ###
+###############################################################################
+UNREG_ARGS := void
+UNREG_RET := void
+
+
+
+
+
+###############################################################################
+### math support ###
+###############################################################################
# S6E8AA0:
ifeq ($(CONFIG_LCD_S6E8AA0), y)
swap_energy-y += lcd/s6e8aa0.o
- EXTRA_CFLAGS += -DCONFIG_ENEGRGY_LCD
+
+ REG_FUNC_LIST += s6e8aa0_register
+ UNREG_FUNC_LIST += s6e8aa0_unregister
endif
# MARU:
ifeq ($(CONFIG_MARU_BACKLIGHT), y)
swap_energy-y += lcd/maru.o
- EXTRA_CFLAGS += -DCONFIG_ENEGRGY_LCD
+
+ REG_FUNC_LIST += maru_register
+ UNREG_FUNC_LIST += maru_unregister
endif
+
+
+
+
+
+###############################################################################
+### generate defines for un/register functions ###
+###############################################################################
+EMPTY :=
+SPACE := $(EMPTY) $(EMPTY)
+COMMA := ,
+
+
+
+
+
+###############################################################################
+### generate defines for register functions ###
+###############################################################################
+TMP := ($(REG_ARGS));
+DEFINITION_REG_FUNC := DEFINITION_REG_FUNC=$(foreach it, $(REG_FUNC_LIST), "extern" $(REG_RET) $(it)$(TMP))
+
+ifeq (void,$(REG_ARGS))
+ REG_ARGS :=
+endif
+
+TMP := $(subst $(SPACE),$(EMPTY),$(REG_ARGS)) # remove space
+TMP := $(subst $(COMMA), ,$(TMP)) # replace ',' --> ' '
+LAST := $(words $(TMP))
+
+TMP := $(shell seq 1 $(LAST))
+TMP := $(foreach it, $(TMP), "X"$(it))
+TMP := $(strip $(TMP))
+TMP := $(subst $(SPACE),$(COMMA),$(TMP)) # replace ' ' --> ','
+TMP := $(strip $(TMP))
+
+REG_ARG_LIST := $(TMP)
+TMP := ($(REG_ARG_LIST));
+
+CALL_REG_FUNC := REGISTER_ALL_FUNC($(REG_ARG_LIST))={$(foreach it, $(REG_FUNC_LIST), $(it)$(TMP))}
+
+
+
+
+
+###############################################################################
+### generate defines for unregister functions ###
+###############################################################################
+TMP := ($(UNREG_ARGS));
+DEFINITION_UNREG_FUNC := DEFINITION_UNREG_FUNC=$(foreach it, $(UNREG_FUNC_LIST), "extern" $(UNREG_RET) $(it)$(TMP))
+
+ifeq (void, $(UNREG_ARGS))
+ UNREG_ARGS :=
+endif
+
+TMP := $(subst $(SPACE),$(EMPTY),$(UNREG_ARGS)) # remove space
+TMP := $(subst $(COMMA), ,$(TMP)) # replace ',' --> ' '
+LAST := $(words $(TMP))
+
+TMP := $(shell seq 1 $(LAST))
+TMP := $(foreach it, $(TMP), "X"$(it))
+TMP := $(strip $(TMP))
+TMP := $(subst $(SPACE),$(COMMA),$(TMP)) # replace ' ' --> ','
+TMP := $(strip $(TMP))
+
+UNREG_ARG_LIST := $(TMP)
+TMP := ($(UNREG_ARG_LIST));
+
+CALL_UNREG_FUNC := UNREGISTER_ALL_FUNC($(UNREG_ARG_LIST))={$(foreach it, $(UNREG_FUNC_LIST), $(it)$(TMP))}
+
+
+
+
+
+###############################################################################
+### add generate defines to EXTRA_CFLAGS ###
+###############################################################################
+EXTRA_CFLAGS += -D"$(DEFINITION_REG_FUNC)" \
+ -D"$(CALL_REG_FUNC)" \
+ -D"$(DEFINITION_UNREG_FUNC)" \
+ -D"$(CALL_UNREG_FUNC)"