make clean,mrproper,distclean

本文介绍了三种清理编译环境的方法:makeclean用于删除构建外部模块时不需要的文件;makemrproper用于删除所有生成的文件,包括.config文件;makedistclean则用于删除所有临时文件,如*.orig和*~等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

make clean - delete everything not needed for building external modules
make mrproper - delete all generated files, including .config
make distclean - delete all temporary files such as *.orig, *~, *.rej etc.

#!/bin/bash set -e # 遇到错误立即退出 # ******************** 用户配置区域 ******************** UBOOT_SOURCE_DIR="/path/to/uboot/source" # 替换为实际U-Boot源码路径 KERNEL_SOURCE_DIR="/path/to/kernel/source" # 替换为实际Kernel源码路径 OUTPUT_DIR="/path/to/output" # 输出目录 UBOOT_TARGET_NAME="u-boot.elf" # 重命名后的U-Boot文件名 # ***************************************************** # 创建输出目录(如果不存在) mkdir -p "$OUTPUT_DIR" # 编译U-Boot函数 compile_uboot() { echo "===== 开始编译U-Boot =====" cd "$UBOOT_SOURCE_DIR" || exit 1 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- -j$(nproc) if [ ! -f u-boot ]; then echo "错误:u-boot文件未生成!" exit 1 fi mv u-boot "$UBOOT_TARGET_NAME" cp -v "$UBOOT_TARGET_NAME" "$OUTPUT_DIR" echo "===== U-Boot编译完成 =====" } # 编译Kernel函数 compile_kernel() { echo "===== 开始编译Kernel =====" cd "$KERNEL_SOURCE_DIR" || exit 1 make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- zImage dtbs -j$(nproc) if [ ! -f arch/arm/boot/zImage ] || [ ! -f arch/arm/boot/dts/*.dtb ]; then echo "错误:内核镜像或dtb文件未生成!" exit 1 fi cp -v arch/arm/boot/zImage "$OUTPUT_DIR" cp -v arch/arm/boot/dts/*.dtb "$OUTPUT_DIR" echo "===== Kernel编译完成 =====" } # 清理U-Boot编译结果 clean_uboot() { echo "===== 清理U-Boot编译结果 =====" cd "$UBOOT_SOURCE_DIR" || exit 1 # 根据实际需求选择清理命令(make clean / make distcleanmake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- distclean echo "已清理U-Boot编译文件" } # 清理Kernel编译结果 clean_kernel() { echo "===== 清理Kernel编译结果 =====" cd "$KERNEL_SOURCE_DIR" || exit 1 # 根据实际需求选择清理命令(make clean / make mrpropermake ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- mrproper echo "已清理Kernel编译文件" } # 参数处理逻辑 case $1 in uboot|u) compile_uboot ;; kernel|k) compile_kernel ;; all|a) compile_uboot compile_kernel ;; clean_uboot|cu) clean_uboot ;; clean_kernel|ck) clean_kernel ;; clean_all|ca) clean_uboot clean_kernel echo "===== 已清理所有编译文件 =====" ;; *) echo "用法: $0 [command]" echo "可用命令:" echo " 编译:" echo " uboot|u # 编译U-Boot" echo " kernel|k # 编译Kernel" echo " all|a # 编译全部" echo " 清理:" echo " clean_uboot|cu # 清理U-Boot" echo " clean_kernel|ck # 清理Kernel" echo " clean_all|ca # 清理全部" exit 1 ;; esac
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值