+define add_feature
+ @echo "$(if $(findstring 1,$($(1))),#define UCI_$(1) 1,#undef UCI_$(1))" >> $@.tmp
+endef
+
+define add_dep
+$(1).shared.o: $(2)
+$(1).static.o: $(2)
+endef
+
+SOURCES = libuci.c file.c ucimap.c util.c
+
+all: uci libuci.$(SHLIB_EXT) uci-static ucimap-example
+
+$(eval $(call add_dep,libuci,delta.c list.c uci.h uci_config.h uci_internal.h))
+$(eval $(call add_dep,ucimap,uci.h uci_config.h ucimap.h))
+
+cli.o: cli.c uci.h uci_config.h
+
+uci_config.h: FORCE
+ @rm -f "$@.tmp"
+ @echo "#define UCI_PREFIX \"$(prefix)\"" > "$@.tmp"
+ $(call add_feature,PLUGIN_SUPPORT)
+ $(call add_feature,DEBUG)
+ $(call add_feature,DEBUG_TYPECAST)
+ @if [ \! -f "$@" ] || ! cmp "$@.tmp" "$@" >/dev/null; then \
+ mv "$@.tmp" "$@"; \
+ else \
+ rm -f "$@.tmp"; \
+ fi