makefile将⽣成的⽬标⽂件和可执⾏⽂件存放在指定的⽬录下.PHONY: all clean
CC = gcc
RM = rm
MKDIR = mkdir
CFLAGS = -Wall -std=gnu99
INC = -I ../include/hh_include
DIR_OBJS = ../obj
DIR_EXEC = ../exec
DIRS := $(DIR_OBJS) $(DIR_EXEC)
EXEC = prin
SRCS = $(wildcard *.c)
OBJS = $(SRCS:.c=.o)
OBJS := $(addprefix $(DIR_OBJS)/,$(OBJS))
EXEC := $(addprefix $(DIR_EXEC)/,$(EXEC))
makefile phonyall: $(DIRS) $(EXEC)
$(DIRS):
$(MKDIR) $@
$(EXEC):$(OBJS)
$(CC) -o $@ $^
$(DIR_OBJS)/%.o:%.c
$(CC) $(CFLAGS) $(INC) -o $@ -c $^
clean:
$(RM) -rf $(DIRS) $(EXEC)
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论