-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (48 loc) · 1.42 KB
/
Copy pathMakefile
File metadata and controls
60 lines (48 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
V ?= 0
DEBUG ?= 0
ifeq ($(V),1)
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
MAKEFLAGS += --no-print-directory
endif
SRCDIR := src
OUTDIR := dist
CC := clang
CFLAGS ?= -Wall -Wextra -Wpedantic -Wconversion -std=c11 -D_POSIX_C_SOURCE=200809L
LDLIBS ?= -larchive -lcurl -lssl -lcrypto
LDFLAGS ?=
ifeq ($(DEBUG),1)
CFLAGS += -O0 -g3 -DDEBUG
else
CFLAGS += -O2 -DNDEBUG -flto=thin
LDFLAGS += -flto=thin
endif
ifeq ($(shell uname),Darwin)
LDFLAGS += -mmacosx-version-min=26.0
# Homebrew libarchive and libssl is not in the default search path, so we need to add it
LDFLAGS += -L/opt/homebrew/opt/libarchive/lib -L/opt/homebrew/opt/openssl@3/lib
LDFLAGS += -L/usr/local/opt/libarchive/lib -L/usr/local/opt/openssl@3/lib
CFLAGS += -I/opt/homebrew/opt/libarchive/include -I/opt/homebrew/opt/openssl@3/include
CFLAGS += -I/usr/local/opt/libarchive/include -I/usr/local/opt/openssl@3/include
endif
C_SOURCES := $(wildcard $(SRCDIR)/*.c) $(wildcard $(SRCDIR)/cmds/*.c)
C_OUTPUTS := $(C_SOURCES:$(SRCDIR)/%.c=$(OUTDIR)/%.o)
TARGET := zircon
.PHONY: all
all: $(OUTDIR)/$(TARGET)
$(OUTDIR)/$(TARGET): $(C_OUTPUTS) | $(OUTDIR)
$(ECHO) " CCLD $@"
$(Q)$(CC) -o $(OUTDIR)/$(TARGET) $(C_OUTPUTS) $(LDLIBS) $(LDFLAGS)
$(OUTDIR)/%.o: $(SRCDIR)/%.c | $(OUTDIR)
$(ECHO) " CC $@"
$(Q)$(CC) $(CFLAGS) -c $< -o $@
$(OUTDIR):
$(ECHO) " MKDIR $@"
$(Q)mkdir -p $(OUTDIR)/cmds
.PHONY: clean
clean:
$(ECHO) " RM $(OUTDIR)"
$(Q)rm -rf $(OUTDIR)