Added basic HID intervace
This commit is contained in:
28
Makefile
28
Makefile
@ -13,34 +13,52 @@ clean:
|
||||
-rm -r $(BUILD_DIR)
|
||||
@echo ""
|
||||
|
||||
.PHONY: clean all run
|
||||
|
||||
libs: $(BUILD_DIR)/hid.o
|
||||
|
||||
.PHONY: clean all run libs
|
||||
|
||||
#################################################
|
||||
# Flags and autodetection
|
||||
|
||||
# -MMD and -MP generate makefiles with extension .d.
|
||||
CPPFLAGS := -Wall -MMD -MP -I src
|
||||
LDFLAGS := -l fftw3
|
||||
CPPFLAGS := -Wall -MMD -MP -I src -I libs/hidapi/hidapi
|
||||
LDFLAGS := -l fftw3 -l udev
|
||||
|
||||
# Find all cpp files in source dirs
|
||||
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
|
||||
# Turns ./build/a.cpp into ./build/a.cpp.o
|
||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||
LIB_OBJS := $(BUILD_DIR)/hid.o
|
||||
# Turns ./build/a.cpp.o into ./build/a.cpp.d
|
||||
DEPS := $(OBJS:.o=.d)
|
||||
|
||||
#################################################
|
||||
# Build targets
|
||||
|
||||
HIDAPI_PATH := libs/hidapi
|
||||
# Build hidapi
|
||||
$(BUILD_DIR)/hid.o:
|
||||
@mkdir -p $(BUILD_DIR)
|
||||
|
||||
@echo "Compiling hid.o"
|
||||
@gcc -Wall -g -fpic -c \
|
||||
-I $(HIDAPI_PATH)/hidapi \
|
||||
`pkg-config libusb-1.0 --cflags` \
|
||||
\
|
||||
$(HIDAPI_PATH)/linux/hid.c \
|
||||
-o $(BUILD_DIR)/hid.o
|
||||
|
||||
# C++ build step
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||
$(BUILD_DIR)/%.cpp.o: %.cpp $(BUILD_DIR)/hid.o
|
||||
mkdir -p $(dir $@)
|
||||
g++ $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||
|
||||
|
||||
# Final build step
|
||||
$(TARGET_EXEC) : $(OBJS)
|
||||
g++ $(OBJS) -o $@ $(LDFLAGS)
|
||||
g++ $(OBJS) $(LIB_OBJS) -o $@ $(LDFLAGS)
|
||||
|
||||
|
||||
|
||||
# Include generated makefiles
|
||||
|
Reference in New Issue
Block a user