forked from jhx0/bsdfetch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
84 lines (71 loc) · 2.18 KB
/
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
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
79
80
81
82
83
84
# Set the default compiler to clang if not specified
CC?= clang
# Common compilation flags
CFLAGS= -O2 -fomit-frame-pointer -pipe -std=c11
# Additional flags for clang
.if ${CC} == "clang"
CFLAGS+= -Weverything
.else
# Additional flags for other compilers
CFLAGS+= -Wall -Wconversion -Wshadow -Wextra -Wpedantic
.endif
# Debugging flags
DFLAGS= -g -ggdb
# Executable and debug target names
EXE= openfetch
DBG= ${EXE}.debug
# Source files
SRC= openfetch.c
# Include additional source file for OpenBSD
OS != uname -s
.if ${OS} == "OpenBSD"
SRC+= sysctlbyname.c
.endif
# Manual page
MAN= openfetch.1
# Rule to build the executable
${EXE}: ${SRC}
@echo "Building ${EXE}..."
@${CC} ${CFLAGS} -s -o $@ $>
# Rule to build the debug version
${DBG}: ${SRC}
@echo "Building debug version ${DBG}..."
@${CC} ${DFLAGS} -o $@ $>
# Default target to build both release and debug versions
.PHONY: all
all: ${EXE} ${DBG}
# Phony target to clean up build artifacts
.PHONY: clean
clean:
@echo "Cleaning up..."
@rm -f ${EXE} ${DBG}
# Phony target to install the executable and other files
.PHONY: install
install: ${EXE}
@echo "Installing ${EXE} to /usr/local/bin..."
@install -d /usr/local/bin
@install -m 755 ${EXE} /usr/local/bin
@echo "Installing logo files to /usr/local/share/doc/logo/..."
@install -d /usr/local/share/doc/logo
@install -m 644 logo/* /usr/local/share/doc/logo/
@echo "Installing man page to /usr/local/man/man1..."
@install -d /usr/local/man/man1
@install -m 644 ${MAN} /usr/local/man/man1
# Phony target to uninstall the executable and other files
.PHONY: uninstall
uninstall:
@echo "Uninstalling ${EXE} from /usr/local/bin..."
@rm -f /usr/local/bin/${EXE}
@echo "Removing /usr/local/share/doc/logo/..."
@rm -rf /usr/local/share/doc/logo/
@echo "Removing man page from /usr/local/man/man1..."
@rm -f /usr/local/man/man1/${MAN}
# Phony target to display help
.PHONY: help
help:
@echo "Available targets:"
@echo " all - Build both release and debug versions"
@echo " clean - Clean up build artifacts"
@echo " install - Install the executable and other files"
@echo " uninstall - Uninstall the executable and other files"
@echo " help - Display this help message"