Cleaned up makefile
parent
4eff7eb277
commit
a447b5f8c8
26
Makefile
26
Makefile
|
@ -22,22 +22,31 @@ libs: $(BUILD_DIR)/hid.o
|
||||||
# Flags and autodetection
|
# Flags and autodetection
|
||||||
|
|
||||||
# -MMD and -MP generate makefiles with extension .d.
|
# -MMD and -MP generate makefiles with extension .d.
|
||||||
CPPFLAGS := -Wall -MMD -MP -I src -I libs/hidapi/hidapi
|
CPPFLAGS := -MMD -MP \
|
||||||
|
-Wall \
|
||||||
|
-I src \
|
||||||
|
-I libs/hidapi/hidapi
|
||||||
|
|
||||||
|
# udev: required by hidapi
|
||||||
LDFLAGS := -l fftw3 -l udev
|
LDFLAGS := -l fftw3 -l udev
|
||||||
|
|
||||||
# Find all cpp files in source dirs
|
# Find all cpp files in source dirs
|
||||||
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
|
SRCS := $(shell find $(SRC_DIRS) -name '*.cpp')
|
||||||
# Turns ./build/a.cpp into ./build/a.cpp.o
|
# Turns src/a.cpp into build/src/a.cpp.o
|
||||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
SRC_OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
||||||
LIB_OBJS := $(BUILD_DIR)/hid.o
|
LIB_OBJS := $(BUILD_DIR)/hid.o
|
||||||
# Turns ./build/a.cpp.o into ./build/a.cpp.d
|
OBJS = $(SRC_OBJS) $(LIB_OBJS)
|
||||||
|
# Turns build/a.cpp.o into build/a.cpp.d
|
||||||
DEPS := $(OBJS:.o=.d)
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
#################################################
|
#################################################
|
||||||
# Build targets
|
# Build targets
|
||||||
|
|
||||||
HIDAPI_PATH := libs/hidapi
|
|
||||||
|
### Libraries
|
||||||
|
|
||||||
# Build hidapi
|
# Build hidapi
|
||||||
|
HIDAPI_PATH := libs/hidapi
|
||||||
$(BUILD_DIR)/hid.o:
|
$(BUILD_DIR)/hid.o:
|
||||||
@mkdir -p $(BUILD_DIR)
|
@mkdir -p $(BUILD_DIR)
|
||||||
|
|
||||||
|
@ -49,15 +58,18 @@ $(BUILD_DIR)/hid.o:
|
||||||
$(HIDAPI_PATH)/linux/hid.c \
|
$(HIDAPI_PATH)/linux/hid.c \
|
||||||
-o $(BUILD_DIR)/hid.o
|
-o $(BUILD_DIR)/hid.o
|
||||||
|
|
||||||
|
|
||||||
|
### Source
|
||||||
|
|
||||||
# C++ build step
|
# C++ build step
|
||||||
$(BUILD_DIR)/%.cpp.o: %.cpp $(BUILD_DIR)/hid.o
|
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||||
mkdir -p $(dir $@)
|
mkdir -p $(dir $@)
|
||||||
g++ $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
g++ $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Final build step
|
# Final build step
|
||||||
$(TARGET_EXEC) : $(OBJS)
|
$(TARGET_EXEC) : $(OBJS)
|
||||||
g++ $(OBJS) $(LIB_OBJS) -o $@ $(LDFLAGS)
|
g++ $(OBJS) -o $@ $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue