-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (38 loc) · 1.24 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
CC = g++
CXX = $(CC)
CFLAGS = -O3 -Ofast -Wall -W
#-ansi -pedantic
CXXFLAGS = $(CFLAGS)
ALL_CFLAGS = $(CFLAGS) -std=gnu++11 -c -o
ALL_CXXFLAGS = $(CXXFLAGS) -std=gnu++11 -c -o
TARGET = calc
SRCDIR = src/
STACKDIR = $(SRCDIR)calc_stacks/
SOURCES = $(wildcard $(SRCDIR)*.cpp $(STACKDIR)*.cpp)
OBJDIR = $(SRCDIR)obj/
OBJECTS = $(addprefix $(OBJDIR), $(subst .cpp,.o,$(notdir $(SOURCES))))
INCLUDE = -I$(SRCDIR)include/
LIBS = -lreadline
PREFIX=/usr/local/
INSTALL_PREFIX=$(PREFIX)
INSTALL_DIR = $(INSTALL_PREFIX)bin/
MANPATH=$(INSTALL_PREFIX)share/man/man1/
MANPAGE=doc/man/man1/$(TARGET).1
all: $(TARGET) doc
$(TARGET): $(OBJECTS)
$(CXX) -o $(TARGET) $^ $(LIBS)
$(OBJDIR)%.o: $(SRCDIR)%.cpp
@if [ ! -d "$(OBJDIR)" ]; then mkdir $(OBJDIR); fi
$(CXX) $(ALL_CXXFLAGS) $@ $< $(INCLUDE)
$(OBJDIR)%.o: $(STACKDIR)%.cpp
$(CXX) $(ALL_CXXFLAGS) $@ $< $(INCLUDE)
.PHONY: clean cleanall install
clean:
-rm -f $(OBJECTS)
cleanall:
@if [ -f $(TARGET) ]; then rm -f $(TARGET); else echo "Target already removed"; fi
@if [ -d $(OBJDIR) ]; then rm -r $(OBJDIR); else echo "Objects already removed"; fi
install:
@cp "$(TARGET)" "$(INSTALL_DIR)" && echo Successfully installed;
-mkdir -p $(MANPATH);
@cp "$(MANPAGE)" "$(MANPATH)" && echo Man page made available;