blob: 3cf8d3158dc5da3078cda3702dacdb9e41608fee (
plain)
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
|
PREFIX ?= /usr/local
DOCDIR ?= $(PREFIX)/share/btop/doc
#Compiler and Linker
CXX := g++
#The Target Binary Program
TARGET := btop
#The Directories, Source, Includes, Objects and Binary
SRCDIR := src
INCDIR := include
BUILDDIR := obj
TARGETDIR := bin
SRCEXT := cpp
DEPEXT := d
OBJEXT := o
#Flags, Libraries and Includes
CXXFLAGS := -std=c++20 -pthread -O3 -Wall -Wextra -Wno-stringop-overread -pedantic
INC := -I$(INCDIR) -I$(SRCDIR)
#---------------------------------------------------------------------------------
#DO NOT EDIT BELOW THIS LINE
#---------------------------------------------------------------------------------
SOURCES := $(shell find $(SRCDIR) -type f -name *.$(SRCEXT))
OBJECTS := $(patsubst $(SRCDIR)/%,$(BUILDDIR)/%,$(SOURCES:.$(SRCEXT)=.$(OBJEXT)))
#Default Make
all: directories $(TARGET)
#Make the Directories
directories:
@mkdir -p $(TARGETDIR)
@mkdir -p $(BUILDDIR)
#Clean only Objecst
clean:
@rm -rf $(BUILDDIR)
#Full Clean, Objects and Binaries
dist-clean: clean
@rm -rf $(TARGETDIR)
install:
@mkdir -p $(DESTDIR)$(PREFIX)/bin
@cp -p bin/btop $(DESTDIR)$(PREFIX)/bin/btop
@mkdir -p $(DESTDIR)$(DOCDIR)
@cp -p README.md $(DESTDIR)$(DOCDIR)
@cp -pr themes $(DESTDIR)$(PREFIX)/share/btop
@chmod 755 $(DESTDIR)$(PREFIX)/bin/btop
uninstall:
@rm -rf $(DESTDIR)$(PREFIX)/bin/btop
@rm -rf $(DESTDIR)$(DOCDIR)
@rm -rf $(DESTDIR)$(PREFIX)/share/btop
#Pull in dependency info for *existing* .o files
-include $(OBJECTS:.$(OBJEXT)=.$(DEPEXT))
#Link
$(TARGET): $(OBJECTS)
$(CXX) -o $(TARGETDIR)/$(TARGET) $^
#Compile
$(BUILDDIR)/%.$(OBJEXT): $(SRCDIR)/%.$(SRCEXT)
$(CXX) $(CXXFLAGS) $(INC) -c -o $@ $<
@$(CXX) $(CXXFLAGS) $(INC) -MM $(SRCDIR)/$*.$(SRCEXT) > $(BUILDDIR)/$*.$(DEPEXT)
@cp -f $(BUILDDIR)/$*.$(DEPEXT) $(BUILDDIR)/$*.$(DEPEXT).tmp
@sed -e 's|.*:|$(BUILDDIR)/$*.$(OBJEXT):|' < $(BUILDDIR)/$*.$(DEPEXT).tmp > $(BUILDDIR)/$*.$(DEPEXT)
@sed -e 's/.*://' -e 's/\\$$//' < $(BUILDDIR)/$*.$(DEPEXT).tmp | fmt -1 | sed -e 's/^ *//' -e 's/$$/:/' >> $(BUILDDIR)/$*.$(DEPEXT)
@rm -f $(BUILDDIR)/$*.$(DEPEXT).tmp
#Non-File Targets
.PHONY: all clean dist-clean uninstall
|