-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
42 lines (30 loc) · 820 Bytes
/
Makefile
File metadata and controls
42 lines (30 loc) · 820 Bytes
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
SHELL := /bin/sh
CC = gcc
CFLAGS = -Iinclude -std=c99 -Wall -Wextra -O2
LDFLAGS = -fsanitize=address,leak,undefined
CFLAGS += $(shell pkg-config --cflags glib-2.0 libnotify)
LDFLAGS += $(shell pkg-config --libs glib-2.0 libnotify)
SRC_DIR := src
OBJ_DIR := .build/obj
BUILD_DIR := .build
BIN_NAME := disk_usage
BIN_PATH := $(BUILD_DIR)/$(BIN_NAME)
SOURCES := $(shell find $(SRC_DIR) -name '*.c')
OBJECTS := $(patsubst $(SRC_DIR)/%.c, $(OBJ_DIR)/%.o, $(SOURCES))
.PHONY: all build clean run rebuild
all: build
build: $(BIN_PATH) $(OBJECTS)
$(BIN_PATH): $(OBJECTS)
@mkdir -p $(BUILD_DIR)
$(CC) $(LDFLAGS) $^ -o $@
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
clean:
rm -rf $(BUILD_DIR)
rebuild:
rm -f $(BIN_PATH)
rm -f $(OBJECTS)
$(MAKE) build
run: build
$(BIN_PATH)