[Makefile]多文件的通用Makefile
下面是一个糅合多线程和多文件的示例
emc-test.c
#include <stdio.h>
#include <pthread.h>
#include "charge-test.h"
#include "rs485-test.h" pthread_mutex_t mutex;
pthread_cond_t cond; int main()
{
pthread_t thread1, thread2; pthread_mutex_init(&mutex, NULL);
pthread_cond_init(&cond, NULL); pthread_create(&thread1, NULL, (void*)thread1_rs485, NULL);
pthread_create(&thread2, NULL, (void*)thread2_charge, NULL); do{
pthread_cond_signal(&cond);
}while(); sleep();
pthread_exit(); return ;
}
emc-test.h
#ifndef __EMC_TEST_H
#define __EMC_TEST_H #endif
charge-test.c
#include <stdio.h>
#include <pthread.h>
#include "charge-test.h" void *thread2_charge(void *arg)
{ }
charge-test.h
#ifndef __CHARGE_TEST_H
#define __CHARGE_TEST_H void *thread2_charge(void *arg); #endif
rs485-test.c
#include <stdio.h>
#include <pthread.h>
#include "rs485-test.h" void *thread1_rs485(void *arg)
{ }
rs485-test.h
#ifndef __RS485_H
#define __RS485_H void *thread1_rs485(void *arg); #endif
Makefile
CC=gcc #arm-linux-gnueabihf-gcc
CFLAGS=-Wall TARGET=emc-test
SRCS=$(wildcard *.c)
OBJS=$(SRCS:.c=.o)
#$(shell echo $(OBJS) > a.txt) ${TARGET}:${OBJS}
$(CC) $(OBJS) -pthread -o $@ clean:
rm -rf $(TARGET) $(OBJS) *.o *~ %.o:%.c %.h
$(CC) -c $< -o $@
[Makefile]多文件的通用Makefile的更多相关文章
- 【linux】-Makefile简要知识+一个通用Makefile
目录 Makefile Makefile规则与示例 为什么需要Makefile Makefile样式 先介绍Makefile的两个函数 完善Makefile 通用Makefile的使用 通用的Make ...
- Makefile.am文件配置
Makefile.am Makefile.am是一种比Makefile更高层次的编译规则,可以和configure.in文件一起通过调用automake命令,生成Makefile.in文件,再调用./ ...
- Makefile.am文件的实例讲解
Makefile.am是一种比Makefile更高层次的编译规则,可以和configure.in文件一起通过调用automake命令,生成Makefile.in文件,再调用./configure的时候 ...
- Makefile之文件搜索
Makefile之文件搜索 1.Makefile 文件中的"VPATH"变量 如果没有指明这个变量,make只会在当前目录下查找依赖文件和目标文件: 如果定义了这个变量,make会 ...
- Makefile学习与进阶之Makefile.am和$$(M)的意思
(1)makefile 中,出现$$(M) 是什么意思,发现还是看实际的Makefile长知识啊 在makefile中,会经常使用shell命令,也经常见到$var 和 $$var的情况,有什么区别呢 ...
- Linux C编程学习之开发工具3---多文件项目管理、Makefile、一个通用的Makefile
GNU Make简介 大型项目的开发过程中,往往会划分出若干个功能模块,这样可以保证软件的易维护性. 作为项目的组成部分,各个模块不可避免的存在各种联系,如果其中某个模块发生改动,那么其他的模块需要相 ...
- 一个简单的通用Makefile实现
一个简单的通用Makefile实现 Makefile是Linux下程序开发的自动化编译工具,一个好的Makefile应该准确的识别编译目标与源文件的依赖关系,并且有着高效的编译效率,即每次重新ma ...
- 代码片段--Makefile之大型工程项目子目录Makefile的一种通用写法
转载:http://blog.csdn.net/mo_hui123456/article/details/8929615 管理Linux环境下的C/C++大型项目,如果有一个智能的Build Syst ...
- 通用Makefile
本文推荐了一个用于对 C/C++ 程序进行编译和连接以产生可执行程序的通用 Makefile. 在使用 Makefile 之前,只需对它进行一些简单的设置即可:而且一经设置,即使以后对源程序文件有所增 ...
随机推荐
- define() vs const 该如何选择?
使用 define(),除非考虑到可读性.类常量.或关注微优化 1.在 PHP 中是使用 define() 函数来定义常量,PHP 5.3.0 以后,PHP 中也能够使用 const 关键字来声明常量 ...
- 理解Lucene中的Analyzer
学习一个库,最好去官网.因为很多库API变动十分大,从博客上找的教程都过时了. Lucene原理就是简简单单的"索引",以空间换时间.但是Lucene将这件事做到了极致,后人再有想 ...
- shell脚本条件判断
http://blog.csdn.net/ws_zll/article/details/7515310
- struts2 xml配置文件配置传参数
传参方式 重定向 第一方式: <action name="search" method="search" class="c ...
- python学习笔记011——内置函数dir()
1 描述 dir()函数可以查看(打印)对象的属性和方法.不管时那种对象(python中一切皆对象)类型(数据,模块)都有自己的属性和方法. dir() 函数不带参数时,返回当前范围内的变量.方法和定 ...
- python解压压缩包的几种方法
这里讨论使用Python解压例如以下五种压缩文件: .gz .tar .tgz .zip .rar 简单介绍 gz: 即gzip.通常仅仅能压缩一个文件.与tar结合起来就能够实现先打包,再压缩. ...
- CXF+Spring+JAXB+Json构建Restful服务
话不多说,先看详细的样例: 文件文件夹结构: web.xml <?xml version="1.0" encoding="UTF-8"? > < ...
- win7下安装ubuntu双系统的方法及心得体会(ps:要死好几回的节奏)
1.win7下安装ubuntu系统后,可以很好进入ubuntu系统 但是进不去win7,开机有win7选项,但是选择后不管用 方法思路:各种修复win7的mbr 我的问题是:在winpe中发现,根本看 ...
- struts2.xml中所有constant详解--大全
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE struts PUBLIC "-/ ...
- git 录制简单实用好工具 LICEcap
官网 https://www.cockos.com/licecap/ 界面如图: 录制效果如下: