From 026be959856001da26c23f60a5416a377b0e5148 Mon Sep 17 00:00:00 2001 From: Bogomil Vasilev Date: Sun, 26 Apr 2015 10:08:34 +0300 Subject: [PATCH] Add install/uninstall to Makefile --- Makefile | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 65f871b..d560837 100644 --- a/Makefile +++ b/Makefile @@ -1,25 +1,26 @@ CXX ?= c++ -CPPFLAGS ?= -O2 -CPPFLAGS += -Wall \ +CXXFLAGS ?= -O2 +CXXFLAGS += -Wall \ -Wextra \ -pipe \ -Wmissing-declarations \ -pedantic \ -fstack-protector-strong \ -LDFLAGS=-lncursesw -Wl,-z,relro,-z,now +LDFLAGS = -lncursesw -Wl,-z,relro,-z,now -SOURCES = main.cpp \ - chess.cpp \ - bishop.cpp \ - rook.cpp \ - queen.cpp \ - king.cpp \ - knight.cpp \ - pawn.cpp +SOURCES = main.cpp \ + chess.cpp \ + bishop.cpp \ + rook.cpp \ + queen.cpp \ + king.cpp \ + knight.cpp \ + pawn.cpp OBJECTS = $(SOURCES:.cpp=.o) EXECUTABLE = chess +INSTALLDIR := $(DESTDIR)/usr/bin all: $(SOURCES) $(EXECUTABLE) @@ -29,10 +30,17 @@ $(EXECUTABLE): $(OBJECTS) .cpp.o: @echo ' CC $@' - @$(CXX) $(CPPFLAGS) -c $< -o $@ + @$(CXX) $(CXXFLAGS) -c $< -o $@ clean: rm -rf $(OBJECTS) $(EXECUTABLE) distclean: rm -rf $(OBJECTS) + +install: + install -m755 -D $(EXECUTABLE) "$(INSTALLDIR)/$(EXECUTABLE)" + +uninstall: + rm -f "$(INSTALLDIR)/$(EXECUTABLE)" +