diff --git a/.gitignore b/.gitignore index cb40e26..6c18ba2 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,6 @@ windows/x64/ *.user *.aps + +*.o +*.so diff --git a/linux/Makefile b/linux/Makefile new file mode 100644 index 0000000..c655ddf --- /dev/null +++ b/linux/Makefile @@ -0,0 +1,33 @@ +TARGET := lib-wooting-analog + +HID_DIR := ../hidapi + +SRC_DIR := ../src +INC_DIR := ../src +BLD_DIR := build + +HID_INC := $(HID_DIR)/hidapi + +C_FILES := $(wildcard $(SRC_DIR)/*.c) +O_FILES := $(patsubst $(SRC_DIR)/%.c,$(BLD_DIR)/%.o,$(C_FILES)) + +CC := clang +LD := clang + +C_FLAGS := -c -fPIC $(addprefix -I,$(INC_DIR) $(HID_INC)) +LD_FLAGS := -shared + +all: buildDir library + +clean: + rm -vf $(O_FILES) + +buildDir: + mkdir -p $(BLD_DIR) + +library: $(O_FILES) + $(LD) $(LD_FLAGS) -o $(TARGET).so $? + +$(BLD_DIR)/%.o: $(SRC_DIR)/%.c + $(CC) $(C_FLAGS) -o $@ $< + diff --git a/linux/README b/linux/README new file mode 100644 index 0000000..71a0096 --- /dev/null +++ b/linux/README @@ -0,0 +1,33 @@ +# Requirements + +Make +Clang + +These are required for libhid: +Autotools Development +Autoconf +Automake +Libtool +udev Development +Libusb Development +Libfox Development + +To install these on Debian based systems run: +``` +sudo apt-get install autotools-dev autoconf automake libtool libudev-dev libusb-1.0-0-dev libfox-1.6-dev build-essential clang +``` + +# Building libhid +``` +cd libhid +./bootstrap +./configure +make -j8 +``` +You can adjust -j8 based on your system, if your RAM allows the recomendation is generally threads * 2. + +# Building +``` +cd linux +make +``` diff --git a/src/wooting-analog-sdk.h b/src/wooting-analog-sdk.h index ce5b513..605a300 100644 --- a/src/wooting-analog-sdk.h +++ b/src/wooting-analog-sdk.h @@ -7,11 +7,16 @@ */ #pragma once +// Check for Windows, and make sure it is not CYGWIN (since that uses Unix APIs) +#if defined(WIN32) || defined(_WIN32) || defined(__WIN32) && !defined(__CYGWIN__) #ifdef WOOTINGANALOGSDK_EXPORTS #define WOOTINGANALOGSDK_API __declspec(dllexport) #else #define WOOTINGANALOGSDK_API __declspec(dllimport) #endif +#else +#define WOOTINGANALOGSDK_API +#endif // WIN32 check #include "stdbool.h" #include "stdint.h"