ZDClient加入到OpenWrt

之前的Makefile总是碰到iconv.h not found的错误,后来找到另一个Makefile就好了,原因还没有分析出来。


错误的Makefile

include $(TOPDIR)/rules.mk
PKG_NAME:=zdclient
PKG_VERSION:=1.0
PKG_RELEASE:=1
PKG_BUILD_DIR:= $(BUILD_DIR)/$(PKG_NAME)
include $(INCLUDE_DIR)/nls.mk
include $(INCLUDE_DIR)/package.mk
define Package/zdclient
        SECTION:=utils
        CATEGORY:=Utilities
        TITLE:=zdclient
        DEPENDS:=+libpcap +libstdcpp +libiconv-full +libintl-full
endef
define Package/$(PKG_NAME)/description
        zdclient
endef
define Build/Prepare
        mkdir -p $(PKG_BUILD_DIR)
        $(CP) ./src/* $(PKG_BUILD_DIR)/
endef
define Package/zdclient/install
        $(INSTALL_DIR) $(1)/bin
        $(INSTALL_BIN) $(PKG_BUILD_DIR)/zdclient $(1)/bin/
endef
$(eval $(call BuildPackage,$(PKG_NAME)))

正确的Makefile

include $(TOPDIR)/rules.mk

PKG_NAME:=zdcclient

PKG_RELEASE:=1.2

PKG_FIXUP:=autoreconf
PKG_INSTALL:=1

include $(INCLUDE_DIR)/package.mk

define Package/$(PKG_NAME)
  
  SECTION:=Utilities
  CATEGORY:=Utilities
  SUBMENU:=AOS
  DEPENDS:=+libpcap +libstdcpp
  TITLE:=shenzhoushuma 802.1x  supplicant  client
 
endef

define Package/$(PKG_NAME)/description
	山寨版的神州数码802.1x认证supplicant,基于pcap库的C语言的跨平台的原生客户端。
endef

define Build/Prepare
	mkdir -p $(PKG_BUILD_DIR)
	$(CP) ./src/* $(PKG_BUILD_DIR)/
endef

define Build/Compile
	#$(Build/Compile/$(PKG_NAME))
	$(MAKE) -C $(PKG_BUILD_DIR)/ \
		$(TARGET_CONFIGURE_OPTS) \
		CFLAGS="$(TARGET_CFLAGS)" \
		CPPFLAGS="$(TARGET_CPPFLAGS)"  \
		LIBS="$(STAGING_DIR)/usr/lib/libpcap.a"
endef

define Package/$(PKG_NAME)/install
	$(INSTALL_DIR) $(1)/usr/bin
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/zdclient $(1)/usr/bin/
	$(INSTALL_BIN) $(PKG_BUILD_DIR)/runzdclient $(1)/usr/bin/
endef

$(eval $(call BuildPackage,$(PKG_NAME)))

附上src目录中的Makefile

TARGET = zdclient
BIN_DIR = /usr/bin/
INCLUDES = 

C_SOURCES       = $(wildcard *.c)
C_OBJS = $(patsubst %.c, %.o, $(C_SOURCES))

# ------------  generate the names of the object files  ------------------------
OBJECTS         = $(addsuffix .o,$(BASENAMES))

# ------------  generate the names of the hidden prerequisite files  -----------
PREREQUISITES   = $(addprefix .,$(addsuffix .d,$(BASENAMES)))

# ------------  make the executable (the default goal)  ------------------------
%.o:%.c
	$(CC) -c $<$ $(CCFLAGS)

$(TARGET): $(CPP_OBJS) $(C_OBJS)
	$(CXX)$(LINKFLAGS) -o $(TARGET) $^ $(LIBS)

all:$(TARGET)


你可能感兴趣的:(ZDClient加入到OpenWrt)