diff --git a/hi/Makefile b/hi/Makefile new file mode 100644 index 0000000..5004d0c --- /dev/null +++ b/hi/Makefile @@ -0,0 +1,40 @@ +# 导入通用编译规则 +include $(TOPDIR)/rules.mk + +# name和version用来定义编译目录名$(PKG_BUILD_DIR)] +PKG_NAME:=hellwworld2 +PKG_VERSION:=1.0 +PKG_RELEASE:=1 +#PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME) # 也可以直接定义编译目录名,代替默认的目录名 + +# 导入包定义 +include $(INCLUDE_DIR)/package.mk + +# 包定义:定义我们的包在menuconfig中的位置 +# Makefile中的define语法可以理解为函数,用于定义命令集合 +define Package/hellwworld2 + SECTION:=examples + CATEGORY:=Examples + TITLE:=hellwworld2, learn from example. +endef + +# 包描述:关于我们包的更详细的描述 +define Package/hellwworld2/description + A simple hellwworld2 example, my first openwrt package example. +endef + +# 编译准备. 必须使用tab缩进,表示是可执行的命令 +define Build/Prepare + echo "Here is Build/Prepare" + mkdir -p $(PKG_BUILD_DIR) + cp ./src/* $(PKG_BUILD_DIR)/ +endef + +# 安装 +define Package/hellwworld2/install + $(INSTALL_DIR) $(1)/usr/bin + $(INSTALL_BIN) $(PKG_BUILD_DIR)/hellwworld2 $(1)/usr/bin +endef + +# 这一行总是在最后 +$(eval $(call BuildPackage,hellwworld2)) diff --git a/hi/src/Makefile b/hi/src/Makefile new file mode 100644 index 0000000..6ede6e0 --- /dev/null +++ b/hi/src/Makefile @@ -0,0 +1,12 @@ +TARGET = hellwworld2 +OBJS = hellwworld2.o + +$(TARGET):$(OBJS) + $(CC) $(LDFLAGS) -o $@ $^ + +%.o: %.c + $(CC) $(CFLAGS) -c $< -o $@ + +.PHONY: clean +clean: + rm -f $(TARGET) $(OBJS) diff --git a/hi/src/helloworld2.c b/hi/src/helloworld2.c new file mode 100644 index 0000000..cdb6b0a --- /dev/null +++ b/hi/src/helloworld2.c @@ -0,0 +1,8 @@ +#include + +int main(void) +{ + long l = 0x10001010; + printf("\nHello, world! %ld\n\n", l); + return 0; +} \ No newline at end of file