2019-09-07 15:01:53 +00:00
|
|
|
MACHINE := $(shell $(CC) -dumpmachine)
|
|
|
|
ARCH := $(firstword $(subst -, ,$(MACHINE)))
|
|
|
|
BUILD_DIR ?= build-$(MACHINE)
|
|
|
|
|
2019-09-07 17:10:37 +00:00
|
|
|
PREFIX ?= /usr/local
|
|
|
|
|
2019-09-07 15:01:53 +00:00
|
|
|
ifeq ($(ARCH),x86_64)
|
|
|
|
ARCH_CFLAGS := -mavx
|
|
|
|
else
|
|
|
|
ifeq ($(ARCH),arm)
|
|
|
|
ARCH_CFLAGS := -mfpu=neon
|
|
|
|
endif # end arm block
|
|
|
|
endif # end x86_64 block
|
|
|
|
|
2019-09-07 17:10:37 +00:00
|
|
|
ifeq (, $(shell which $(MACHINE)-strip 2>/dev/null))
|
2019-09-07 17:31:20 +00:00
|
|
|
STRIP ?= strip
|
2019-09-07 17:10:37 +00:00
|
|
|
else
|
2019-09-07 17:31:20 +00:00
|
|
|
STRIP ?= $(MACHINE)-strip
|
2019-09-07 17:10:37 +00:00
|
|
|
endif
|
|
|
|
|
2019-09-07 17:30:21 +00:00
|
|
|
ifeq (, $(shell which $(MACHINE)-pkg-config 2>/dev/null))
|
|
|
|
PKGCONFIG ?= pkg-config
|
|
|
|
else
|
|
|
|
PKGCONFIG ?= $(MACHINE)-pkg-config
|
|
|
|
endif
|
|
|
|
|
2019-09-07 15:01:53 +00:00
|
|
|
CFLAGS ?= -g -O3 $(ARCH_CFLAGS) -flto -DNDEBUG
|
|
|
|
LDFLAGS ?= -flto
|
|
|
|
|
2019-09-14 16:07:34 +00:00
|
|
|
CFLAGS += -std=gnu11 -D_GNU_SOURCE -Iinclude
|
2019-09-07 15:01:53 +00:00
|
|
|
|
|
|
|
CC_OBJ = $(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $(@:.o=.deps)
|
2019-09-07 15:59:48 +00:00
|
|
|
LINK_EXE = $(CC) $^ $(LDFLAGS) -o $@
|
2019-09-07 15:01:53 +00:00
|
|
|
LINK_DSO = $(CC) -fPIC -shared $^ $(LDFLAGS) -o $@
|
|
|
|
|
2019-09-07 17:30:21 +00:00
|
|
|
CFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell $(PKGCONFIG) --cflags $(dep)))
|
|
|
|
LDFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell $(PKGCONFIG) --libs $(dep)))
|
2019-09-07 15:01:53 +00:00
|
|
|
OBJECTS := $(SOURCES:src/%.c=$(BUILD_DIR)/%.o)
|
|
|
|
|
|
|
|
$(BUILD_DIR): ; mkdir -p $(BUILD_DIR)
|
|
|
|
|
|
|
|
.PHONY: clean
|
|
|
|
clean: ; rm -rf $(BUILD_DIR)
|
|
|
|
|
|
|
|
-include $(BUILD_DIR)/*.deps
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
.SECONDARY:
|
|
|
|
|
|
|
|
# This clears the default target set by this file
|
|
|
|
.DEFAULT_GOAL :=
|