-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
78 lines (63 loc) · 2.68 KB
/
Makefile
File metadata and controls
78 lines (63 loc) · 2.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# ./Makefile
# 現在のmain.cppファイル用の簡易Makefile
CXX = g++
CXXFLAGS = -std=c++17 -O3 -march=native -Wall -Wextra
TARGET = sound_processor
SOURCE = main.cpp
# 依存ライブラリ
LIBS = -lsndfile -lsamplerate
# pkg-configを使ってフラグを自動取得
CXXFLAGS += $(shell pkg-config --cflags sndfile)
CXXFLAGS += $(shell pkg-config --cflags samplerate)
LIBS += $(shell pkg-config --libs sndfile)
LIBS += $(shell pkg-config --libs samplerate)
# nlohmann/jsonの場所を探す(システムにインストールされている場合)
JSON_INCLUDE = $(shell find /usr/include /usr/local/include -name "nlohmann" -type d 2>/dev/null | head -1)
ifneq ($(JSON_INCLUDE),)
CXXFLAGS += -I$(dir $(JSON_INCLUDE))
endif
# デバッグビルド用
DEBUG_FLAGS = -g -DDEBUG -O0
RELEASE_FLAGS = -DNDEBUG -O3 -march=native
.PHONY: all clean debug release install
all: release
release:
$(CXX) $(CXXFLAGS) $(RELEASE_FLAGS) $(SOURCE) -o $(TARGET) $(LIBS)
@echo "Release build complete: ./$(TARGET)"
debug:
$(CXX) $(CXXFLAGS) $(DEBUG_FLAGS) $(SOURCE) -o $(TARGET)_debug $(LIBS)
@echo "Debug build complete: ./$(TARGET)_debug"
clean:
rm -f $(TARGET) $(TARGET)_debug
install: release
sudo cp $(TARGET) /usr/local/bin/
sudo cp params.json /usr/local/share/$(TARGET)/
@echo "Installed to /usr/local/bin/$(TARGET)"
# 依存関係チェック
check-deps:
@echo "Checking dependencies..."
@pkg-config --exists sndfile || (echo "ERROR: libsndfile not found. Install with: sudo apt-get install libsndfile1-dev" && exit 1)
@pkg-config --exists samplerate || (echo "ERROR: libsamplerate not found. Install with: sudo apt-get install libsamplerate0-dev" && exit 1)
@test -f /usr/include/nlohmann/json.hpp || test -f /usr/local/include/nlohmann/json.hpp || (echo "ERROR: nlohmann/json not found. Install with: sudo apt-get install nlohmann-json3-dev" && exit 1)
@echo "All dependencies found!"
# ヘルプ
help:
@echo "Available targets:"
@echo " all - Build release version (default)"
@echo " release - Build optimized release version"
@echo " debug - Build debug version"
@echo " clean - Remove built files"
@echo " install - Install to system (requires sudo)"
@echo " check-deps - Check if dependencies are installed"
@echo " help - Show this help"
@echo ""
@echo "Usage examples:"
@echo " make check-deps"
@echo " make release"
@echo " ./$(TARGET) input.wav"
# 依存ライブラリのインストールヘルプ
install-deps-ubuntu:
sudo apt-get update
sudo apt-get install -y libsndfile1-dev libsamplerate0-dev nlohmann-json3-dev build-essential pkg-config
install-deps-macos:
brew install libsndfile libsamplerate nlohmann-json pkg-config