今天学习makefile小有成就,特贴于此,永久留念。
#!/bin/sh
objects := hello.o
objects += lhg-hello.o
objects += mx-hello.o
out = hello
all:$(objects)
@echo "正在编译...."
cc $(objects) -o $(out)
@echo "运行"$(out)"...."
@./$(out)
$(objects):%.o:%.c
cc -c $< -o $@
.PHONY: clean
clean:
-rm -f $(out) $(objects)