# Lines starting with the pound sign are comments.
#
# This is one of two options you might need to tweak.
EXECUTABLE = myprogram
# You can modify the below as well, but probably
# won't need to.
#
# CC is for the name of the C compiler. CPPFLAGS denotes pre-processor
# flags, such as -I options. CFLAGS denotes flags for the C compiler.
# CXXFLAGS denotes flags for the C++ compiler. You may add additional
# settings here, such as PFLAGS, if you are using other languages such
# as Pascal.
CC = gcc
CPPFLAGS =
CFLAGS = -Wall -O2
CXXFLAGS = $(CFLAGS)
COMPILE = $(CC) $(CPPFLAGS) $(CFLAGS) -c
SRCS := $(wildcard *.c)
OBJS := $(patsubst %.c,%.o,$(SRCS))
DEPS := $(patsubst %.c,%.d,$(SRCS))
DIRS= input format
# "all" is the default target. Simply make it point to myprogram.
all: $(EXECUTABLE)
subdirs:
@for dir in $(DIRS); do $(MAKE) -C $$dir; done
# Define the components of the program, and how to link them together.
# These components are defined as dependencies; that is, they must be
# made up-to-date before the code is linked.
$(EXECUTABLE): subdirs $(DEPS) $(OBJS)
$(CC) -o $(EXECUTABLE) $(OBJS)
# Specify that the dependency files depend on the C source files.
%.d: %.c
$(CC) -M $(CPPFLAGS) $< > $@
$(CC) -M $(CPPFLAGS) $< | sed s///.o/.d/ >> $@
# Specify that all .o files depend on .c files, and indicate how
# the .c files are converted (compiled) to the .o files.
%.o: %.c
$(COMPILE) -o $@ $<
clean:
-rm $(OBJS) $(EXECUTABLE) $(DEPS) *~
@for dir in $(DIRS); do $(MAKE) -C $$dir clean; done
explain:
@echo "The following information represents your program:"
@echo "Final executable name: $(EXECUTABLE)"
@echo "Source files: $(SRCS)"
@echo "Object files: $(OBJS)"
@echo "Dependency files: $(DEPS)"
@echo "Subdictionary: $(DIRS)"
depend: $(DEPS)
@for dir in $(DIRS); do $(MAKE) -C $$dir; done
@echo "Dependencies are now up-to-date."
-include $(DEPS)
|
相关推荐
Linux下Makefile教程,结合实例详细介绍Linux下的Makefile编写规则和技巧,欢迎下载。
Makefile模式当几个BSD用户尝试我的一个项目时告诉我他们无法构建我的项目时,我只是在想一些更高级的Gnu制作技巧。这个缺点激发了我重新思考自己的方法。那么,这个项目就是我记录成功想法的地方,以便以后找到它们...
Makefile linux 帮助你快速掌握Makefile编写规则与技巧,
文档中详细讲解了makefile组织结构和编写技巧,阅读后便可对makefile有一个全面的了解,不仅能够很好理解makefile,还能编写简单实用的makefile。
linux中学习makefile;掌握makefile基本语法和一些常用技巧;
附带一些多目录makefile编写技巧
makefile教程,主要介绍makefile的基本概念和相关的使用技巧
详细的讲解makefile的资料,快速全面掌握使用技巧和方法
linux编程小技巧,linux下C语言编程,makefile编写
很详细的makefile编写指南。其中涵盖各种编写技巧和规则。
综合运用Makefile工程管理的技巧操作。 1.3步骤及现象 Makefile 工程管理 1、实验要求: 使用Makefile完成对一个含有多个文件的程序的编译。 2、实验器材: 软件: 安装了ubuntu的VMware虚拟机。 硬件: ...
用法、技巧。它会为你在 下的工程开发、工程管理提供非常有用的帮助。 此中文文档当前版本 本文的所有勘误和最新版本可在主 页 上获取!! 谢谢! 徐海兵 年月日 中文于册 第一章:概述 概既述 环境下的程序员如果不会...
其中,Linux嵌入式开发部分介绍了如何搭建环境、交叉编译、制作根文件系统等实用技巧,帮助读者快速上手嵌入式开发领域。 而该文档中的C语言部分则详细介绍了基本数据类型、指针、结构体、函数、预处理等内容,并...
展讯 平台环境 搭建 Makefile 工作流程 第三方编译选项说明 相关使用技巧等等
使用方法: 1.解压在linux文件下 2.用你的codeblock打开里面有个cbp2make.cbp然后编译 3.如果你经常要用就在你的解压文档下打开terminal,然后命令 sudo cp ./bin/Release/cbp2make /usr/local/bin/ 4. 要生成...
在本次课程设计中,设计的目的就是在Linux系统环境下,使用makefile文件的方式,使用C语言编写出手机缴费系统。要求系统必须具有增查...在本次课程设计中,要求同学们掌握使用Linux系统、C语言做系统设计步骤和技巧。
作为一个Linux程序员,make工具的使用以及编写Makefile是必需的。系统、详细讲述make的中文资料比较少,出于对广大中文Linuxer的支持,本人在工作之余,花了18个多月时间完成对“info make”的翻译整理,完成这个...
阅读本文的几点建议: 1. 如果之前你对GNU make 没有了解、当前也不想深入的学习GNU make 的读者。 可只阅读本文各章节前半部分的内容(作为各...技巧。它会为你在Linux 下的工程开发、工程管理提供非常有用的帮助。