⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 makefile

📁 cygwin下的包含各种c基本操作的demo程序
💻
字号:
AS = 
AFLAGS = 
CC = gcc
CFLAGS = -g 
OBJDUMP = objdump
DUMFLAGS = -S 
LD = ld
LDFLAGS = -r -o
SRCS = $(wildcard *.c)
#OBJS = $(patsubst %.c ,%.o , $(SRCS)) #error: the space between .c and , leads to fatel error
OBJS = $(patsubst %.c,%.o, $(SRCS) )
HEADS = $(wildcard *.h)
#OBJS = $(patsubst %.c,%.o, $(wildcard *.c) )
O_TARGET = c.o



all:  pre_echo $(OBJS) $(O_TARGET) test_echo 

%.o:%.c
	$(CC) $(CFLAGS) -c $< 

    
#include rules.make

$(O_TARGET): $(OBJS)					#rules to compile a set of .o files into one .o files
	$(LD) $(LDFLAGS) $@ b.o a.o			

.PHONY: pre_echo
pre_echo:
	@echo "head files are $(HEADS)"
	
.PHONY: test_echo
test_echo:
	@echo "objs files are: $(O_TARGET) "
	@echo "srcs files are: $(SRCS) "	
	gcc -o test test.o c.o
	@echo ".................. done"
	
clean:
	-rm -f *.o *.exe
	 
ifdef for_demo
demo:			#shoule not be here for this Makefile ,just to demostrate the rules
## Rule to compile a set of .o files into one .o file#ifdef O_TARGET$(O_TARGET): $(obj-y)	rm -f $@    ifneq "$(strip $(obj-y))" ""	$(LD) $(LDFLAGS) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)    else	$(AR) rcs $@    endif	@ ( \	    echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \	    echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \	    echo 'endif' \	) > $(dir $@)/.$(notdir $@).flagsendif # O_TARGET## Rule to compile a set of .o files into one .a file#ifdef L_TARGET$(L_TARGET): $(obj-y)	rm -f $@	$(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)	@ ( \	    echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \	    echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \	    echo 'endif' \	) > $(dir $@)/.$(notdir $@).flagsendif

endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -