49 lines
1.1 KiB
Makefile

CXX := g++
CFLAGS := -std=c++11 -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: cross_test
cross_test:
make -s mrproper && make -s CXX=x86_64-pc-linux-gnu-g++
make -s mrproper && make -s CXX=aarch64-unknown-linux-gnu-g++
.PHONY: check-cxx-works
check-cxx-works:
@${CXX} --version >/dev/null 2>&1 || (echo 'Please install a C++ compiler.' && exit 1)