44 lines
983 B
Makefile
44 lines
983 B
Makefile
CXX := g++
|
|
CFLAGS := -std=c++11 -m64 -Wall -Werror -Wextra -O3
|
|
|
|
.PHONY: all
|
|
all: bin/format_time bin/format_time_ns
|
|
|
|
bin:
|
|
@mkdir -v bin
|
|
|
|
bin/format_time: src/format_time.cpp src/toolbox.cpp | check-cxx-works bin
|
|
@echo Compiling $<
|
|
@${CXX} ${CFLAGS} $^ -o $@
|
|
|
|
bin/format_time_ns: src/format_time_ns.cpp src/toolbox.cpp | check-cxx-works bin
|
|
@echo Compiling $^
|
|
@${CXX} ${CFLAGS} $^ -o $@
|
|
|
|
bin/format_time_test: src/format_time.cpp src/format_time_ns.cpp src/toolbox.cpp src/unit_test.cpp | check-cxx-works bin
|
|
@echo Compiling $^
|
|
@${CXX} ${CFLAGS} -DTEST $^ -o $@
|
|
|
|
.PHONY: install
|
|
install: bin/format_time bin/format_time_ns
|
|
@cp -v $^ /usr/bin
|
|
|
|
.PHONY: uninstall
|
|
uninstall: /usr/bin/format_time /usr/bin/format_time_ns
|
|
@rm -v $^
|
|
|
|
.PHONY: test
|
|
test: bin/format_time_test
|
|
@./$^
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
@rm -rfv bin
|
|
|
|
.PHONY: mrproper
|
|
mrproper: clean
|
|
|
|
.PHONY: check-cxx-works
|
|
check-cxx-works:
|
|
@${CXX} --version >/dev/null 2>&1 || (echo 'Please install a C++ compiler.' && exit 1)
|