当前位置: 技术问答>linux和unix
提问一个makefile最简单的问题
来源: 互联网 发布时间:2015-11-22
本文导语: 结构组织如下: 在DEBUG文件夹下有:DEBUG.c DEBUG.h 在MAIN文件夹下有:MAIN.c MAIN.h makefile MAIN.c文件包含了DEBUG.h: #include "../DEBUG.h" #include "MAIN.h" makefile: # # Include the gcc dir # CROSS_COMPILE = # # Include...
结构组织如下:
在DEBUG文件夹下有:DEBUG.c DEBUG.h
在MAIN文件夹下有:MAIN.c MAIN.h makefile
MAIN.c文件包含了DEBUG.h:
#include "../DEBUG.h"
#include "MAIN.h"
makefile:
#
# Include the gcc dir
#
CROSS_COMPILE =
#
# Include the make variables (CC, etc...)
#
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
VPATH = ../DEBUG
#
# Define the var
#
exec = a_exec.exe
objects = mE_MAIN.o mE_DEBUG.o
$(exec) : $(objects)
$(CC) -o $(exec) $(objects)
$(objects) : %.o : %.c
$(CC) -c $
在DEBUG文件夹下有:DEBUG.c DEBUG.h
在MAIN文件夹下有:MAIN.c MAIN.h makefile
MAIN.c文件包含了DEBUG.h:
#include "../DEBUG.h"
#include "MAIN.h"
makefile:
#
# Include the gcc dir
#
CROSS_COMPILE =
#
# Include the make variables (CC, etc...)
#
AS = $(CROSS_COMPILE)as
LD = $(CROSS_COMPILE)ld
CC = $(CROSS_COMPILE)gcc
AR = $(CROSS_COMPILE)ar
NM = $(CROSS_COMPILE)nm
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
VPATH = ../DEBUG
#
# Define the var
#
exec = a_exec.exe
objects = mE_MAIN.o mE_DEBUG.o
$(exec) : $(objects)
$(CC) -o $(exec) $(objects)
$(objects) : %.o : %.c
$(CC) -c $