me icon indicating copy to clipboard operation
me copied to clipboard

学习 C/C++ (Part 15: Makefile multiply target)

Open nonocast opened this issue 2 years ago • 0 comments

Makefile

CC=clang
ARCH=x86_64
CFLAGS=`pkg-config --cflags librtmp`
LDFLAGS=`pkg-config --libs librtmp`
SRC=src
BUILD=build
PROG=$(BUILD)/dump $(BUILD)/read

all: $(BUILD) $(PROG)

$(BUILD)/dump: $(SRC)/dump.c
	@$(CC) -arch $(ARCH) $(CFLAGS) $(LDFLAGS) -o $@ $<

$(BUILD)/read: $(SRC)/read.c
	@$(CC) -arch $(ARCH) $(CFLAGS) $(LDFLAGS) -o $@ $<

$(BUILD):
	@mkdir -p $@

run-dump: $(BUILD)/dump
	$(BUILD)/dump -o out.flv rtmp://shgbit.xyz/live/1

run-read: $(BUILD)/read
	@$(BUILD)/read

# alias
run: run-read

clean:
	@rm -rf build

.PHONY: all clean
  • 直接参考linus/git的Makefile即可
  • 如果target多就可以采用%通配符

nonocast avatar May 15 '22 20:05 nonocast