avatar

松果工作室

欢迎光临

  • 首页
  • ESP
  • LVGL
  • freeRTOS
  • 快速笔记
  • 考察日志
  • 个人收藏
  • 我的服务
Home (Linux)Makefile 文件的编写
文章

(Linux)Makefile 文件的编写

Posted 2024-04-30 Updated 2024-04- 30
By YCP
3~4 min read

例子

#交叉编译工具链绝对路径,去掉首个 / 为相对路径
CC = /root/OpenWrt-Toolchain-ramips-for-mipsel_24kec+dsp-gcc-4.8-linaro_uClibc-0.9.33.2/toolchain-mipsel_24kec+dsp_gcc-4.8-linaro_uClibc-0.9.33.2/bin/mipsel-openwrt-linux-gcc

#编译目标文件
APP = myLn

#主函数入口文件
SOURCES = myLn.c

#头文件相对路径  
DEPENDS = 	Components/one.h \
			Components/two.h \
			Components/aes.h \
			Components/gps.h \
			Components/tcp.h \
			Components/data_process.h \
			Components/i2c_bmx055.h
#头文件目标文件相对路径
OBJS = 	Components/one.o \
		Components/two.o \
		Components/aes.o \
		Components/gps.o \
		Components/tcp.o \
		Components/data_process.o\
		Components/i2c_bmx055.o
#-I 后加相对头文件路径
INCLUDES = -IComponents

#动态链接库
LIBS	  = -lm -lpthread -ldl
CFLAGS = -std=c99

#[可执行文件]包括 :[头文件] [头文件编译目标] [主函数文件]
$(APP) :  $(DEPENDS) $(OBJS) $(SOURCES)

#用[GCC工具链] 把[主函数文件]编译成[可执行文件APP],同时应用[CFLAGS][CFLAGS][LIBS][INCLUDES][INCLUDES][OBJS]
$(CC) $(SOURCES) -o $(APP) $(CFLAGS) $(LIBS) $(INCLUDES) $(OBJS) 

PHONY: all clean
all: $(APP)

clean:
	rm -rf $(APP)
	rm -rf *.o Components/*.o
坑和笔记
Linux
License:  CC BY 4.0
Share

Further Reading

Sep 27, 2025

(LIB)一个好用的Modbus解析函数

一个好用的Modbus解析函数 包含03/10/04/06 #include <stdio.h> #include <stdint.h> #include <string.h> #

Jun 21, 2024

(LIB)环形滤波算法

#include <stdio.h> #include <stdlib.h> #define BUFFER_SIZE 10 // 缓冲区大小 #define THRESHOLD 180

Jun 17, 2024

(STM32)STM32 ADC采集的三种方式

采样周期 单个采集模式 ADC_Settings: 程序使用 uint16_t ADC_Read(

OLDER

(Elec)有一级低频放大的晶体管收音机

NEWER

(Elec)能选电台的收音机

Recently Updated

  • (ESP-IDF)LVGL 模拟器
  • (ESP-IDF)LVGL 自定义对象加入编码器组
  • (ESP-IDF)vscode配置文件
  • (Elec)来复再生式晶体管单管收音机
  • (ESP-IDF)ESPNOW

Trending Tags

LVGL WCH Linux Elec ThatProject freeRTOS STM ESP Flutter Others

Contents

©2026 松果工作室. Some rights reserved.

Using the Halo theme Chirpy