summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt8
-rw-r--r--Makefile70
-rw-r--r--bin/obj/sha2560
4 files changed, 17 insertions, 63 deletions
diff --git a/.gitignore b/.gitignore
index 259148f..baa0e17 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,3 +30,5 @@
*.exe
*.out
*.app
+
+CMakeCache.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..c830847
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,8 @@
+cmake_minimum_required(VERSION 2.8.9)
+project(hmacsha256)
+
+include_directories(include)
+
+file(GLOB SOURCES "src/*.cc")
+
+add_executable(hmacsha256 ${SOURCES})
diff --git a/Makefile b/Makefile
index 97a0990..d9cd914 100644
--- a/Makefile
+++ b/Makefile
@@ -1,67 +1,11 @@
+.PHONY: make_build
+make_build:
+ mkdir build && cd build && cmake .. && make
-CXX ?= g++
-CPPFLAGS ?= -pipe -O2 -Wall -Wextra -fPIC -std=c++14
+prerequisites: make_build
-OK_STRING = "[OK]"
-ERROR_STRING = "[ERROR]"
-WARN_STRING = "[WARNING]"
-COM_STRING = "Compiling"
-
-SRC_DIR := src
-HEADER_DIR := include
-BIN_DIR := bin
-OBJ_DIR := $(BIN_DIR)/obj
-MAIN := $(SRC_DIR)/main.cc
-SOURCES := $(filter-out $(SRC_DIR)/main.cc, $(wildcard $(SRC_DIR)/*.cc))
-OBJECTS := $(SOURCES:$(SRC_DIR)/%.cc=$(OBJ_DIR)/%.o)
-EXECUTABLE := $(BIN_DIR)/hmacsha256
-
-clean: COUNT=$(words $(wildcard $(OBJ_DIR)/*.o))
-
-all: $(EXECUTABLE)
-
-$(EXECUTABLE): $(OBJECTS) $(MAIN)
- @script -q -e -c '$(CXX) -I$(HEADER_DIR) -o $@ $(OBJECTS) $(MAIN)' $@.log > /dev/null; \
- RESULT=$$?; \
- sed -i '1d;$$d' $@.log; \
- sed -i '/^[[:space:]]*$$/d' $@.log; \
- if [ $$RESULT -ne 0 ]; then \
- printf "%-60b%b" "Building $@" "$(ERROR_STRING)\n"; \
- elif [ -s $@.log ]; then \
- printf "%-60b%b" "Building $@" "$(WARN_STRING)\n"; \
- else \
- printf "%-60b%b" "Building $@" "$(OK_STRING)\n"; \
- printf "%b" "Build success\n"; \
- fi; \
- cat $@.log; \
- rm -f $@.log; \
-
-$(OBJECTS): $(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc
- @script -q -e -c '$(CXX) $(CPPFLAGS) -c -I$(HEADER_DIR) $< -o $@' $@.log > /dev/null; \
- RESULT=$$?; \
- sed -i '1d;$$d' $@.log; \
- sed -i '/^[[:space:]]*$$/d' $@.log; \
- if [ $$RESULT -ne 0 ]; then \
- printf "%-60b%b" "$(COM_STRING) $@" "$(ERROR_STRING)\n"; \
- elif [ -s $@.log ]; then \
- printf "%-60b%b" "$(COM_STRING) $@" "$(WARN_STRING)\n"; \
- else \
- printf "%-60b%b" "$(COM_STRING) $@" "$(OK_STRING)\n"; \
- fi; \
- cat $@.log; \
- rm -f $@.log; \
+target: prerequisites
+.PHONY: clean
clean:
- @if [ $(COUNT) -ne 0 ] || [ -f $(EXECUTABLE) ]; then \
- if [ $(COUNT) -ne 0 ]; then \
- printf "%b" "Cleaning objects\n"; \
- rm -f $(OBJ_DIR)/*.o; \
- fi; \
- if [ -f $(EXECUTABLE) ]; then \
- printf "%b" "Removing executable\n"; \
- rm -f $(EXECUTABLE); \
- fi; \
- printf "%b" "Clean complete\n"; \
- else \
- printf "%b" "Nothing to clean\n"; \
- fi;
+ rm -rf build/
diff --git a/bin/obj/sha256 b/bin/obj/sha256
deleted file mode 100644
index e69de29..0000000
--- a/bin/obj/sha256
+++ /dev/null