-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
44 lines (33 loc) · 983 Bytes
/
Makefile
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
TARGET_EXEC := perg
# Local directories
BUILD_DIR := ./build
SRC_DIR := ./src
INC_DIRS := $(shell find $(SRC_DIR) -type d)
# Source and object file names
SRCS := $(shell find $(SRC_DIR) -name '*.c')
OBJS := $(SRCS:$(SRC_DIR)/%.c=$(BUILD_DIR)/%.o)
# Installation directories
PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man
CC = gcc
CFLAGS = -Wall -Werror -O3 -std=gnu89 -pthread
$(BUILD_DIR)/$(TARGET_EXEC) : $(OBJS)
$(CC) $(CFLAGS) -o $@ $(OBJS)
$(BUILD_DIR)/%.o : $(SRC_DIR)/%.c
mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean debug install uninstall
install : $(BUILD_DIR)/$(TARGET_EXEC)
mkdir -p $(DESTDIR)$(BINDIR)
install -m755 $(BUILD_DIR)/$(TARGET_EXEC) $(DESTDIR)$(BINDIR)/
mkdir -p $(DESTDIR)$(MANDIR)/man1
# install manpage to $(DESTDIR)$(MANDIR)/man1/perg.1
uninstall :
rm -f $(BINDIR)/$(TARGET_EXEC)
rm -f $(MANDIR)/man1/perg.1
debug : clean
CFLAGS += -Og -g
$(TARGET_EXEC)
clean :
rm -rf $(BUILD_DIR)