-
-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
114 lines (91 loc) · 2.56 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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
CC = gcc
CFLAGS = -O3 -std=c99 -Wall -Wformat -Wunused-variable -pedantic
CPPFLAGS = -D_POSIX_C_SOURCE=200809L
LDFLAGS =
INSTALL = install -c
PREFIX = /usr/local
BINDIR = $(PREFIX)/bin
MANDIR = $(PREFIX)/share/man/man1
ALL_SOURCES = $(shell find . -type f \( -name '*.c' -o -name '*.h' \))
SOURCES = $(wildcard ./src/*.c)
OBJS = $(SOURCES:.c=.o)
EXEEXT =
PROG = screenfetch-c$(EXEEXT)
SCRIPTS =
TESTS =
OLDTARGETS = linux win bsd osx sun
ifeq ($(COLORS),0)
CPPFLAGS += -DNO_COLORS
endif
ifneq (,$(findstring mingw,$(shell $(CC) -dumpmachine)))
OS = Windows_NT
endif
ifeq ($(OS),Windows_NT)
SOURCES += $(wildcard ./src/plat/win32/*.c)
CPPFLAGS += -DWIN32_LEAN_AND_MEAN
LDFLAGS += -lgdi32
EXEEXT = .exe
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
SOURCES += $(wildcard ./src/plat/linux/*.c)
CFLAGS += -Wno-unused-result
LDFLAGS += -lX11 -lGL
SCRIPTS += ./src/scripts/detectgtk
TESTS += x11test gltest
endif
ifeq ($(UNAME_S),Darwin)
SOURCES += $(wildcard ./src/plat/darwin/*.c)
LDFLAGS += -framework CoreFoundation -framework IOKit -framework CoreGraphics
CPPFLAGS += -D_DARWIN_C_SOURCE -D_DARWIN_USE_64_BIT_INODE
endif
ifeq ($(UNAME_S),SunOS)
SOURCES += $(wildcard ./src/plat/sun/*.c)
LDFLAGS += -lX11
SCRIPTS += ./src/scripts/detectwm ./src/scripts/detectwmtheme
TESTS += x11test
endif
ifneq (,$(filter $(UNAME_S),FreeBSD NetBSD OpenBSD DragonFly))
SOURCES += $(wildcard ./src/plat/bsd/*.c)
LDFLAGS +=
SCRIPTS += ./src/scripts/detectwm ./src/scripts/detectwmtheme \
./src/scripts/detectgtk
endif
endif
all: $(TESTS) $(OBJS)
$(CC) $(CFLAGS) $(CPPFLAGS) $(OBJS) -o $(PROG) $(LDFLAGS)
.c.o:
$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
install: all
$(INSTALL) $(PROG) $(BINDIR)/$(PROG)
if [ -n "$(SCRIPTS)" ] ; then \
$(INSTALL) $(SCRIPTS) $(BINDIR) ; \
fi
mkdir -p $(MANDIR)
$(INSTALL) ./man/man1/screenfetch-c.1 $(MANDIR)/screenfetch-c.1
uninstall:
rm -rf $(BINDIR)/screenfetch-c
rm -rf $(BINDIR)/detectde
rm -rf $(BINDIR)/detectgtk
rm -rf $(BINDIR)/detectwm
rm -rf $(BINDIR)/detectwmtheme
rm -rf $(BINDIR)/detectgpu
rm -rf $(MANDIR)/screenfetch-c.1
x11test:
@echo "Testing for X11..."
$(CC) $(CFLAGS) ./src/tests/x11test.c -o ./x11test -lX11
@echo "Looks good."
gltest:
@echo "Testing for OpenGL..."
$(CC) $(CFLAGS) ./src/tests/gltest.c -o ./gltest -lGL
@echo "Looks good."
clean:
rm -f ./src/*.o ./src/plat/*/*.o
rm -f threadtest
rm -f x11test
rm -f gltest
rm -f screenfetch-c screenfetch-c.exe
fmt:
clang-format -i -style=file $(ALL_SOURCES)
$(OLDTARGETS): all
.PHONY: all install uninstall clean fmt $(OLDTARGETS)