Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,30 @@ ifneq ($(OS), Linux)
ARGP = /usr/local
ifeq ($(OS), Darwin)
ifneq ($(shell command -v brew),)
ARGP = $(shell brew --prefix)
# Apple Silicon Homebrew lives under /opt/homebrew; Intel under
# /usr/local. `brew --prefix` resolves either. Prefer the
# argp-standalone keg path when present (it is more robust if the
# formula is keg-only), else fall back to the Homebrew prefix.
ARGP = $(shell brew --prefix argp-standalone 2>/dev/null || brew --prefix)
endif
endif
CFLAGS += -I$(ARGP)/include
LDFLAGS += -L$(ARGP)/lib -largp
endif

# libudev is Linux-only; f3probe's Darwin backend does not use it.
ifeq ($(OS), Linux)
UDEV_LIBS = -ludev
else
UDEV_LIBS =
endif

# Among the "extra" tools, only f3probe is ported to macOS: f3brew needs
# libudev and f3fix needs libparted, both out of scope on Darwin.
ifeq ($(OS), Darwin)
EXTRA_TARGETS = $(BUILD_DIR)/f3probe
endif

all: $(TARGETS)
extra: $(EXTRA_TARGETS)

Expand Down Expand Up @@ -64,10 +81,10 @@ $(BUILD_DIR)/f3read: $(BUILD_DIR)/libutils.o $(BUILD_DIR)/libfile.o $(BUILD_DIR)
$(CC) -o $@ $^ $(LDFLAGS) -lm

$(BUILD_DIR)/f3probe: $(BUILD_DIR)/libutils.o $(BUILD_DIR)/libflow.o $(BUILD_DIR)/libdevs.o $(BUILD_DIR)/libprobe.o $(BUILD_DIR)/f3probe.o
$(CC) -o $@ $^ $(LDFLAGS) -lm -ludev
$(CC) -o $@ $^ $(LDFLAGS) -lm $(UDEV_LIBS)

$(BUILD_DIR)/f3brew: $(BUILD_DIR)/libutils.o $(BUILD_DIR)/libflow.o $(BUILD_DIR)/libdevs.o $(BUILD_DIR)/f3brew.o
$(CC) -o $@ $^ $(LDFLAGS) -lm -ludev
$(CC) -o $@ $^ $(LDFLAGS) -lm $(UDEV_LIBS)

$(BUILD_DIR)/f3fix: $(BUILD_DIR)/libutils.o $(BUILD_DIR)/f3fix.o
$(CC) -o $@ $^ $(LDFLAGS) -lparted
Expand Down
Loading