-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (35 loc) · 935 Bytes
/
Makefile
File metadata and controls
48 lines (35 loc) · 935 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
43
44
45
46
47
48
.POSIX:
.SUFFIXES:
include config.mk
CFLAGS += -std=c99 -pedantic -Wall -Wextra
CFLAGS += -Wformat-security -Wwrite-strings
CFLAGS += -Wno-unused-parameter
CFLAGS += -g -Iinclude -Isrc
BIN = kirc
SRC = src
BUILD = build
# Discover all source files
SRCS = $(wildcard $(SRC)/*.c)
# Create matching build/*.o paths
OBJS = $(SRCS:$(SRC)/%.c=$(BUILD)/%.o)
all: $(BIN)
$(BIN): $(OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
$(BUILD):
mkdir -p $@
# Pattern rule: build/xyz.o ← src/xyz.c
$(BUILD)/%.o: $(SRC)/%.c | $(BUILD)
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(BIN) $(BUILD)/*
install:
mkdir -p $(DESTDIR)$(BINDIR)
cp -f $(BIN) $(DESTDIR)$(BINDIR)
chmod 755 $(DESTDIR)$(BINDIR)/$(BIN)
mkdir -p $(DESTDIR)$(MANDIR)/man1
cp -f $(BIN).1 $(DESTDIR)$(MANDIR)/man1
chmod 644 $(DESTDIR)$(MANDIR)/man1/$(BIN).1
uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(BIN)
rm -f $(DESTDIR)$(MANDIR)/man1/$(BIN).1
.PHONY: all clean install uninstall