# Press2P's XInput1_4.dll for xemu (online split-screen controllers)
# Build with MSYS2 MinGW-w64 (MSYSTEM=MINGW64):  make  -> build/XInput1_4.dll

ifeq ($(origin CC),default)
CC      := gcc
endif
BUILD   := build
TARGET  := $(BUILD)/XInput1_4.dll

CFLAGS  ?= -O2
CFLAGS  += -std=c11 -Wall -Wextra
# No timestamp in the DLL: the same source always builds the same bytes, so the release build can
# check that the copy in cores\ is this source's.
LDFLAGS += -shared -static -static-libgcc -s -Wl,--no-undefined -Wl,--no-insert-timestamp

SRCS    := src/proxy.c
HDRS    := src/pads.h

.PHONY: all clean

all: $(TARGET)

$(TARGET): $(SRCS) $(HDRS) XInput1_4.def | $(BUILD)
	$(CC) $(CFLAGS) -o $@ $(SRCS) XInput1_4.def $(LDFLAGS)

$(BUILD):
	mkdir -p $(BUILD)

clean:
	rm -rf $(BUILD)
