Current section
Files
Jump to
Current section
Files
input_event
Makefile
Makefile
# Variables to override## CC C compiler# CROSSCOMPILE crosscompiler prefix, if any# CFLAGS compiler flags for compiling all C files# ERL_CFLAGS additional compiler flags for files using Erlang header files# ERL_EI_LIBDIR path to libei.a# LDFLAGS linker flags for linking all binaries# ERL_LDFLAGS additional linker flags for projects referencing Erlang librariesPREFIX = $(MIX_APP_PATH)/privBUILD = $(MIX_APP_PATH)/obj# Check that we're on a supported build platformifeq ($(CROSSCOMPILE),) # Not crosscompiling, so check that we're on Linux. ifneq ($(shell uname -s),Linux) $(warning input_event only works on Linux, but crosscompilation) $(warning is supported by defining $$CROSSCOMPILE, $$ERL_EI_INCLUDE_DIR,) $(warning and $$ERL_EI_LIBDIR. See Makefile for details. If using Nerves,) $(warning this should be done automatically.) $(warning .) $(warning Skipping C compilation unless targets explicitly passed to make.) DEFAULT_TARGETS = priv endifendifDEFAULT_TARGETS ?= $(PREFIX) $(PREFIX)/input_eventLDFLAGS +=CFLAGS += -std=gnu99# If not cross-compiling, then run sudo by defaultifeq ($(origin CROSSCOMPILE), undefined)SUDO_ASKPASS ?= /usr/bin/ssh-askpassSUDO ?= sudoelse# If cross-compiling, then permissions need to be set some build system-dependent waySUDO ?= trueendif# Enable for debug messages#CFLAGS += -DDEBUGSRC=$(wildcard src/*.c)OBJ = $(SRC:src/%.c=$(BUILD)/%.o)calling_from_make: mix compile.PHONY: all cleanall: $(PREFIX) $(BUILD) $(PREFIX)/input_event$(BUILD)/%.o: src/%.c $(CC) -c $(CFLAGS) -o $@ $<$(PREFIX) $(BUILD): mkdir -p $@$(PREFIX)/input_event: $(OBJ) $(CC) $^ $(LDFLAGS) -o $@ # For host builds, setuid root the input_event binary so that it can read /dev/input/event* SUDO_ASKPASS=$(SUDO_ASKPASS) $(SUDO) -- sh -c 'chown root:root $@; chmod +s $@'clean: rm -f $(PREFIX)/input_event $(BUILD)/*.o