程序:
include scripts/Makefile
modules_make = $(MAKE) -C $(1);
modules_clean = $(MAKE) clean -C $(1);
.PHONY: all mm mc clean
all: $(Target)
mm:
@ $(foreach n,$(Modules),$(call modules_make,$(n)))
mc:
@ $(foreach n,$(Modules),$(call modules_clean,$(n)))
$(Target) : mm
$(CC) $(CFLAGS) -o $(Target) $(AllObjs) $(Libs)
@ echo $(Target) make done!
clean : mc
rm -rf $(Target)
@ echo clean done!
include ../scripts/Makefile
all : $(Objs)
clean :
rm -rf $(Objs)
CC := gcc
CFLAGS := -Wall -O3
Libs = -lpthread
Target := client
Source := $(wildcard src/*.c)
Objs := $(patsubst %.c,%.o,$(Source))
Modules += add sub mul div main
AllObjs := $(addsuffix /src/*.o,$(Modules))
int add(int a, int b)
{
return a + b;
}
int div(int a, int b)
{
return a / b;
}
int mul(int a, int b)
{
return a * b;
}
int sub(int a, int b)
{
return a - b;
}
#include<stdio.h>int main()
{
printf("add = %d\n",add(6,3));
printf("sub = %d\n",sub(6,3));
printf("mul = %d\n",mul(6,3));
printf("div = %d\n",div(6,3));
return 0;
}
今日学习任务 | 1,调试器gdb的介绍和简单使用 2,熟练掌握 makefile 基本语法的使用 3,企业级 makefile 的编写 |
今日任务完成情况 | 基本完成今日任务 1,初步掌握了makefilede 的使用 2,学习了调试器gdb的的使用 3,掌握了gdb部分操作命令 |
今日开发中出现的问题汇总 | 1,对makefile语法三要素掌握不精 2,编写makefile时没有熟练掌握相关语句的使用, 经常出现一些问题,从而导致编写效率较低 |
今日未解决问题 | 无 |
今日开发收获 | 了解了gdb的三大功能,并对gdb有了初步掌握; 了解了makefile管理代码的高效性; 学会了编写makefile文件 |
自我评价 | 今天相比昨天,感觉上课的内容难度加大, 未能全部掌握老师所讲的知识点,尤其是在Makefile这块, 尽管了解大致的操作流程,但在细微操作中,还是不熟练,有点欠缺, 需要自己多加巩固练习。 |
其他 | 无 |