diff --git a/Makefile b/Makefile index de45dd68e..d0a80379c 100644 --- a/Makefile +++ b/Makefile @@ -1,226 +1,98 @@ -# CMAKE generated file: DO NOT EDIT! -# Generated by "Unix Makefiles" Generator, CMake Version 3.5 +.PHONY: pretty clean ChangeLog.md -# Default target executed when no arguments are given to make. -default_target: all +# used programs +RE2C = re2c +SED = sed -.PHONY : default_target +# main target +all: json_unit -# Allow only one "make -f Makefile2" at a time, but pass parallelism. -.NOTPARALLEL: - - -#============================================================================= -# Special targets provided by cmake. - -# Disable implicit rules so canonical targets will work. -.SUFFIXES: - - -# Remove some rules from gmake that .SUFFIXES does not remove. -SUFFIXES = - -.SUFFIXES: .hpux_make_needs_suffix_list - - -# Suppress display of executed commands. -$(VERBOSE).SILENT: - - -# A target that is always out of date. -cmake_force: - -.PHONY : cmake_force - -#============================================================================= -# Set environment variables for the build. - -# The shell in which to execute make rules. -SHELL = /bin/sh - -# The CMake executable. -CMAKE_COMMAND = /usr/local/Cellar/cmake/3.5.1/bin/cmake - -# The command to remove a file. -RM = /usr/local/Cellar/cmake/3.5.1/bin/cmake -E remove -f - -# Escaping for special characters. -EQUALS = = - -# The top-level source directory on which CMake was run. -CMAKE_SOURCE_DIR = /Users/cameron/Projects/json - -# The top-level build directory on which CMake was run. -CMAKE_BINARY_DIR = /Users/cameron/Projects/json - -#============================================================================= -# Targets provided globally by CMake. - -# Special rule for the target rebuild_cache -rebuild_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..." - /usr/local/Cellar/cmake/3.5.1/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : rebuild_cache - -# Special rule for the target rebuild_cache -rebuild_cache/fast: rebuild_cache - -.PHONY : rebuild_cache/fast - -# Special rule for the target list_install_components -list_install_components: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\"" -.PHONY : list_install_components - -# Special rule for the target list_install_components -list_install_components/fast: list_install_components - -.PHONY : list_install_components/fast - -# Special rule for the target install -install: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/Cellar/cmake/3.5.1/bin/cmake -P cmake_install.cmake -.PHONY : install - -# Special rule for the target install -install/fast: preinstall/fast - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..." - /usr/local/Cellar/cmake/3.5.1/bin/cmake -P cmake_install.cmake -.PHONY : install/fast - -# Special rule for the target install/strip -install/strip: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..." - /usr/local/Cellar/cmake/3.5.1/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake -.PHONY : install/strip - -# Special rule for the target install/strip -install/strip/fast: install/strip - -.PHONY : install/strip/fast - -# Special rule for the target install/local -install/local: preinstall - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..." - /usr/local/Cellar/cmake/3.5.1/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake -.PHONY : install/local - -# Special rule for the target install/local -install/local/fast: install/local - -.PHONY : install/local/fast - -# Special rule for the target edit_cache -edit_cache: - @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake cache editor..." - /usr/local/Cellar/cmake/3.5.1/bin/ccmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) -.PHONY : edit_cache - -# Special rule for the target edit_cache -edit_cache/fast: edit_cache - -.PHONY : edit_cache/fast - -# The main all target -all: cmake_check_build_system - $(CMAKE_COMMAND) -E cmake_progress_start /Users/cameron/Projects/json/CMakeFiles /Users/cameron/Projects/json/CMakeFiles/progress.marks - $(MAKE) -f CMakeFiles/Makefile2 all - $(CMAKE_COMMAND) -E cmake_progress_start /Users/cameron/Projects/json/CMakeFiles 0 -.PHONY : all - -# The main clean target +# clean up clean: - $(MAKE) -f CMakeFiles/Makefile2 clean -.PHONY : clean - -# The main clean target -clean/fast: clean - -.PHONY : clean/fast - -# Prepare targets for installation. -preinstall: all - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall - -# Prepare targets for installation. -preinstall/fast: - $(MAKE) -f CMakeFiles/Makefile2 preinstall -.PHONY : preinstall/fast - -# clear depends -depend: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1 -.PHONY : depend - -#============================================================================= -# Target rules for targets named json_unit - -# Build rule for target. -json_unit: cmake_check_build_system - $(MAKE) -f CMakeFiles/Makefile2 json_unit -.PHONY : json_unit - -# fast build rule for target. -json_unit/fast: - $(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/build -.PHONY : json_unit/fast - -test/unit.o: test/unit.cpp.o - -.PHONY : test/unit.o - -# target to build an object file -test/unit.cpp.o: - $(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.o -.PHONY : test/unit.cpp.o - -test/unit.i: test/unit.cpp.i - -.PHONY : test/unit.i - -# target to preprocess a source file -test/unit.cpp.i: - $(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.i -.PHONY : test/unit.cpp.i - -test/unit.s: test/unit.cpp.s - -.PHONY : test/unit.s - -# target to generate assembly for a file -test/unit.cpp.s: - $(MAKE) -f CMakeFiles/json_unit.dir/build.make CMakeFiles/json_unit.dir/test/unit.cpp.s -.PHONY : test/unit.cpp.s - -# Help Target -help: - @echo "The following are some of the valid targets for this Makefile:" - @echo "... all (the default if no target is provided)" - @echo "... clean" - @echo "... depend" - @echo "... rebuild_cache" - @echo "... list_install_components" - @echo "... install" - @echo "... install/strip" - @echo "... install/local" - @echo "... edit_cache" - @echo "... json_unit" - @echo "... test/unit.o" - @echo "... test/unit.i" - @echo "... test/unit.s" -.PHONY : help + rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM +########################################################################## +# unit tests +########################################################################## -#============================================================================= -# Special targets to cleanup operation of make. +# additional flags +FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal -# Special rule to run CMake to check the build system integrity. -# No rule that depends on this can have commands that come from listfiles -# because they might be regenerated. -cmake_check_build_system: - $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0 -.PHONY : cmake_check_build_system +# build unit tests +json_unit: test/unit.cpp src/json.hpp test/catch.hpp + $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@ + +########################################################################## +# documentation tests +########################################################################## + +# compile example files and check output +doctest: + make check_output -C doc + + +########################################################################## +# fuzzing +########################################################################## + +# the overall fuzz testing target +fuzz_testing: + rm -fr fuzz-testing + mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out + $(MAKE) fuzz CXX=afl-clang++ + mv fuzz fuzz-testing + find test/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases + @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz" + +# the fuzzer binary +fuzz: test/fuzz.cpp src/json.hpp + $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@ + + +########################################################################## +# static analyzer +########################################################################## + +# call cppcheck on the main header file +cppcheck: + cppcheck --enable=all --inconclusive --std=c++11 src/json.hpp + + +########################################################################## +# maintainer targets +########################################################################## + +# create scanner with re2c +re2c: src/json.hpp.re2c + $(RE2C) --bit-vectors --nested-ifs --no-debug-info $< | $(SED) '1d' > src/json.hpp + +# pretty printer +pretty: + astyle --style=allman --indent=spaces=4 --indent-modifiers \ + --indent-switches --indent-preproc-block --indent-preproc-define \ + --indent-col1-comments --pad-oper --pad-header --align-pointer=type \ + --align-reference=type --add-brackets --convert-tabs --close-templates \ + --lineend=linux --preserve-date --suffix=none --formatted \ + src/json.hpp src/json.hpp.re2c test/unit.cpp test/fuzz.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp + + +########################################################################## +# benchmarks +########################################################################## + +# benchmarks +json_benchmarks: benchmarks/benchmarks.cpp benchmarks/benchpress.hpp benchmarks/cxxopts.hpp src/json.hpp + $(CXX) -std=c++11 $(CXXFLAGS) -O3 -flto -I src -I benchmarks $< $(LDFLAGS) -o $@ + ./json_benchmarks + + +########################################################################## +# changelog +########################################################################## + +ChangeLog.md: + github_changelog_generator -o ChangeLog.md --simple-list --release-url https://github.com/nlohmann/json/releases/tag/%s + gsed -i 's|https://github.com/nlohmann/json/releases/tag/HEAD|https://github.com/nlohmann/json/tree/HEAD|' ChangeLog.md + gsed -i '2i All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/).' ChangeLog.md