最简单版示例:
smsh1:smsh1.o splitline.o execute.o
gcc -o smsh1 smsh1.o splitline.o execute.o
smsh1.o:smsh1.c smsh.h
gcc -c -g smsh1.c
splitline.o:splitline.c smsh.h
gcc -c -g splitline.c
execute.o:execute.c
gcc -c -g execute.c
clean:
rm -f smsh1 smsh1.o splitline.o execute.o
复杂一点点的:
CC=gcc
TARGET=smsh1
RM=rm -f
OBJS=smsh1.o splitline.o execute.o
$(TARGET):$(OBJS)
$(CC) -o $(TARGET) $(OBJS)
$(OBJS):%.o:%.c
$(CC) -c -g $< -o $@
clean:
-$(RM) $(TARGET) $(OBJS)
编写makefile的一些规则;
待添加~~~