-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
53 lines (38 loc) · 1.45 KB
/
Makefile
File metadata and controls
53 lines (38 loc) · 1.45 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
TARGET = hwmonitor
CC = gcc
.DEFAULT_GOAL := all
SRC_DIRS = ./src ./vendor/cJSON/cJSON.c
BUILD_DIR = ./build
INC_DIRS = ./include ./vendor/cJSON
CFLAGS = -D_POSIX_C_SOURCE=200809L -std=c11 -Wall -Wextra -Wpedantic -O2 $(INC_FLAGS)
TEST_BUILD_DIR = ./build/tests
TEST_CFLAGS = -D_POSIX_C_SOURCE=200809L -std=c11 -Wall -Wextra -Wpedantic -O2 $(INC_FLAGS)
TEST_SUPPORT = tests/test_support.c vendor/cJSON/cJSON.c
SRCS = $(shell find $(SRC_DIRS) -name "*.c")
INCS = $(shell find $(INC_DIRS) -name "*.h")
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
BIN = $(BUILD_DIR)/$(TARGET)
all: $(BIN)
$(TEST_BUILD_DIR):
mkdir -p $(TEST_BUILD_DIR)
$(TEST_BUILD_DIR)/test_format_size: tests/test_format_size.c src/util.c
$(CC) tests/test_format_size.c src/util.c $(TEST_SUPPORT) -o $@ $(TEST_CFLAGS)
$(TEST_BUILD_DIR)/test_parse_arguments: tests/test_parse_arguments.c src/util.c
$(CC) tests/test_parse_arguments.c src/util.c $(TEST_SUPPORT) -o $@ $(TEST_CFLAGS)
.PHONY: test
test: $(TEST_BUILD_DIR) $(TEST_BUILD_DIR)/test_format_size $(TEST_BUILD_DIR)/test_parse_arguments
$(TEST_BUILD_DIR)/test_format_size
$(TEST_BUILD_DIR)/test_parse_arguments
$(BIN): $(SRCS) $(INCS)
mkdir -p $(BUILD_DIR)
$(CC) $(SRCS) -o $(BIN) $(CFLAGS) -lcurl
.PHONY: clean
clean:
rm -r $(BUILD_DIR)
PREFIX ?= /usr/local
.PHONY: install uninstall
install: $(BIN)
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 $(BIN) $(DESTDIR)$(PREFIX)/bin/$(TARGET)
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(TARGET)