当前位置:网站首页>Generic kernel and userspace Makefiles
Generic kernel and userspace Makefiles
2022-08-11 06:16:00 【, as you like】
User space Makefile, save as a Makefile
TARGET:=mainSOURCE_FILES:=$(wildcard *.c)INCLUDE_FILES:=$(wildcard *.h)INCLUDE_FILES+=$(wildcard *.h)OBJ:=$(patsubst %.c, %.o, $(SOURCE_FILES))C_FLAGS:= -g -Wall -O2 \-fsanitize=addressLINK_MODULES:=-pthreadLDFLAGS := -L../out/lib/#LINK_MODULES += -lmodulename$(TARGET):$(OBJ)gcc $(C_FLAGS) $(LINK_MODULES) $(LDFLAGS) -o $(TARGET) $(OBJ)%.o:%.c $(INCLUDE_FILES)gcc $(C_FLAGS) -c -o [email protected] $<.PHONY:cleanclean:rm -f $(TARGET) $(OBJ)
The Makefile of the Kernel space, save it as a Makefile
CONFIG_MODULE_SIG=nobj-m := icdev.oCURRENT_PATH:=$(shell pwd)#the current kernel version numberLINUX_KERNEL:=$(shell uname -r)#the absolute pathLINUX_KERNEL_PATH:=/usr/src/linux-headers-$(LINUX_KERNEL)#complie objectall:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules #######cleanclean:make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean ######
Generic C++ Makefile with directory settings
########## Makefile COMMON #########c or c++EXTENSION =c#gcc or g++CC = gcc#exe nameTARGET = mpls_dump#source-file-direction space add-more-as: src src1 src2SUBDIR=file util.#.o file directionOBJ_DIR = out# (including .h file direction)#CPPFLAGS += -I ./incCPPFLAGS=-I.# link flagsLDFLAGS += -pthread# C flagsCFLAGS += -g -Wall -O2 \-fsanitize=address \-DHAVE_CONFIG_H#not change lines belowALL_SOURCES=$(foreach dir,$(SUBDIR), $(wildcard $(dir)/*.$(EXTENSION)))SOURCE_TO_OBJECT = ./$(OBJ_DIR)/$(subst .$(EXTENSION),.o,$(notdir $(1)))ALL_OBJECTS=$(foreach src,$(ALL_SOURCES),$(call SOURCE_TO_OBJECT,$(src)))define CREATE_OBJECT_TARGET$(call SOURCE_TO_OBJECT,$(1)) : $(1)if [ ! -d $(OBJ_DIR) ]; then mkdir -p $(OBJ_DIR); fi;\$(CC) -c $(CFLAGS) $(CPPFLAGS) -o [email protected] $$^endef$(TARGET):$(ALL_OBJECTS)$(CC) $(CFLAGS) $(LDFLAGS) -o [email protected] $^mv $(TARGET) $(OBJ_DIR)$(foreach src,$(ALL_SOURCES),$(eval $(call CREATE_OBJECT_TARGET,$(src))))all: $(TARGET).PHONY:cleanclean:rm -rf $(OBJ_DIR) $(TARGET)
边栏推荐
- windows下的redis安装及密码修改
- Thread Handler
- 通用的 kernel和 userspace Makefile
- 解决SmartRefreshLayout/SwipeRefreshLayout与RecyclerView下拉冲突的问题
- mysql 间隙锁(GAP-LOCK)演示
- LVS负载群集--DR模式
- 基于ijkplayer 0.8.8编译的完整so. libijkffmpeg.so等,支持ssl h265, rm, rmvb
- AI-based intelligent image recognition: 4 different industry applications
- NodeRed系列—创建mqtt broker(mqtt服务器),并使用mqttx进行消息发送验证
- LiDAR Snowfall Simulation for Robust 3D Object Detection
猜你喜欢
随机推荐
使用TD-workbench管理tDengine数据库数据
基于ijkplayer 0.8.8编译的完整so. libijkffmpeg.so等,支持ssl h265, rm, rmvb
GBase 8s中IO读写方法
emqx安装及mqttx连接使用
GBase 8s 执行计划查询分析
【高德地图】易采坑合集
GBase 8s集中式企业级安全事务型数据库
动画(其二)
NodeRed系列—创建mqtt broker(mqtt服务器),并使用mqttx进行消息发送验证
浙江大学软件学院2020年保研上机真题练习
解决Glide图片缓存问题,同一url换图片不起作用问题
Androd 基本布局(其一)
安全帽识别系统
Rethinking LiDAR Object Detection in adverse weather conditions
OSI TCP/IP学习笔记
Haproxy集群
华为adb wifi调试断线问题解决
Nodered系列—使用mqtt写入国产数据库tDengine
跳转到微信小程序方法
【sqlyog】【mysql】csv导入问题