neatvnc/common.mk

46 lines
1.0 KiB
Makefile
Raw Normal View History

MACHINE := $(shell $(CC) -dumpmachine)
ARCH := $(firstword $(subst -, ,$(MACHINE)))
BUILD_DIR ?= build-$(MACHINE)
2019-09-07 17:10:37 +00:00
PREFIX ?= /usr/local
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))
STRIP := strip
else
STRIP := $(MACHINE)-strip
endif
CFLAGS ?= -g -O3 $(ARCH_CFLAGS) -flto -DNDEBUG
LDFLAGS ?= -flto
CFLAGS += -std=gnu11 -D_GNU_SOURCE -Iinc
CC_OBJ = $(CC) -c $(CFLAGS) $< -o $@ -MMD -MP -MF $(@:.o=.deps)
2019-09-07 15:59:48 +00:00
LINK_EXE = $(CC) $^ $(LDFLAGS) -o $@
LINK_DSO = $(CC) -fPIC -shared $^ $(LDFLAGS) -o $@
CFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --cflags $(dep)))
LDFLAGS += $(foreach dep,$(DEPENDENCIES),$(shell pkg-config --libs $(dep)))
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 :=