-$(IPKG_MTD):
- install -d -m0755 $(IDIR_MTD)/sbin
- install -m0755 $(PKG_BUILD_DIR)/mtd $(IDIR_MTD)/sbin
- $(RSTRIP) $(IDIR_MTD)/sbin/*
- $(IPKG_BUILD) $(IDIR_MTD) $(PACKAGE_DIR)
+target=$(firstword $(subst -, ,$(BOARD)))
+
+define Build/Compile
+ $(MAKE) -C $(PKG_BUILD_DIR) \
+ $(TARGET_CONFIGURE_OPTS) \
+ TARGET=$(target) \
+ CFLAGS="$(TARGET_CFLAGS) -Dtarget_$(target)=1 -Wall"
+endef
+
+define Package/mtd/install
+ $(INSTALL_DIR) $(1)/sbin
+ $(INSTALL_BIN) $(PKG_BUILD_DIR)/mtd $(1)/sbin/
+endef
+
+$(eval $(call BuildPackage,mtd))