diff options
author | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2024-05-21 01:29:20 +0200 |
---|---|---|
committer | Rafael G. Martins <rafael@rafaelmartins.eng.br> | 2024-05-21 01:29:20 +0200 |
commit | b54b8f5b25403cf3b9623804b2491ec78a8b913e (patch) | |
tree | 8100b69a2fd1e37d1eb400a33c92ec3c984f208b | |
parent | 0bbc18869720ad042b668742ca48e5cb8a37491a (diff) | |
download | blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.tar.gz blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.tar.bz2 blogc-b54b8f5b25403cf3b9623804b2491ec78a8b913e.zip |
build: replace autotools with cmake
this patch removes all the autoconf/automake/libtool build
infrastructure and replaces it with cmake.
notable default behavior changes:
- man pages are not pre-built, and are not built by default, must be
enabled with `-DBUILD_MANPAGES=ON`.
removed features:
- srpm packaging, to be reintroduced at some point.
- deb packaging, now handled externally via rafaelmartins/deb.rgm.io
more stuff must be missing, please report bugs!
57 files changed, 1102 insertions, 3378 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..d00a04c --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,263 @@ +name: Main + +on: + - push + +defaults: + run: + shell: bash + +jobs: + test: + runs-on: ${{ matrix.os }} + + strategy: + fail-fast: false + + matrix: + os: + - ubuntu-latest + cc: + - gcc + - clang + variant: + - default + - memcheck + - make-embedded + include: + - os: macos-latest + cc: clang + variant: default + - os: ubuntu-latest + cc: clang + variant: clang-analyzer + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + + - name: Install dependencies (Ubuntu) + if: ${{ matrix.os == 'ubuntu-latest' }} + run: | + sudo apt install -y libcmocka-dev ninja-build ronn + if [[ "${{ matrix.variant }}" = "memcheck" ]]; then + sudo apt install -y valgrind + fi + if [[ "${{ matrix.variant }}" = "clang-analyzer" ]]; then + sudo apt install -y clang-tools + fi + + - name: Install dependencies (MacOS) + if: ${{ matrix.os == 'macos-latest' }} + run: | + brew install cmocka coreutils groff ninja + gem install ronn-ng + + - name: Setup clang-analyzer wrapper (if needed) + id: clang-analyzer + run: | + wrapper= + if [[ "${{ matrix.variant }}" = "clang-analyzer" ]]; then + wrapper="scan-build -o ${{ github.workspace }}/reports --use-cc=clang" + fi + echo "wrapper=${wrapper}" >> $GITHUB_OUTPUT + + - name: Configure CMake (default) + if: ${{ matrix.variant != 'make-embedded' }} + run: | + ${{ steps.clang-analyzer.outputs.wrapper }} cmake \ + -B ${{ github.workspace }}/build \ + -DCMAKE_C_COMPILER=${{ matrix.cc }} \ + -DBUILD_BLOGC_GIT_RECEIVER=ON \ + -DBUILD_BLOGC_MAKE=ON \ + -DBUILD_BLOGC_RUNSERVER=ON \ + -DBUILD_MANPAGES=ON \ + -DBUILD_TESTING=ON \ + -S ${{ github.workspace }} \ + -G Ninja + + - name: Configure CMake (make-embedded) + if: ${{ matrix.variant == 'make-embedded' }} + run: | + cmake \ + -B ${{ github.workspace }}/build \ + -DCMAKE_C_COMPILER=${{ matrix.cc }} \ + -DBUILD_BLOGC_MAKE_EMBEDDED=ON \ + -DBUILD_TESTING=ON \ + -S ${{ github.workspace }} \ + -G Ninja + + - name: Build + run: | + ${{ steps.clang-analyzer.outputs.wrapper }} cmake \ + --build ${{ github.workspace }}/build \ + --config RelWithDebInfo + + - name: Test (default) + working-directory: ${{ github.workspace }}/build + env: + VARIANT: ${{ matrix.variant }} + run: | + ${{ steps.clang-analyzer.outputs.wrapper }} ctest \ + --verbose \ + --build-config RelWithDebInfo + + - uses: actions/upload-artifact@v4 + if: ${{ matrix.variant == 'clang-analyzer' }} + id: clang-analyzer-upload + with: + name: clang-analyzer + path: reports + if-no-files-found: ignore + + - name: Check clang-analyzer status + if: ${{ matrix.variant == 'clang-analyzer' && steps.clang-analyzer-upload.outputs.artifact-id != '' }} + run: | + echo "::error title=Error hint::clang-analyzer found bugs!" + exit 1 + + package: + runs-on: ubuntu-latest + + strategy: + fail-fast: false + + matrix: + pkg: + - source + - linux-amd64 + - linux-amd64-static + - linux-amd64-make-embedded + - linux-amd64-make-embedded-static + - windows-i686 + - windows-amd64 + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + + - name: Install dependencies + run: | + sudo apt install -y ninja-build ronn + if [[ "${{ matrix.pkg }}" = "windows-i686" ]]; then + sudo apt install -y gcc-mingw-w64-i686 + fi + if [[ "${{ matrix.pkg }}" = "windows-amd64" ]]; then + sudo apt install -y gcc-mingw-w64-x86-64 + fi + if [[ "${{ matrix.pkg }}" = *-static ]]; then + sudo apt install -y musl-dev + fi + + - name: Configure CMake (Default) + if: ${{ !startsWith(matrix.pkg, 'windows-') }} + run: | + cmake \ + -B ${{ github.workspace }}/build \ + -DCMAKE_C_COMPILER=$([[ "${{ matrix.pkg }}" = *-static ]] && echo x86_64-linux-musl-gcc || echo gcc) \ + -DCMAKE_C_FLAGS="-Wall" \ + -DCMAKE_EXE_LINKER_FLAGS="$([[ "${{ matrix.pkg }}" = *-static ]] && echo -static)" \ + -DCPACK_PACKAGE_FILE_NAME_SUFFIX="$([[ "${{ matrix.pkg }}" != "source" ]] && echo "${{ matrix.pkg }}")" \ + -DBUILD_BLOGC_GIT_RECEIVER=$([[ "${{ matrix.pkg }}" != *-make-embedded* ]] && echo ON || echo OFF) \ + -DBUILD_BLOGC_MAKE=ON \ + -DBUILD_BLOGC_MAKE_EMBEDDED=$([[ "${{ matrix.pkg }}" = *-make-embedded* ]] && echo ON || echo OFF) \ + -DBUILD_BLOGC_RUNSERVER=$([[ "${{ matrix.pkg }}" != *-make-embedded* ]] && echo ON || echo OFF) \ + -DBUILD_MANPAGES=$([[ "${{ matrix.pkg }}" != *-make-embedded* ]] && echo ON || echo OFF) \ + -S ${{ github.workspace }} \ + -G Ninja + + - name: Configure CMake (Windows) + if: ${{ startsWith(matrix.pkg, 'windows-') }} + run: | + cmake \ + -B ${{ github.workspace }}/build \ + -DCMAKE_C_COMPILER=$([[ "${{ matrix.pkg }}" = "windows-i686" ]] && echo i686-w64-mingw32-gcc || echo x86_64-w64-mingw32-gcc) \ + -DCMAKE_C_FLAGS="-Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" \ + -DCMAKE_SYSTEM_NAME=Windows \ + -S ${{ github.workspace }} \ + -G Ninja + + - name: Build + run: | + cmake \ + --build ${{ github.workspace }}/build \ + --config Release \ + --target $([[ "${{ matrix.pkg }}" = "source" ]] && echo package_source || echo package) + + - uses: actions/upload-artifact@v4 + with: + name: ${{ matrix.pkg }} + path: build/blogc-* + + validate-source: + runs-on: ubuntu-latest + needs: package + steps: + - uses: actions/download-artifact@v4 + with: + name: source + path: source + + - name: Install dependencies + run: sudo apt install -y ninja-build ronn + + - name: Validate source + run: | + pushd source > /dev/null + sha512sum -c blogc-*.tar.xz.sha512 + popd > /dev/null + + tar -xvf source/blogc-*.tar.xz + + cmake \ + -B ${{ github.workspace }}/build \ + -DCMAKE_C_COMPILER=gcc \ + -DBUILD_BLOGC_GIT_RECEIVER=ON \ + -DBUILD_BLOGC_MAKE=ON \ + -DBUILD_BLOGC_RUNSERVER=ON \ + -DBUILD_MANPAGES=ON \ + -S ${{ github.workspace }}/blogc-* \ + -G Ninja + + cmake \ + --build ${{ github.workspace }}/build \ + --config Release + + ${{ github.workspace }}/build/src/blogc/blogc -v | grep -iv Unknown + ${{ github.workspace }}/build/src/blogc-make/blogc-make -v | grep -iv Unknown + ${{ github.workspace }}/build/src/blogc-runserver/blogc-runserver -v | grep -iv Unknown + + release: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: + - test + - validate-source + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + ref: ${{ github.ref }} + + - uses: actions/download-artifact@v4 + with: + path: artifacts + merge-multiple: true + + - name: Get release metadata + id: meta + run: | + version="$(echo "${{ github.ref }}" | sed 's,refs/tags/v,,')" + echo "name=$(git tag -l --format="%(contents:subject)" "v${version}")" >> $GITHUB_OUTPUT + git tag -l --format="%(contents:body)" "v${version}" > body.txt + + - uses: ncipollo/release-action@2c591bcc8ecdcd2db72b97d6147f871fcd833ba5 + with: + name: ${{ steps.meta.outputs.name }} + artifacts: "artifacts/blogc-*" + bodyFile: body.txt + generateReleaseNotes: true diff --git a/.github/workflows/yatr.yaml b/.github/workflows/yatr.yaml deleted file mode 100644 index 897c41e..0000000 --- a/.github/workflows/yatr.yaml +++ /dev/null @@ -1,100 +0,0 @@ -name: yatr -on: - - push - -jobs: - yatr: - runs-on: "${{ matrix.image }}" - - strategy: - fail-fast: false - matrix: - target: - - distcheck - - valgrind - - check-make-embedded - compiler: - - gcc - - clang - image: - - ubuntu-20.04 - include: - - target: distcheck - compiler: clang - image: macos-10.15 - - target: clang-analyzer - compiler: clang - image: ubuntu-20.04 - - target: dist-srpm - compiler: gcc - image: ubuntu-20.04 - - target: deb-bullseye-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: deb-bookworm-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: deb-sid-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: deb-focal-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: deb-jammy-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: deb-kinetic-amd64 - compiler: gcc - image: ubuntu-22.04 - - target: static - compiler: gcc - image: ubuntu-20.04 - - target: static-all - compiler: gcc - image: ubuntu-20.04 - - target: win32 - compiler: gcc - image: ubuntu-20.04 - - target: win64 - compiler: gcc - image: ubuntu-20.04 - - steps: - - name: Check out code - uses: actions/checkout@v2 - - - name: Install dependencies - run: | - if [[ "x${{ matrix.image }}" = xubuntu-* ]]; then - sudo gem install ronn - sudo apt-get update -y - if [[ "x${{ matrix.target }}" = *check* ]] || [[ "x${{ matrix.target }}" = xvalgrind ]] || [[ "x${{ matrix.target }}" = xdeb-* ]]; then - sudo apt-get install -y libcmocka-dev - fi - if [[ "x${{ matrix.target }}" = xvalgrind ]]; then - sudo apt-get install -y valgrind - fi - if [[ "x${{ matrix.target }}" = xclang-analyzer ]]; then - sudo apt-get install -y clang-tools - fi - if [[ "x${{ matrix.target }}" = xwin32 ]]; then - sudo apt-get install -y gcc-mingw-w64-i686 - fi - if [[ "x${{ matrix.target }}" = xwin64 ]]; then - sudo apt-get install -y gcc-mingw-w64-x86-64 - fi - if [[ "x${{ matrix.target }}" = xdeb-* ]]; then - sudo apt-get install -y cowbuilder debhelper pbuilder reprepro - fi - elif [[ "x${{ matrix.image }}" = xmacos-* ]]; then - gem install ronn - brew install automake coreutils cmocka pkg-config - fi - - - name: Run yatr - env: - CC: "${{ matrix.compiler }}" - TARGET: "${{ matrix.target }}" - DISTFILES_URL: "${{ secrets.DISTFILES_URL }}" - DISABLE_PUBLISHER: "${{ matrix.compiler != 'gcc' && matrix.target != 'clang-analyzer' }}" - run: curl -sSf https://yatr.rgm.io/run.sh | bash @@ -1,124 +1,15 @@ -# Object files -*.o -*.ko - -# Libraries -*.lib -*.a - -# Shared objects (inc. Windows DLLs) -*.dll -*.so -*.so.* -*.dylib - -# Executables -*.exe -*.out -*.app - -# Autotools +# CMake +build*/ +CMakeLists.txt.user +CMakeCache.txt +CMakeFiles +CMakeScripts +Testing Makefile -Makefile.in -.deps -.libs -*.la -*.lo -/aclocal.m4 -/configure -/configure~ -/config.* -/autom4te.cache -/libtool -/stamp-h1 -.dirstamp -/build-aux/* -!/build-aux/build-*.sh -!/build-aux/check-make-embedded.sh -!/build-aux/clang-analyzer.sh -!/build-aux/git-version-gen -!/build-aux/valgrind.sh - -# debian -debian/.debhelper -debian/autoreconf.* -debian/*.log -debian/*.substvars -debian/debhelper-build-stamp -debian/files -debian/blogc/ -debian/blogc-git-receiver/ -debian/blogc-make/ -debian/blogc-runserver/ -debian/tmp/ - -# installed .m4 files -/m4/*.m4 -!/m4/ax_pthread.m4 -!/m4/pkg.m4 - -# man pages -/blogc*.[157] -blogc*.html - -# binaries -/blogc -/blogc-git-receiver -/blogc-make -/blogc-runserver - -# tests -/tests/blogc/check_blogc.sh -/tests/blogc/check_content_parser -/tests/blogc/check_datetime_parser -/tests/blogc/check_filelist_parser -/tests/blogc/check_funcvars -/tests/blogc/check_loader -/tests/blogc/check_renderer -/tests/blogc/check_rusage -/tests/blogc/check_source_parser -/tests/blogc/check_sysinfo -/tests/blogc/check_sysinfo2 -/tests/blogc/check_template_parser -/tests/blogc/check_toctree -/tests/blogc-git-receiver/check_pre_receive_parser -/tests/blogc-git-receiver/check_pre_receive.sh -/tests/blogc-git-receiver/check_post_receive.sh -/tests/blogc-git-receiver/check_settings -/tests/blogc-git-receiver/check_shell_command_parser -/tests/blogc-git-receiver/check_shell.sh -/tests/blogc-make/check_atom -/tests/blogc-make/check_blogc_make.sh -/tests/blogc-make/check_exec -/tests/blogc-make/check_rules -/tests/blogc-make/check_settings -/tests/blogc-make/check_utils -/tests/blogc-runserver/check_httpd_utils -/tests/blogc-runserver/check_mime -/tests/common/check_config_parser -/tests/common/check_error -/tests/common/check_sort -/tests/common/check_stdin -/tests/common/check_utf8 -/tests/common/check_utils - -# tarballs -blogc-*.tar.* -blogc-*.zip - -# rpms -blogc.spec -blogc-*.rpm - -# git-version-gen -/.version - -# scan-build reports -*.plist - -/build/ -/root/ - -/maint/releases/ +cmake_install.cmake +install_manifest.txt +compile_commands.json +CTestTestfile.cmake +_deps .gdb_history diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3eb825d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "files.associations": { + "*.sh.in": "shellscript" + }, + "[shellscript]": { + "files.trimTrailingWhitespace": false + }, +} diff --git a/.yatr.yml b/.yatr.yml deleted file mode 100644 index 244b9fa..0000000 --- a/.yatr.yml +++ /dev/null @@ -1,85 +0,0 @@ -default_configure_args: - - "CFLAGS=-Wall -g -O0" - - --disable-silent-rules - - --disable-valgrind - - --enable-ronn - - --enable-tests - - --enable-git-receiver - - --enable-make - - --enable-runserver - -targets: - dist-srpm: - configure_args: - - --disable-tests - archive_filter: "*.src.rpm" - clang-analyzer: - configure_args: - - --enable-silent-rules - - --disable-tests - task_script: build-aux/clang-analyzer.sh - archive_extract_filter: "*.tar.xz" - publish_on_failure: true - valgrind: - configure_args: - - --enable-valgrind - check-make-embedded: - configure_args: - - --disable-git-receiver - - --disable-runserver - - --enable-make-embedded - task_script: build-aux/check-make-embedded.sh - static: - configure_args: - - "CFLAGS=-Wall -g -O2" - - --disable-tests - - --disable-git-receiver - - --disable-runserver - - --enable-make-embedded - task_script: build-aux/build-static.sh - static-all: - configure_args: - - "CFLAGS=-Wall -g -O2" - - --disable-tests - - --prefix=/ - task_script: build-aux/build-static-all.sh - win32: - configure_args: - - CC= - - "CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" - - --host=i686-w64-mingw32 - - --target=i686-w64-mingw32 - - --disable-tests - - --disable-git-receiver - - --disable-make - - --disable-runserver - task_script: build-aux/build-windows.sh - win64: - configure_args: - - CC= - - "CFLAGS=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions --param=ssp-buffer-size=4" - - --host=x86_64-w64-mingw32 - - --target=x86_64-w64-mingw32 - - --disable-tests - - --disable-git-receiver - - --disable-make - - --disable-runserver - task_script: build-aux/build-windows.sh - deb-bullseye-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" - deb-bookworm-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" - deb-sid-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" - deb-focal-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" - deb-jammy-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" - deb-kinetic-amd64: - task_script: build-aux/build-debian.sh - archive_extract_filter: "blogc-deb-*.tar.xz" diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..7498ad5 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,144 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.19) + +find_package(Git) + +if (EXISTS "${CMAKE_SOURCE_DIR}/version.cmake") + include("${CMAKE_SOURCE_DIR}/version.cmake") +elseif(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND Git_FOUND) + execute_process( + COMMAND ${GIT_EXECUTABLE} describe --abbrev=4 HEAD + OUTPUT_VARIABLE _blogc_version + ERROR_VARIABLE _blogc_version_err + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}" + RESULT_VARIABLE _blogc_version_result + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(_blogc_version_err) + message(FATAL_ERROR "Failed to find version from Git\n${_blogc_version_err}") + endif() + + if(NOT _blogc_version_result EQUAL 0) + message(FATAL_ERROR "Failed to find version from Git. Git process returned ${_blogc_version_result}") + endif() + + string(REGEX REPLACE "^v" "" _blogc_version "${_blogc_version}") + string(REGEX REPLACE "^([^-]*)-(.*)" "\\1.\\2" _blogc_version "${_blogc_version}") + string(REGEX REPLACE "-g" "-" BLOGC_VERSION "${_blogc_version}") +else() + message(FATAL_ERROR "Can't find version information!") +endif() + +string(REGEX MATCHALL "[0-9]+" _blogc_version_list "${BLOGC_VERSION}") +list(LENGTH _blogc_version_list _blogc_version_list_len) +if(NOT _blogc_version_list_len GREATER_EQUAL 3) + message(FATAL_ERROR "Invalid version: ${BLOGC_VERSION}") +endif() + +list(GET _blogc_version_list 0 _blogc_version_major) +list(GET _blogc_version_list 1 _blogc_version_minor) +list(GET _blogc_version_list 2 _blogc_version_patch) +set(BLOGC_VERSION_CANONICAL "${_blogc_version_major}.${_blogc_version_minor}.${_blogc_version_patch}") + +if(EXISTS "${CMAKE_SOURCE_DIR}/.git" AND _blogc_version_list_len GREATER_EQUAL 4) + list(GET _blogc_version_list 3 _blogc_version_tweak) + set(BLOGC_VERSION_CANONICAL "${BLOGC_VERSION_CANONICAL}.${_blogc_version_tweak}") +endif() + +project(blogc + VERSION "${BLOGC_VERSION_CANONICAL}" + HOMEPAGE_URL "https://blogc.rgm.io/" + LANGUAGES C +) + +# explicitly disable tests by default. +option(BUILD_TESTING "Build the testing tree." OFF) + +enable_testing() + +include(CheckFunctionExists) +include(CheckIncludeFile) +include(CTest) +include(GNUInstallDirs) + +check_function_exists(getrusage HAVE_GETRUSAGE) +check_function_exists(gethostname HAVE_GETHOSTNAME) + +check_include_file(arpa/inet.h HAVE_ARPA_INET_H) +check_include_file(dirent.h HAVE_DIRENT_H) +check_include_file(errno.h HAVE_ERRNO_H) +check_include_file(fcntl.h HAVE_FCNTL_H) +check_include_file(libgen.h HAVE_LIBGEN_H) +check_include_file(limits.h HAVE_LIMITS_H) +check_include_file(netdb.h HAVE_NETDB_H) +check_include_file(netinet/in.h HAVE_NETINET_IN_H) +check_include_file(signal.h HAVE_SIGNAL_H) +check_include_file(sysexits.h HAVE_SYSEXITS_H) +check_include_file(sys/resource.h HAVE_SYS_RESOURCE_H) +check_include_file(sys/socket.h HAVE_SYS_SOCKET_H) +check_include_file(sys/stat.h HAVE_SYS_STAT_H) +check_include_file(sys/time.h HAVE_SYS_TIME_H) +check_include_file(sys/types.h HAVE_SYS_TYPES_H) +check_include_file(sys/wait.h HAVE_SYS_WAIT_H) +check_include_file(time.h HAVE_TIME_H) +check_include_file(unistd.h HAVE_UNISTD_H) + +set(PACKAGE_VERSION "${BLOGC_VERSION}") +configure_file(config.h.in config.h @ONLY) + +include_directories(${CMAKE_BINARY_DIR}) +add_compile_definitions(HAVE_CONFIG_H) + +add_subdirectory(man) +add_subdirectory(src) + +if(BUILD_TESTING) + add_subdirectory(tests) +endif() + +set(CPACK_VERBATIM_VARIABLES YES) + +set(CPACK_PACKAGE_VENDOR "Rafael G. Martins") +set(CPACK_PACKAGE_VERSION "${BLOGC_VERSION}") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "A blog compiler.") +set(CPACK_PACKAGE_CHECKSUM SHA512) + +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") +set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/README.md") +set(CPACK_RESOURCE_FILE_WELCOME "${CMAKE_CURRENT_SOURCE_DIR}/README.md") + +set(CPACK_INSTALL_SCRIPTS + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpack/install_license_and_readme.cmake" + "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cpack/install_version.cmake" +) + +set(CPACK_SOURCE_GENERATOR "TXZ") +set(CPACK_SOURCE_IGNORE_FILES + \\.git + \\.gitignore + \\.github/ + Testing/ + "build.*/" + ".*~$" +) +if(DEFINED CPACK_PACKAGE_NAME) + set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${BLOGC_VERSION}") +else() + set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${BLOGC_VERSION}") +endif() + +if(DEFINED CPACK_PACKAGE_FILE_NAME_SUFFIX) + set(CPACK_PACKAGE_FILE_NAME "${CPACK_SOURCE_PACKAGE_FILE_NAME}-${CPACK_PACKAGE_FILE_NAME_SUFFIX}") +endif() + +if(WIN32) + set(CPACK_GENERATOR "ZIP") +elseif(UNIX) + set(CPACK_GENERATOR "STGZ" "TXZ") +endif() + +include(CPack) diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index 571cb41..0000000 --- a/Makefile.am +++ /dev/null @@ -1,1128 +0,0 @@ -## Autotools settings - -ACLOCAL_AMFLAGS = -I m4 - -AM_DISTCHECK_CONFIGURE_FLAGS = \ - CFLAGS="-Wall -g -O0" \ - --enable-git-receiver \ - --enable-make \ - --enable-ronn \ - --enable-runserver \ - --enable-tests \ - --disable-silent-rules \ - --disable-valgrind \ - $(NULL) - - -## File listings - -EXTRA_DIST = \ - build-aux/git-version-gen \ - build-aux/valgrind.sh \ - $(top_srcdir)/.version \ - autogen.sh \ - blogc.spec \ - LICENSE \ - README.md \ - $(NULL) - -CLEANFILES = \ - $(NULL) - -MAINTAINERCLEANFILES = \ - $(NULL) - -BUILT_SOURCES = \ - $(top_srcdir)/.version \ - $(NULL) - -noinst_HEADERS = \ - src/blogc/content-parser.h \ - src/blogc/datetime-parser.h \ - src/blogc/debug.h \ - src/blogc/filelist-parser.h \ - src/blogc/funcvars.h \ - src/blogc/loader.h \ - src/blogc/renderer.h \ - src/blogc/rusage.h \ - src/blogc/sysinfo.h \ - src/blogc/source-parser.h \ - src/blogc/template-parser.h \ - src/blogc/toctree.h \ - src/blogc-git-receiver/post-receive.h \ - src/blogc-git-receiver/pre-receive.h \ - src/blogc-git-receiver/pre-receive-parser.h \ - src/blogc-git-receiver/settings.h \ - src/blogc-git-receiver/shell.h \ - src/blogc-git-receiver/shell-command-parser.h \ - src/blogc-make/atom.h \ - src/blogc-make/ctx.h \ - src/blogc-make/exec.h \ - src/blogc-make/exec-native.h \ - src/blogc-make/httpd.h \ - src/blogc-make/reloader.h \ - src/blogc-make/rules.h \ - src/blogc-make/settings.h \ - src/blogc-make/utils.h \ - src/blogc-runserver/httpd.h \ - src/blogc-runserver/httpd-utils.h \ - src/blogc-runserver/mime.h \ - src/common/compat.h \ - src/common/config-parser.h \ - src/common/error.h \ - src/common/file.h \ - src/common/sort.h \ - src/common/stdin.h \ - src/common/utf8.h \ - src/common/utils.h \ - $(NULL) - -noinst_LTLIBRARIES = \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -noinst_PROGRAMS = \ - $(NULL) - -bin_PROGRAMS = \ - blogc \ - $(NULL) - -if BUILD_GIT_RECEIVER -bin_PROGRAMS += \ - blogc-git-receiver \ - $(NULL) - -noinst_LTLIBRARIES += \ - libblogc_git_receiver.la \ - $(NULL) -endif - -if BUILD_MAKE -bin_PROGRAMS += \ - blogc-make \ - $(NULL) - -noinst_LTLIBRARIES += \ - libblogc_make.la \ - $(NULL) -endif - -if BUILD_RUNSERVER -bin_PROGRAMS += \ - blogc-runserver \ - $(NULL) - -noinst_LTLIBRARIES += \ - libblogc_runserver.la \ - $(NULL) -endif - -check_PROGRAMS = \ - $(NULL) - -check_SCRIPTS = \ - $(NULL) - - -libblogc_la_SOURCES = \ - src/blogc/content-parser.c \ - src/blogc/datetime-parser.c \ - src/blogc/debug.c \ - src/blogc/filelist-parser.c \ - src/blogc/funcvars.c \ - src/blogc/loader.c \ - src/blogc/renderer.c \ - src/blogc/rusage.c \ - src/blogc/sysinfo.c \ - src/blogc/source-parser.c \ - src/blogc/template-parser.c \ - src/blogc/toctree.c \ - $(NULL) - -libblogc_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) - -libblogc_la_LIBADD = \ - $(LIBM) \ - libblogc_common.la \ - $(NULL) - - -libblogc_common_la_SOURCES = \ - src/common/compat.c \ - src/common/config-parser.c \ - src/common/error.c \ - src/common/file.c \ - src/common/sort.c \ - src/common/stdin.c \ - src/common/utf8.c \ - src/common/utils.c \ - $(NULL) - -libblogc_common_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) - - -blogc_SOURCES = \ - src/blogc/main.c \ - $(NULL) - -blogc_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) - -blogc_LDADD = \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -if BUILD_MAKE_EMBEDDED -blogc_SOURCES += \ - src/blogc-make/main.c \ - $(NULL) - -blogc_LDADD += \ - libblogc_make.la \ - $(NULL) -endif - - -if BUILD_GIT_RECEIVER -blogc_git_receiver_SOURCES = \ - src/blogc-git-receiver/main.c \ - $(NULL) - -blogc_git_receiver_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) - -blogc_git_receiver_LDADD = \ - libblogc_git_receiver.la \ - libblogc_common.la \ - $(NULL) - -libblogc_git_receiver_la_SOURCES = \ - src/blogc-git-receiver/post-receive.c \ - src/blogc-git-receiver/pre-receive.c \ - src/blogc-git-receiver/pre-receive-parser.c \ - src/blogc-git-receiver/settings.c \ - src/blogc-git-receiver/shell.c \ - src/blogc-git-receiver/shell-command-parser.c \ - $(NULL) - -libblogc_git_receiver_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(NULL) - -libblogc_git_receiver_la_LIBADD = \ - libblogc_common.la \ - $(NULL) -endif - - -if BUILD_MAKE -blogc_make_SOURCES = \ - src/blogc-make/main.c \ - $(NULL) - -blogc_make_CFLAGS = \ - $(AM_CFLAGS) \ - $(PTHREAD_CFLAGS) \ - $(NULL) - -blogc_make_LDADD = \ - $(PTHREAD_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) -endif - -if BUILD_MAKE_LIB -libblogc_make_la_SOURCES = \ - src/blogc-make/atom.c \ - src/blogc-make/ctx.c \ - src/blogc-make/exec.c \ - src/blogc-make/exec-native.c \ - src/blogc-make/httpd.c \ - src/blogc-make/reloader.c \ - src/blogc-make/rules.c \ - src/blogc-make/settings.c \ - src/blogc-make/utils.c \ - $(NULL) - -libblogc_make_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(PTHREAD_CFLAGS) \ - $(NULL) - -libblogc_make_la_LIBADD = \ - $(PTHREAD_LIBS) \ - libblogc_common.la \ - $(NULL) -endif - - -if BUILD_RUNSERVER -blogc_runserver_SOURCES = \ - src/blogc-runserver/main.c \ - $(NULL) - -blogc_runserver_CFLAGS = \ - $(AM_CFLAGS) \ - $(PTHREAD_CFLAGS) \ - $(NULL) - -blogc_runserver_LDADD = \ - $(PTHREAD_LIBS) \ - libblogc_runserver.la \ - libblogc_common.la \ - $(NULL) - -libblogc_runserver_la_SOURCES = \ - src/blogc-runserver/httpd.c \ - src/blogc-runserver/httpd-utils.c \ - src/blogc-runserver/mime.c \ - $(NULL) - -libblogc_runserver_la_CFLAGS = \ - $(AM_CFLAGS) \ - $(PTHREAD_CFLAGS) \ - $(NULL) - -libblogc_runserver_la_LIBADD = \ - $(PTHREAD_LIBS) \ - libblogc_common.la \ - $(NULL) -endif - - -## Build rules: man pages - -# README: all the prebuilt manpages that are hidden behind --enable-* -# options should be added here, otherwise they may be not included -# in the distfiles. -EXTRA_DIST += \ - man/blogc.1.ronn \ - man/blogc-git-receiver.1.ronn \ - man/blogc-make.1.ronn \ - man/blogc-runserver.1.ronn \ - man/blogcfile.5.ronn \ - man/blogc-source.7.ronn \ - man/blogc-template.7.ronn \ - man/blogc-toctree.7.ronn \ - man/blogc-pagination.7.ronn \ - man/index.txt \ - blogc-git-receiver.1 \ - blogc-make.1 \ - blogc-runserver.1 \ - blogcfile.5 \ - $(NULL) - -dist_man_MANS = \ - blogc.1 \ - blogc-source.7 \ - blogc-template.7 \ - blogc-toctree.7 \ - blogc-pagination.7 \ - $(NULL) - -if BUILD_GIT_RECEIVER -dist_man_MANS += \ - blogc-git-receiver.1 \ - $(NULL) -endif - -if BUILD_MAKE_LIB -dist_man_MANS += \ - blogc-make.1 \ - blogcfile.5 - $(NULL) -endif - -if BUILD_RUNSERVER -dist_man_MANS += \ - blogc-runserver.1 \ - $(NULL) -endif - -MAINTAINERCLEANFILES += \ - $(dist_man_MANS) \ - $(NULL) - -if BUILD_MANPAGE - -blogc.1: man/blogc.1.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc.1.ronn > blogc.1 - -blogc-git-receiver.1: man/blogc-git-receiver.1.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-git-receiver.1.ronn > blogc-git-receiver.1 - -blogc-make.1: man/blogc-make.1.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-make.1.ronn > blogc-make.1 - -blogc-runserver.1: man/blogc-runserver.1.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-runserver.1.ronn > blogc-runserver.1 - -blogcfile.5: man/blogcfile.5.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogcfile.5.ronn > blogcfile.5 - -blogc-source.7: man/blogc-source.7.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-source.7.ronn > blogc-source.7 - -blogc-template.7: man/blogc-template.7.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-template.7.ronn > blogc-template.7 - -blogc-toctree.7: man/blogc-toctree.7.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-toctree.7.ronn > blogc-toctree.7 - -blogc-pagination.7: man/blogc-pagination.7.ronn - $(AM_V_GEN)$(RONN) \ - --roff \ - --pipe \ - --organization "Rafael G. Martins" \ - --manual "$(PACKAGE_NAME) Manual" \ - $(top_srcdir)/man/blogc-pagination.7.ronn > blogc-pagination.7 - -else - -blogc.1: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-git-receiver.1: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-make.1: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-runserver.1: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-source.7: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-template.7: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-toctree.7: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -blogc-pagination.7: - $(AM_V_GEN)echo "error: ronn not found. failed to build man page: $@"; exit 1 - -endif - - -## Build rules: tests - -if BUILD_TESTS - -if BUILD_GIT_RECEIVER -if USE_BGR_DEPS -check_SCRIPTS += \ - tests/blogc-git-receiver/check_post_receive.sh \ - tests/blogc-git-receiver/check_pre_receive.sh \ - tests/blogc-git-receiver/check_shell.sh \ - $(NULL) -endif -endif - -if BUILD_MAKE -check_SCRIPTS += \ - tests/blogc-make/check_blogc_make.sh \ - $(NULL) -endif - -check_SCRIPTS += \ - tests/blogc/check_blogc.sh \ - $(NULL) - -if USE_CMOCKA - -check_PROGRAMS += \ - tests/blogc/check_content_parser \ - tests/blogc/check_datetime_parser \ - tests/blogc/check_filelist_parser \ - tests/blogc/check_renderer \ - tests/blogc/check_source_parser \ - tests/blogc/check_template_parser \ - tests/blogc/check_toctree \ - tests/common/check_config_parser \ - tests/common/check_error \ - tests/common/check_sort \ - tests/common/check_utf8 \ - tests/common/check_utils \ - $(NULL) - -if USE_LD_WRAP -check_PROGRAMS += \ - tests/blogc/check_funcvars \ - tests/blogc/check_loader \ - tests/blogc/check_sysinfo \ - tests/blogc/check_sysinfo2 \ - tests/common/check_stdin \ - $(NULL) - -tests_blogc_check_funcvars_SOURCES = \ - tests/blogc/check_funcvars.c \ - $(NULL) - -tests_blogc_check_funcvars_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_funcvars_LDFLAGS = \ - -no-install \ - -Wl,--wrap=bc_file_get_contents \ - $(NULL) - -tests_blogc_check_funcvars_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_loader_SOURCES = \ - tests/blogc/check_loader.c \ - $(NULL) - -tests_blogc_check_loader_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_loader_LDFLAGS = \ - -no-install \ - -Wl,--wrap=bc_file_get_contents \ - $(NULL) - -tests_blogc_check_loader_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_sysinfo_SOURCES = \ - tests/blogc/check_sysinfo.c \ - $(NULL) - -tests_blogc_check_sysinfo_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_sysinfo_LDFLAGS = \ - -no-install \ - -Wl,--wrap=bc_file_get_contents \ - -Wl,--wrap=getenv \ - $(NULL) - -if HAVE_NETDB_H -tests_blogc_check_sysinfo_LDFLAGS += \ - -Wl,--wrap=gethostbyname \ - $(NULL) -endif - -if HAVE_UNISTD_H -tests_blogc_check_sysinfo_LDFLAGS += \ - -Wl,--wrap=gethostname \ - $(NULL) -endif - -if HAVE_TIME_H -tests_blogc_check_sysinfo_LDFLAGS += \ - -Wl,--wrap=time \ - -Wl,--wrap=gmtime \ - $(NULL) -endif - -tests_blogc_check_sysinfo_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_sysinfo2_SOURCES = \ - tests/blogc/check_sysinfo2.c \ - $(NULL) - -tests_blogc_check_sysinfo2_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_sysinfo2_LDFLAGS = \ - -no-install \ - -Wl,--wrap=bc_file_get_contents \ - $(NULL) - -tests_blogc_check_sysinfo2_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_common_check_stdin_SOURCES = \ - tests/common/check_stdin.c \ - $(NULL) - -tests_common_check_stdin_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_stdin_LDFLAGS = \ - -no-install \ - -Wl,--wrap=fgetc \ - $(NULL) - -tests_common_check_stdin_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -if HAVE_SYS_RESOURCE_H -if HAVE_SYS_TIME_H -check_PROGRAMS += \ - tests/blogc/check_rusage \ - $(NULL) - -tests_blogc_check_rusage_SOURCES = \ - tests/blogc/check_rusage.c \ - $(NULL) - -tests_blogc_check_rusage_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_rusage_LDFLAGS = \ - -no-install \ - -Wl,--wrap=getrusage \ - $(NULL) - -tests_blogc_check_rusage_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) -endif -endif - -endif - -tests_blogc_check_content_parser_SOURCES = \ - tests/blogc/check_content_parser.c \ - $(NULL) - -tests_blogc_check_content_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_content_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_content_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_datetime_parser_SOURCES = \ - tests/blogc/check_datetime_parser.c \ - $(NULL) - -tests_blogc_check_datetime_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_datetime_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_datetime_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_filelist_parser_SOURCES = \ - tests/blogc/check_filelist_parser.c \ - $(NULL) - -tests_blogc_check_filelist_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_filelist_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_filelist_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_renderer_SOURCES = \ - tests/blogc/check_renderer.c \ - $(NULL) - -tests_blogc_check_renderer_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_renderer_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_renderer_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_source_parser_SOURCES = \ - tests/blogc/check_source_parser.c \ - $(NULL) - -tests_blogc_check_source_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_source_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_source_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_template_parser_SOURCES = \ - tests/blogc/check_template_parser.c \ - $(NULL) - -tests_blogc_check_template_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_template_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_template_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_check_toctree_SOURCES = \ - tests/blogc/check_toctree.c \ - $(NULL) - -tests_blogc_check_toctree_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_check_toctree_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_check_toctree_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc.la \ - libblogc_common.la \ - $(NULL) - -tests_common_check_config_parser_SOURCES = \ - tests/common/check_config_parser.c \ - $(NULL) - -tests_common_check_config_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_config_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_common_check_config_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -tests_common_check_error_SOURCES = \ - tests/common/check_error.c \ - $(NULL) - -tests_common_check_error_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_error_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_common_check_error_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -tests_common_check_sort_SOURCES = \ - tests/common/check_sort.c \ - $(NULL) - -tests_common_check_sort_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_sort_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_common_check_sort_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -tests_common_check_utf8_SOURCES = \ - tests/common/check_utf8.c \ - $(NULL) - -tests_common_check_utf8_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_utf8_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_common_check_utf8_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -tests_common_check_utils_SOURCES = \ - tests/common/check_utils.c \ - $(NULL) - -tests_common_check_utils_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_common_check_utils_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_common_check_utils_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_common.la \ - $(NULL) - -if BUILD_RUNSERVER -if USE_LD_WRAP -check_PROGRAMS += \ - tests/blogc-runserver/check_httpd_utils \ - tests/blogc-runserver/check_mime \ - $(NULL) - -tests_blogc_runserver_check_httpd_utils_SOURCES = \ - tests/blogc-runserver/check_httpd_utils.c \ - $(NULL) - -tests_blogc_runserver_check_httpd_utils_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_runserver_check_httpd_utils_LDFLAGS = \ - -no-install \ - -Wl,--wrap=read \ - $(NULL) - -tests_blogc_runserver_check_httpd_utils_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_runserver.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_runserver_check_mime_SOURCES = \ - tests/blogc-runserver/check_mime.c \ - $(NULL) - -tests_blogc_runserver_check_mime_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_runserver_check_mime_LDFLAGS = \ - -no-install \ - -Wl,--wrap=access \ - $(NULL) - -tests_blogc_runserver_check_mime_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_runserver.la \ - libblogc_common.la \ - $(NULL) -endif -endif - -if BUILD_GIT_RECEIVER -check_PROGRAMS += \ - tests/blogc-git-receiver/check_pre_receive_parser \ - tests/blogc-git-receiver/check_shell_command_parser \ - $(NULL) - -if USE_LD_WRAP -check_PROGRAMS += \ - tests/blogc-git-receiver/check_settings \ - $(NULL) - -tests_blogc_git_receiver_check_settings_SOURCES = \ - tests/blogc-git-receiver/check_settings.c \ - $(NULL) - -tests_blogc_git_receiver_check_settings_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_git_receiver_check_settings_LDFLAGS = \ - -no-install \ - -Wl,--wrap=realpath \ - $(NULL) - -tests_blogc_git_receiver_check_settings_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_git_receiver.la \ - libblogc_common.la \ - $(NULL) -endif - -tests_blogc_git_receiver_check_pre_receive_parser_SOURCES = \ - tests/blogc-git-receiver/check_pre_receive_parser.c \ - $(NULL) - -tests_blogc_git_receiver_check_pre_receive_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_git_receiver_check_pre_receive_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_git_receiver_check_pre_receive_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_git_receiver.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_git_receiver_check_shell_command_parser_SOURCES = \ - tests/blogc-git-receiver/check_shell_command_parser.c \ - $(NULL) - -tests_blogc_git_receiver_check_shell_command_parser_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_git_receiver_check_shell_command_parser_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_git_receiver_check_shell_command_parser_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_git_receiver.la \ - libblogc_common.la \ - $(NULL) -endif - -if BUILD_MAKE_LIB -check_PROGRAMS += \ - tests/blogc-make/check_atom \ - tests/blogc-make/check_rules \ - tests/blogc-make/check_settings \ - tests/blogc-make/check_utils \ - $(NULL) - -if USE_LD_WRAP -check_PROGRAMS += \ - tests/blogc-make/check_exec \ - $(NULL) - -tests_blogc_make_check_exec_SOURCES = \ - tests/blogc-make/check_exec.c \ - $(NULL) - -tests_blogc_make_check_exec_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_make_check_exec_LDFLAGS = \ - -no-install \ - -Wl,--wrap=access \ - $(NULL) - -tests_blogc_make_check_exec_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) -endif - -tests_blogc_make_check_atom_SOURCES = \ - tests/blogc-make/check_atom.c \ - $(NULL) - -tests_blogc_make_check_atom_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_make_check_atom_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_make_check_atom_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_make_check_rules_SOURCES = \ - tests/blogc-make/check_rules.c \ - $(NULL) - -tests_blogc_make_check_rules_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_make_check_rules_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_make_check_rules_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_make_check_settings_SOURCES = \ - tests/blogc-make/check_settings.c \ - $(NULL) - -tests_blogc_make_check_settings_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_make_check_settings_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_make_check_settings_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) - -tests_blogc_make_check_utils_SOURCES = \ - tests/blogc-make/check_utils.c \ - $(NULL) - -tests_blogc_make_check_utils_CFLAGS = \ - $(CMOCKA_CFLAGS) \ - $(NULL) - -tests_blogc_make_check_utils_LDFLAGS = \ - -no-install \ - $(NULL) - -tests_blogc_make_check_utils_LDADD = \ - $(CMOCKA_LIBS) \ - libblogc_make.la \ - libblogc_common.la \ - $(NULL) -endif - -endif - -endif - -TESTS = \ - $(check_PROGRAMS) \ - $(check_SCRIPTS) \ - $(NULL) - -CLEANFILES += \ - $(check_SCRIPTS) \ - $(NULL) - - -## Helpers: dist-srpm - -if BUILD_SRPM -dist-srpm: blogc.spec dist-xz - $(RPMBUILD) \ - --define "_srcrpmdir $(top_builddir)" \ - --define "_sourcedir $(top_builddir)" \ - -bs blogc.spec -endif - - -## Helpers: git-version-gen - -$(top_srcdir)/.version: - echo $(VERSION) > $@-t && mv $@-t $@ - -dist-hook: - echo $(VERSION) > $(distdir)/.tarball-version - - -## Helpers: Valgrind runner - -if USE_VALGRIND -valgrind: all - $(MAKE) check TESTS_ENVIRONMENT=" \ - VALGRIND=$(VALGRIND) \ - $(BASH) -e $(top_srcdir)/build-aux/valgrind.sh" -endif - - -.PHONY: dist-srpm valgrind @@ -1,24 +1,50 @@ # blogc - - A blog compiler. ## Quickstart -Clone the [Git repository](https://github.com/blogc/blogc) or grab the [latest release](https://github.com/blogc/blogc/releases) and extract it. +Clone the [Git repository](https://github.com/blogc/blogc) or grab the [latest release's source tarball](https://github.com/blogc/blogc/releases) and extract it. -If installing from Git repository, [ronn](https://github.com/rtomayko/ronn) and [GNU Autotools](http://www.gnu.org/software/automake/manual/html_node/Autotools-Introduction.html) must be installed in the machine. Release tarballs does not have these dependencies and are the recommended way to install. -Inside the source directory, run the following commands: +### Dependencies + +Building `blogc` requires: + +- [CMake](https://cmake.org/) +- [Ninja](https://ninja-build.org/) (optional, but recommended) +- [ronn-ng](https://github.com/apjanke/ronn-ng) (if configured with `BUILD_MANPAGES=ON`) +- [cmocka](https://cmocka.org/) (if configured with `BUILD_TESTING=ON`) +- bash, diff and tee (if configured with `BUILD_TESTING=ON`) +- git, make and tar (if configured with `BUILD_TESTING=ON` and `BUILD_BLOGC_GIT_RECEIVER=ON`) + +Running the `blogc-git-receiver` tool requires: - $ ./autogen.sh # if installing from git - $ ./configure [--enable-git-receiver] [--enable-make] [--enable-runserver] - $ make - # make install +- git, make and tar + + +### Building and installing + +Inside the source directory, run the following commands: -The `./configure` options listed above will enable building of helper tools. To learn more about these tools, please read the man pages. + $ mkdir build + $ cmake \ + -B build \ + -S . \ + -G Ninja \ + [-DBUILD_BLOGC_GIT_RECEIVER=ON] \ + [-DBUILD_BLOGC_MAKE=ON] \ + [-DBUILD_BLOGC_RUNSERVER=ON] \ + [-DBUILD_MANPAGES=ON] \ + [-DBUILD_TESTING=ON] + $ cmake \ + --build build \ + --config Release + # cmake \ + --build build \ + --config Release \ + --target install To create your first blog, please clone our example repository and adapt it to your needs: diff --git a/autogen.sh b/autogen.sh deleted file mode 100755 index d50080a..0000000 --- a/autogen.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh - -autoreconf \ - --warnings=all \ - --install \ - --force diff --git a/blogc.spec.in b/blogc.spec.in deleted file mode 100644 index d4fd841..0000000 --- a/blogc.spec.in +++ /dev/null @@ -1,241 +0,0 @@ -Name: @PACKAGE_NAME@ -Version: @RPM_VERSION@ -Release: 1%{?dist} -License: BSD -Group: Applications/Text -Summary: A blog compiler -URL: @PACKAGE_URL@ -Source0: https://github.com/blogc/blogc/releases/download/v@PACKAGE_VERSION@/blogc-@PACKAGE_VERSION@.tar.xz -BuildRequires: gcc, bash, coreutils, diffutils -%if ! 0%{?el6} -BuildRequires: git, tar, make -%endif -%if ! 0%{?el8} -BuildRequires: libcmocka-devel -%endif - -%description -blogc(1) is a blog compiler. It compiles source files and templates into -blog/website resources. - -%if ! 0%{?el6} -%package git-receiver -Summary: A simple login shell/git hook to deploy blogc websites -Group: System Environment/Shells -Requires: git, tar, make -Requires: %{name}-make = %{version}-%{release} - -%description git-receiver -blogc-git-receiver is a simple login shell/git hook to deploy blogc websites. -%endif - -%package make -Summary: A simple build tool for blogc -Group: Development/Tools -Requires: %{name} = %{version}-%{release} -Requires: %{name}-runserver = %{version}-%{release} - -%description make -blogc-make is a simple build tool for blogc websites. - -%package runserver -Summary: A simple HTTP server to test blogc websites -Group: Development/Tools - -%description runserver -blogc-runserver is a simple HTTP server to test blogc websites. - -%prep -%setup -q -n @PACKAGE_NAME@-@PACKAGE_VERSION@ - -%build -%define _lto_cflags %{nil} -%if 0%{?el6} -%configure --disable-git-receiver --enable-make --enable-runserver --enable-tests -%else -%if 0%{?el8} -%configure --enable-git-receiver --enable-make --enable-runserver --disable-tests -%else -%configure --enable-git-receiver --enable-make --enable-runserver --enable-tests -%endif -%endif -make %{?_smp_mflags} - -%if ! 0%{?el8} -%check -make check -%endif - -%install -rm -rf $RPM_BUILD_ROOT -%make_install - -%files -%{_mandir}/man*/blogc.* -%{_mandir}/man*/blogc-source.* -%{_mandir}/man*/blogc-template.* -%{_mandir}/man*/blogc-toctree.* -%{_mandir}/man*/blogc-pagination.* -%{_bindir}/blogc -%doc README.md -%license LICENSE - -%if ! 0%{?el6} -%files git-receiver -%{_mandir}/man*/blogc-git-receiver.* -%{_bindir}/blogc-git-receiver -%license LICENSE -%endif - -%files make -%{_mandir}/man*/blogc-make.* -%{_mandir}/man*/blogcfile.* -%{_bindir}/blogc-make -%license LICENSE - -%files runserver -%{_mandir}/man*/blogc-runserver.* -%{_bindir}/blogc-runserver -%license LICENSE - -%changelog -* Sat Jan 02 2021 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.20.1-1 -- New release. - -* Tue Sep 15 2020 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.20.0-1 -- New release. - -* Sun May 31 2020 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.19.0-1 -- New release. - -* Tue Sep 10 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.18.0-1 -- New release. - -* Thu May 2 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.17.0-1 -- New release. - -* Sun Apr 21 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.16.1-1 -- New release. - -* Sat Apr 13 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.16.0-1 -- New release. - -* Tue Feb 26 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.15.1-1 -- New release. - -* Mon Feb 11 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.15.0-1 -- New release. - -* Tue Jan 15 2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.14.1-1 -- New release. - -* Thu Jul 26 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.14.0-1 -- New release. - -* Sun Jul 22 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.10-1 -- New release. - -* Tue Jun 12 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.9-1 -- New release. - -* Sun Jun 10 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.8-1 -- New release. - -* Sun Jun 10 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.7-1 -- New release. - -* Mon May 14 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.6-1 -- New release. - -* Sun May 13 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.5-1 -- New release. - -* Tue Mar 20 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.4-1 -- New release. - -* Wed Mar 14 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.3-1 -- New release. - -* Mon Mar 12 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.2-1 -- New release. - -* Thu Feb 22 2018 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.1-1 -- New release. - -* Sun Nov 19 2017 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.13.0-1 -- New release. - -* Sun Oct 30 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.12.0-1 -- New release. - -* Sun Jul 17 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.11.1-1 -- New release. - -* Tue Jul 5 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.11.0-1 -- New release. - -* Thu Jun 30 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.10.2-1 -- New release. - -* Sun Jun 19 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.10.1-1 -- New release. - -* Mon May 30 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.10.0-1 -- New release. - -* Sat Apr 30 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.9.0-1 -- New release. Merged blogc-git-receiver and blogc-runserver. - -* Sun Apr 17 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.8.1-1 -- New release. - -* Wed Apr 6 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.8.0-1 -- New release. - -* Mon Feb 29 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.6-1 -- New release. Added new dependency. - -* Sun Feb 21 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.5-1 -- New release. - -* Sun Feb 21 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.4-1 -- New release. - -* Sat Feb 20 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.3-1 -- New release. - -* Mon Jan 25 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.2-1 -- New release. - -* Fri Jan 22 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7.1-1 -- New release. - -* Thu Jan 14 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.7-1 -- New release. - -* Sun Jan 10 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.6.1-1 -- New release. - -* Thu Jan 07 2016 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.6-1 -- New release. - -* Thu Dec 03 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.5.1-1 -- New release. - -* Thu Nov 05 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.5-1 -- New release. - -* Sun Oct 25 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.4-1 -- New release. - -* Fri Oct 16 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.3-1 -- New release. - -* Thu Oct 08 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.2.1-1 -- New release. - -* Wed Sep 16 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.1-1 -- First stable release. - -* Mon Sep 14 2015 Rafael G. Martins <rafael@rafaelmartins.eng.br> 0.1-0.1.beta4 -- Initial package. diff --git a/build-aux/build-debian.sh b/build-aux/build-debian.sh deleted file mode 100755 index 5b90c36..0000000 --- a/build-aux/build-debian.sh +++ /dev/null @@ -1,134 +0,0 @@ -#!/bin/bash - -set -exo pipefail - -export DEBEMAIL="rafael+deb@rafaelmartins.eng.br" -export DEBFULLNAME="Automatic Builder (github-actions)" -export DEB_BUILD_OPTIONS="noddebs" - -PBUILDER_CHROOTS_VERSION="202303052042" -PBUILDER_CHROOTS_BASE_URL="https://github.com/rafaelmartins/pbuilder-chroots/releases/download/pbuilder-chroots-amd64-${PBUILDER_CHROOTS_VERSION}" - -MY_P="${PN}_${PV}" -DIST="$(echo "${TARGET}" | cut -d- -f2)" -ARCH="$(echo "${TARGET}" | cut -d- -f3)" -DISTRO="$(wget -q -O- "${PBUILDER_CHROOTS_BASE_URL}/DISTROS" | grep "${DIST}")" -DEB_VERSION="$(echo "${DISTRO}" | cut -d_ -f3)" -REV="1~" -if [[ x${DEB_VERSION} != x ]]; then - REV="${REV}${DEB_VERSION}" -fi -REV="${REV}${DIST}" - -case ${DIST} in - bookworm|sid|kinetic) - DEB_BUILD_OPTIONS="${DEB_BUILD_OPTIONS} nocheck" - ;; -esac - -download_pbuilder_chroot() { - pushd "${SRCDIR}" > /dev/null - - wget -c "${PBUILDER_CHROOTS_BASE_URL}/pbuilder-chroot-${DISTRO}-${ARCH}-${PBUILDER_CHROOTS_VERSION}.tar.xz"{,.sha512} - sha512sum --check --status "pbuilder-chroot-${DISTRO}-${ARCH}-${PBUILDER_CHROOTS_VERSION}.tar.xz.sha512" - - sudo rm -rf /tmp/pbuilder - mkdir -p "/tmp/pbuilder/${DIST}-${ARCH}" - fakeroot tar --checkpoint=1000 -xf "pbuilder-chroot-${DISTRO}-${ARCH}-${PBUILDER_CHROOTS_VERSION}.tar.xz" -C "/tmp/pbuilder/${DIST}-${ARCH}" - - popd > /dev/null -} - -download_orig() { - local i=0 - local out=0 - local url="https://distfiles.rgm.io/${PN}/${P}/${P}.tar.xz" - - while [[ $i -lt 20 ]]; do - set +ex - ((i++)) - echo "waiting for ${P}.tar.xz: $i/20" - wget -q --spider --tries 1 "${url}" - out=$? - set -ex - - if [[ $out -eq 0 ]]; then - wget -c "${url}" - mv "${P}.tar.xz" "${BUILDDIR}/${MY_P}.orig.tar.xz" - return - fi - - if [[ $out -ne 8 ]]; then - exit $out - fi - - sleep 30 - done - - echo "failed to find orig distfile. please check if that task succeeded." - exit 1 -} - -create_reprepro_conf() { - echo "Origin: blogc" - echo "Label: blogc" - echo "Codename: ${DIST}" - echo "Architectures: source amd64" - echo "Components: main" - echo "Description: Apt repository containing blogc snapshots" - echo -} - -download_pbuilder_chroot -download_orig - -rm -rf "${BUILDDIR}/${P}" -tar -xf "${BUILDDIR}/${MY_P}.orig.tar.xz" -C "${BUILDDIR}" -cp -r "${SRCDIR}/debian" "${BUILDDIR}/${P}/" - -pushd "${BUILDDIR}/${P}" > /dev/null - -## skip build silently when new version is older than last changelog version (version bump) -if ! dch \ - --distribution "${DIST}" \ - --newversion "${PV}-${REV}" \ - "Automated build for ${DIST}" -then - exit 0 -fi - -sudo cowbuilder \ - --update \ - --basepath "/tmp/pbuilder/${DIST}-${ARCH}/base.cow" - -RES="${BUILDDIR}/deb/${DIST}" -mkdir -p "${RES}" - -pdebuild \ - --pbuilder cowbuilder \ - --buildresult "${RES}" \ - --debbuildopts -sa \ - -- --basepath "/tmp/pbuilder/${DIST}-${ARCH}/base.cow" - -popd > /dev/null - -mkdir -p "${BUILDDIR}/deb-repo/conf" -create_reprepro_conf > "${BUILDDIR}/deb-repo/conf/distributions" - -pushd "${BUILDDIR}/deb-repo" > /dev/null - -for i in "../deb/${DIST}"/*.changes; do - reprepro include "${DIST}" "${i}" -done - -popd > /dev/null - -tar \ - -cJf "blogc-deb-repo-${DIST}-${ARCH}-${PV}.tar.xz" \ - --exclude ./deb-repo/conf \ - --exclude ./deb-repo/db \ - ./deb-repo - -tar \ - -cJf "blogc-deb-${DIST}-${ARCH}-${PV}.tar.xz" \ - ./deb diff --git a/build-aux/build-static-all.sh b/build-aux/build-static-all.sh deleted file mode 100755 index 0cba1a3..0000000 --- a/build-aux/build-static-all.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -ex - -${MAKE_CMD:-make} LDFLAGS="-all-static" -${MAKE_CMD:-make} DESTDIR="${PWD}/root" install -install -m 644 ../LICENSE root/LICENSE -echo "${PV}" > root/VERSION - -pushd root > /dev/null -tar -cvJf "../${PN}-${TARGET}-amd64-${PV}.tar.xz" * -popd > /dev/null diff --git a/build-aux/build-static.sh b/build-aux/build-static.sh deleted file mode 100755 index cacca1b..0000000 --- a/build-aux/build-static.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/bash - -set -ex - -${MAKE_CMD:-make} LDFLAGS="-all-static" blogc - -xz -zc blogc > "blogc-static-amd64-${PV}.xz" diff --git a/build-aux/build-windows.sh b/build-aux/build-windows.sh deleted file mode 100755 index b00fbe6..0000000 --- a/build-aux/build-windows.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash - -set -ex - -DESTDIR="${PN}-${TARGET}-${PV}" - -${MAKE_CMD:-make} blogc.exe - -rm -rf "${DESTDIR}" -mkdir -p "${DESTDIR}" - -cp .libs/blogc.exe "${DESTDIR}/" -cp ../LICENSE "${DESTDIR}/" -cp ../README.md "${DESTDIR}/" - -zip "${DESTDIR}.zip" "${DESTDIR}"/* diff --git a/build-aux/check-make-embedded.sh b/build-aux/check-make-embedded.sh deleted file mode 100755 index d2e5fe4..0000000 --- a/build-aux/check-make-embedded.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash - -set -ex - -${MAKE_CMD:-make} check diff --git a/build-aux/clang-analyzer.sh b/build-aux/clang-analyzer.sh deleted file mode 100755 index e7820c4..0000000 --- a/build-aux/clang-analyzer.sh +++ /dev/null @@ -1,28 +0,0 @@ -#!/bin/bash - -set -ex - -P="${PN}-clang-analyzer-${PV}" - -set +e -scan-build \ - --use-cc="${CC:-clang}" \ - -o reports \ - make -RV=$? -set -e - -NUM_REPORTS=$(ls -1 reports | wc -l) -[[ ${NUM_REPORTS} -eq 0 ]] && exit ${RV} -[[ ${NUM_REPORTS} -eq 1 ]] - -REPORTS="reports/$(ls -1 reports)" -if [[ -d "${REPORTS}" ]]; then - mv "${REPORTS}" clang-analyzer - tar \ - -cvJf "${P}.tar.xz" \ - clang-analyzer - RV=1 -fi - -exit ${RV} diff --git a/build-aux/git-version-gen b/build-aux/git-version-gen deleted file mode 100755 index 3468247..0000000 --- a/build-aux/git-version-gen +++ /dev/null @@ -1,225 +0,0 @@ -#!/bin/sh -# Print a version string. -scriptversion=2012-12-31.23; # UTC - -# Copyright (C) 2007-2013 Free Software Foundation, Inc. -# -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. - -# This script is derived from GIT-VERSION-GEN from GIT: http://git.or.cz/. -# It may be run two ways: -# - from a git repository in which the "git describe" command below -# produces useful output (thus requiring at least one signed tag) -# - from a non-git-repo directory containing a .tarball-version file, which -# presumes this script is invoked like "./git-version-gen .tarball-version". - -# In order to use intra-version strings in your project, you will need two -# separate generated version string files: -# -# .tarball-version - present only in a distribution tarball, and not in -# a checked-out repository. Created with contents that were learned at -# the last time autoconf was run, and used by git-version-gen. Must not -# be present in either $(srcdir) or $(builddir) for git-version-gen to -# give accurate answers during normal development with a checked out tree, -# but must be present in a tarball when there is no version control system. -# Therefore, it cannot be used in any dependencies. GNUmakefile has -# hooks to force a reconfigure at distribution time to get the value -# correct, without penalizing normal development with extra reconfigures. -# -# .version - present in a checked-out repository and in a distribution -# tarball. Usable in dependencies, particularly for files that don't -# want to depend on config.h but do want to track version changes. -# Delete this file prior to any autoconf run where you want to rebuild -# files to pick up a version string change; and leave it stale to -# minimize rebuild time after unrelated changes to configure sources. -# -# As with any generated file in a VC'd directory, you should add -# /.version to .gitignore, so that you don't accidentally commit it. -# .tarball-version is never generated in a VC'd directory, so needn't -# be listed there. -# -# Use the following line in your configure.ac, so that $(VERSION) will -# automatically be up-to-date each time configure is run (and note that -# since configure.ac no longer includes a version string, Makefile rules -# should not depend on configure.ac for version updates). -# -# AC_INIT([GNU project], -# m4_esyscmd([build-aux/git-version-gen .tarball-version]), -# [bug-project@example]) -# -# Then use the following lines in your Makefile.am, so that .version -# will be present for dependencies, and so that .version and -# .tarball-version will exist in distribution tarballs. -# -# EXTRA_DIST = $(top_srcdir)/.version -# BUILT_SOURCES = $(top_srcdir)/.version -# $(top_srcdir)/.version: -# echo $(VERSION) > $@-t && mv $@-t $@ -# dist-hook: -# echo $(VERSION) > $(distdir)/.tarball-version - - -me=$0 - -version="git-version-gen $scriptversion - -Copyright 2011 Free Software Foundation, Inc. -There is NO warranty. You may redistribute this software -under the terms of the GNU General Public License. -For more information about these matters, see the files named COPYING." - -usage="\ -Usage: $me [OPTION]... \$srcdir/.tarball-version [TAG-NORMALIZATION-SED-SCRIPT] -Print a version string. - -Options: - - --prefix prefix of git tags (default 'v') - --fallback fallback version to use if \"git --version\" fails - - --help display this help and exit - --version output version information and exit - -Running without arguments will suffice in most cases." - -prefix=v -fallback= - -while test $# -gt 0; do - case $1 in - --help) echo "$usage"; exit 0;; - --version) echo "$version"; exit 0;; - --prefix) shift; prefix="$1";; - --fallback) shift; fallback="$1";; - -*) - echo "$0: Unknown option '$1'." >&2 - echo "$0: Try '--help' for more information." >&2 - exit 1;; - *) - if test "x$tarball_version_file" = x; then - tarball_version_file="$1" - elif test "x$tag_sed_script" = x; then - tag_sed_script="$1" - else - echo "$0: extra non-option argument '$1'." >&2 - exit 1 - fi;; - esac - shift -done - -if test "x$tarball_version_file" = x; then - echo "$usage" - exit 1 -fi - -tag_sed_script="${tag_sed_script:-s/x/x/}" - -nl=' -' - -# Avoid meddling by environment variable of the same name. -v= -v_from_git= - -# First see if there is a tarball-only version file. -# then try "git describe", then default. -if test -f $tarball_version_file -then - v=`cat $tarball_version_file` || v= - case $v in - *$nl*) v= ;; # reject multi-line output - [0-9]*) ;; - *) v= ;; - esac - test "x$v" = x \ - && echo "$0: WARNING: $tarball_version_file is missing or damaged" 1>&2 -fi - -if test "x$v" != x -then - : # use $v -# Otherwise, if there is at least one git commit involving the working -# directory, and "git describe" output looks sensible, use that to -# derive a version string. -elif test "`git log -1 --pretty=format:x . 2>&1`" = x \ - && v=`git describe --abbrev=4 --match="$prefix*" HEAD 2>/dev/null \ - || git describe --abbrev=4 HEAD 2>/dev/null` \ - && v=`printf '%s\n' "$v" | sed "$tag_sed_script"` \ - && case $v in - $prefix[0-9]*) ;; - *) (exit 1) ;; - esac -then - # Is this a new git that lists number of commits since the last - # tag or the previous older version that did not? - # Newer: v6.10-77-g0f8faeb - # Older: v6.10-g0f8faeb - case $v in - *-*-*) : git describe is okay three part flavor ;; - *-*) - : git describe is older two part flavor - # Recreate the number of commits and rewrite such that the - # result is the same as if we were using the newer version - # of git describe. - vtag=`echo "$v" | sed 's/-.*//'` - commit_list=`git rev-list "$vtag"..HEAD 2>/dev/null` \ - || { commit_list=failed; - echo "$0: WARNING: git rev-list failed" 1>&2; } - numcommits=`echo "$commit_list" | wc -l` - v=`echo "$v" | sed "s/\(.*\)-\(.*\)/\1-$numcommits-\2/"`; - test "$commit_list" = failed && v=UNKNOWN - ;; - esac - - # Change the first '-' to a '.', so version-comparing tools work properly. - # Remove the "g" in git describe's output string, to save a byte. - v=`echo "$v" | sed 's/-/./;s/\(.*\)-g/\1-/'`; - v_from_git=1 -elif test "x$fallback" = x || git --version >/dev/null 2>&1; then - v=UNKNOWN -else - v=$fallback -fi - -v=`echo "$v" |sed "s/^$prefix//"` - -# Test whether to append the "-dirty" suffix only if the version -# string we're using came from git. I.e., skip the test if it's "UNKNOWN" -# or if it came from .tarball-version. -if test "x$v_from_git" != x; then - # Don't declare a version "dirty" merely because a time stamp has changed. - git update-index --refresh > /dev/null 2>&1 - - dirty=`exec 2>/dev/null;git diff-index --name-only HEAD` || dirty= - case "$dirty" in - '') ;; - *) # Append the suffix only if there isn't one already. - case $v in - *-dirty) ;; - *) v="$v-dirty" ;; - esac ;; - esac -fi - -# Omit the trailing newline, so that m4_esyscmd can use the result directly. -echo "$v" | tr -d "$nl" - -# Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) -# time-stamp-start: "scriptversion=" -# time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" -# time-stamp-end: "; # UTC" -# End: diff --git a/build-aux/valgrind.sh b/build-aux/valgrind.sh deleted file mode 100755 index 991b906..0000000 --- a/build-aux/valgrind.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/sh - -export TESTS_ENVIRONMENT=" - ${VALGRIND:-valgrind} \ - --tool=memcheck \ - --leak-check=full \ - --leak-resolution=high \ - --num-callers=20 \ - --error-exitcode=1 \ - --show-possibly-lost=no" - -if [[ "${1}" == *.sh ]]; then - exec "${@}" -else - exec ${TESTS_ENVIRONMENT} "${@}" -fi diff --git a/cmake/cpack/install_license_and_readme.cmake b/cmake/cpack/install_license_and_readme.cmake new file mode 100644 index 0000000..c41bc46 --- /dev/null +++ b/cmake/cpack/install_license_and_readme.cmake @@ -0,0 +1,20 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT CPACK_SOURCE_INSTALLED_DIRECTORIES) + if(CPACK_SYSTEM_NAME MATCHES "^win") + set(_license "LICENSE.txt") + else() + set(_license "LICENSE") + endif() + + file(COPY_FILE + "${CPACK_RESOURCE_FILE_LICENSE}" + "${CMAKE_INSTALL_PREFIX}/${_license}" + ) + + file(COPY_FILE + "${CPACK_RESOURCE_FILE_README}" + "${CMAKE_INSTALL_PREFIX}/README.md" + ) +endif() diff --git a/cmake/cpack/install_version.cmake b/cmake/cpack/install_version.cmake new file mode 100644 index 0000000..c37b786 --- /dev/null +++ b/cmake/cpack/install_version.cmake @@ -0,0 +1,9 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(CPACK_SOURCE_INSTALLED_DIRECTORIES) + file(WRITE + "${CMAKE_INSTALL_PREFIX}/version.cmake" + "set(BLOGC_VERSION \"${CPACK_PACKAGE_VERSION}\")" + ) +endif() diff --git a/cmake/scripts/test.sh b/cmake/scripts/test.sh new file mode 100755 index 0000000..cbf0de4 --- /dev/null +++ b/cmake/scripts/test.sh @@ -0,0 +1,23 @@ +#!/bin/bash +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +set -Eeuo pipefail + +if [[ "${VARIANT:-}" = "memcheck" ]]; then + export VALGRIND=valgrind + export TESTS_ENVIRONMENT=" + ${VALGRIND} \ + --tool=memcheck \ + --leak-check=full \ + --leak-resolution=high \ + --num-callers=20 \ + --error-exitcode=1 \ + --show-possibly-lost=no" +fi + +if [[ "${1}" == *.sh ]]; then + exec "${@}" +else + exec ${TESTS_ENVIRONMENT:-} "${@}" +fi diff --git a/config.h.in b/config.h.in new file mode 100644 index 0000000..d6fa594 --- /dev/null +++ b/config.h.in @@ -0,0 +1,36 @@ +/* + * blogc: A blog compiler. + * Copyright (C) 2014-2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> + * + * This program can be distributed under the terms of the BSD License. + * See the file LICENSE. + */ + +#ifndef __CONFIG_H +#define __CONFIG_H + +#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@" + +#cmakedefine HAVE_GETRUSAGE +#cmakedefine HAVE_GETHOSTNAME + +#cmakedefine HAVE_ARPA_INET_H +#cmakedefine HAVE_DIRENT_H +#cmakedefine HAVE_ERRNO_H +#cmakedefine HAVE_FCNTL_H +#cmakedefine HAVE_LIBGEN_H +#cmakedefine HAVE_LIMITS_H +#cmakedefine HAVE_NETDB_H +#cmakedefine HAVE_NETINET_IN_H +#cmakedefine HAVE_SIGNAL_H +#cmakedefine HAVE_SYSEXITS_H +#cmakedefine HAVE_SYS_RESOURCE_H +#cmakedefine HAVE_SYS_SOCKET_H +#cmakedefine HAVE_SYS_STAT_H +#cmakedefine HAVE_SYS_TIME_H +#cmakedefine HAVE_SYS_TYPES_H +#cmakedefine HAVE_SYS_WAIT_H +#cmakedefine HAVE_TIME_H +#cmakedefine HAVE_UNISTD_H + +#endif /* __CONFIG_H */ diff --git a/configure.ac b/configure.ac deleted file mode 100644 index 3e98afc..0000000 --- a/configure.ac +++ /dev/null @@ -1,269 +0,0 @@ -AC_PREREQ([2.69]) - -AC_INIT([blogc], m4_esyscmd([build-aux/git-version-gen .tarball-version]), - [https://github.com/blogc/blogc], [blogc], [https://blogc.rgm.io/]) -AC_CONFIG_AUX_DIR([build-aux]) -AC_CONFIG_MACRO_DIR([m4]) - -AM_INIT_AUTOMAKE([1.13 foreign dist-bzip2 dist-xz dist-zip subdir-objects - serial-tests -Wall -Wno-extra-portability -Werror]) -AC_CONFIG_HEADERS([config.h]) -AM_SILENT_RULES([yes]) -AM_MAINTAINER_MODE([enable]) - -AC_USE_SYSTEM_EXTENSIONS - -LT_INIT - -AC_PROG_CC_C99 -AS_IF([test "x$ac_cv_prog_cc_c99" = "xno"], [ - AC_MSG_ERROR([no C99 compiler found, blogc requires a C99 compiler.]) -]) - -PKG_PROG_PKG_CONFIG - -AC_PROG_SED - -RPM_VERSION=`echo ${PACKAGE_VERSION} | sed "s/-/./g"` -AC_SUBST(RPM_VERSION) - -AC_ARG_ENABLE([rpmbuild], AS_HELP_STRING([--disable-rpmbuild], - [ignore presence of rpmbuild and disable srpm generation])) -AS_IF([test "x$enable_rpmbuild" != "xno"], [ - AC_PATH_PROG([rpmbuild], [rpmbuild]) - AS_IF([test "x$ac_cv_path_rpmbuild" = "x"], [ - have_rpmbuild=no - ], [ - have_rpmbuild=yes - ]) -]) -AS_IF([test "x$have_rpmbuild" = "xyes"], , [ - AS_IF([test "x$enable_rpmbuild" = "xyes"], [ - AC_MSG_ERROR([rpmbuild requested but not found]) - ]) -]) -AM_CONDITIONAL([BUILD_SRPM], [test "x$ac_cv_path_rpmbuild" != "x"]) -RPMBUILD="$ac_cv_path_rpmbuild" -AC_SUBST(RPMBUILD) - -AC_ARG_ENABLE([ronn], AS_HELP_STRING([--disable-ronn], - [ignore presence of ronn and disable man pages generation])) -AS_IF([test "x$enable_ronn" != "xno"], [ - AC_PATH_PROG([ronn], [ronn]) - AS_IF([test "x$ac_cv_path_ronn" = "x"], [ - have_ronn=no - ], [ - have_ronn=yes - ]) -]) -AS_IF([test "x$have_ronn" = "xyes"], , [ - AS_IF([test "x$enable_ronn" = "xyes"], [ - AC_MSG_ERROR([ronn requested but not found]) - ]) -]) -AM_CONDITIONAL([BUILD_MANPAGE], [test "x$have_ronn" = "xyes"]) -RONN="$ac_cv_path_ronn" -AC_SUBST(RONN) - -AC_ARG_ENABLE([valgrind], AS_HELP_STRING([--disable-valgrind], - [ignore presence of valgrind])) -AS_IF([test "x$enable_valgrind" != "xno"], [ - AC_PATH_PROG([valgrind], [valgrind]) - AS_IF([test "x$ac_cv_path_valgrind" = "x"], [ - have_valgrind=no - ], [ - have_valgrind=yes - ]) -]) -AS_IF([test "x$have_valgrind" = "xyes"], , [ - AS_IF([test "x$enable_valgrind" = "xyes"], [ - AC_MSG_ERROR([valgrind requested but not found]) - ]) -]) -AM_CONDITIONAL([USE_VALGRIND], [test "x$have_valgrind" = "xyes"]) -VALGRIND="$ac_cv_path_valgrind" -AC_SUBST(VALGRIND) - -GIT_RECEIVER="disabled" -AC_ARG_ENABLE([git-receiver], AS_HELP_STRING([--enable-git-receiver], - [build blogc-git-receiver tool])) -AS_IF([test "x$enable_git_receiver" = "xyes"], [ - AC_CHECK_HEADERS([sys/types.h sys/stat.h time.h libgen.h unistd.h errno.h dirent.h], [ - GIT_RECEIVER="enabled" - have_git_receiver=yes - ], [ - AC_MSG_ERROR([blogc-git-receiver tool requested but required headers not found]) - ]) -]) -AM_CONDITIONAL([BUILD_GIT_RECEIVER], [test "x$have_git_receiver" = "xyes"]) - -MAKE_="disabled" -AC_ARG_ENABLE([make-embedded], AS_HELP_STRING([--enable-make-embedded], - [build blogc-make tool embedded on blogc binary])) -AC_ARG_ENABLE([make], AS_HELP_STRING([--enable-make], - [build blogc-make tool])) -AS_IF([test "x$enable_make" = "xyes" -o "x$enable_make_embedded" = "xyes"], [ - AC_CHECK_HEADERS([dirent.h fcntl.h libgen.h sys/stat.h sys/wait.h time.h unistd.h],, [ - AC_MSG_ERROR([blogc-make tool requested but required headers not found]) - ]) - AX_PTHREAD([], [ - AC_MSG_ERROR([blogc-make tool requested but pthread is not supported]) - ]) - have_make_lib=yes - AS_IF([test "x$enable_make_embedded" = "xyes"], [ - MAKE_="enabled (embedded)" - have_make_embedded=yes - AC_DEFINE([MAKE_EMBEDDED], [], [Build blogc-make embedded to blogc binary]) - ], [ - MAKE_="enabled" - have_make=yes - ]) -]) -AM_CONDITIONAL([BUILD_MAKE], [test "x$have_make" = "xyes"]) -AM_CONDITIONAL([BUILD_MAKE_LIB], [test "x$have_make_lib" = "xyes"]) -AM_CONDITIONAL([BUILD_MAKE_EMBEDDED], [test "x$have_make_embedded" = "xyes"]) - -RUNSERVER="disabled" -AC_ARG_ENABLE([runserver], AS_HELP_STRING([--enable-runserver], - [build blogc-runserver tool])) -AS_IF([test "x$enable_runserver" = "xyes"], [ - AC_CHECK_HEADERS([signal.h limits.h fcntl.h unistd.h sys/stat.h sys/types.h sys/socket.h netinet/in.h arpa/inet.h],, [ - AC_MSG_ERROR([blogc-runserver tool requested but required headers not found]) - ]) - AX_PTHREAD([], [ - AC_MSG_ERROR([blogc-runserver tool requested but pthread is not supported]) - ]) - RUNSERVER="enabled" - have_runserver=yes -]) -AM_CONDITIONAL([BUILD_RUNSERVER], [test "x$have_runserver" = "xyes"]) - -TESTS="disabled" -AC_ARG_ENABLE([tests], AS_HELP_STRING([--disable-tests], - [disable unit tests, ignoring presence of cmocka])) -AS_IF([test "x$enable_tests" != "xno"], [ - PKG_CHECK_MODULES([CMOCKA], [cmocka], [ - have_cmocka=yes - AC_MSG_CHECKING([whether the linker supports -wrap]) - save_LDFLAGS="$LDFLAGS" - LDFLAGS="$LDFLAGS -Wl,-wrap,exit" - AC_RUN_IFELSE([ - AC_LANG_PROGRAM([ - [void __wrap_exit(int s){__real_exit(0);}] - ], [ - [exit(1);] - ]) - ], [ - have_ld_wrap=yes - ], [ - have_ld_wrap=no - ], [ - have_ld_wrap=no - ]) - AC_MSG_RESULT([$have_ld_wrap]) - AS_IF([test "x$have_ld_wrap" = "xyes"],, [ - AC_MSG_WARN([linker does not supports -wrap. tests requiring it will be disabled]) - ]) - LDFLAGS="$save_LDFLAGS" - ], [ - have_cmocka=no - ]) - AS_IF([test "x$have_cmocka" = "xyes"],, [ - have_tests=no - TESTS="disabled" - AS_IF([test "x$enable_tests" = "xyes"], [ - AC_MSG_ERROR([tests requested but cmocka was not found]) - ], [ - AC_MSG_WARN([cmocka was not found, disabling tests]) - ]) - ]) - - AC_PATH_PROG([git], [git]) - AC_PATH_PROG([make], [make]) - AC_PATH_PROG([tar], [tar]) - AS_IF([test "x$ac_cv_path_git" = "x" -o "x$ac_cv_path_make" = "x" -o "x$ac_cv_path_tar" = "x"], [ - have_bgr_deps=no - AS_IF([test "x$have_git_receiver" = "xyes"], [ - have_tests=no - TESTS="disabled" - AS_IF([test "x$enable_tests" = "xyes"], [ - AC_MSG_ERROR([tests requested for blogc-git-receiver but git and/or tar not found]) - ], [ - AC_MSG_WARN([git and/or tar not found, install it to run blogc-git-receiver tests]) - ]) - ]) - ], [ - have_bgr_deps=yes - ]) - - AC_PATH_PROG([bash], [bash]) - AC_PATH_PROG([diff], [diff]) - AC_PATH_PROG([tee], [tee]) - AS_IF([test "x$ac_cv_path_bash" = "x" -o "x$ac_cv_path_diff" = "x" -o "x$ac_cv_path_tee" = "x"], [ - have_tests=no - TESTS="disabled" - AS_IF([test "x$enable_tests" = "xyes"], [ - AC_MSG_ERROR([tests requested but bash, diff and/or tee not found]) - ], [ - AC_MSG_WARN([bash, diff and/or tee not found, install it to run tests]) - ]) - ], [ - have_tests=yes - TESTS="enabled" - ]) -]) -AM_CONDITIONAL([BUILD_TESTS], [test "x$have_tests" = "xyes"]) -AM_CONDITIONAL([USE_CMOCKA], [test "x$have_cmocka" = "xyes"]) -AM_CONDITIONAL([USE_LD_WRAP], [test "x$have_ld_wrap" = "xyes"]) -AM_CONDITIONAL([USE_BGR_DEPS], [test "x$have_bgr_deps" = "xyes"]) -BASH="$ac_cv_path_bash" -AC_SUBST(BASH) - -AC_CHECK_HEADERS([netdb.h sys/resource.h sys/stat.h sys/time.h sys/wait.h time.h unistd.h sysexits.h]) -AC_CHECK_FUNCS([gethostname]) - -AM_CONDITIONAL([HAVE_NETDB_H], [test "x$ac_cv_header_netdb_h" = "xyes"]) -AM_CONDITIONAL([HAVE_TIME_H], [test "x$ac_cv_header_time_h" = "xyes"]) -AM_CONDITIONAL([HAVE_UNISTD_H], [test "x$ac_cv_header_unistd_h" = "xyes"]) -AM_CONDITIONAL([HAVE_SYS_RESOURCE_H], [test "x$ac_cv_header_sys_resource_h" = "xyes"]) -AM_CONDITIONAL([HAVE_SYS_TIME_H], [test "x$ac_cv_header_sys_time_h" = "xyes"]) - -LT_LIB_M - -AC_CONFIG_FILES([ - Makefile - blogc.spec -]) -AC_CONFIG_FILES([tests/blogc/check_blogc.sh], - [chmod +x tests/blogc/check_blogc.sh]) -AC_CONFIG_FILES([tests/blogc-git-receiver/check_pre_receive.sh], - [chmod +x tests/blogc-git-receiver/check_pre_receive.sh]) -AC_CONFIG_FILES([tests/blogc-git-receiver/check_post_receive.sh], - [chmod +x tests/blogc-git-receiver/check_post_receive.sh]) -AC_CONFIG_FILES([tests/blogc-git-receiver/check_shell.sh], - [chmod +x tests/blogc-git-receiver/check_shell.sh]) -AC_CONFIG_FILES([tests/blogc-make/check_blogc_make.sh], - [chmod +x tests/blogc-make/check_blogc_make.sh]) -AC_OUTPUT - -AS_ECHO(" - ====== ${PACKAGE_STRING} ====== - - prefix: ${prefix} - exec_prefix: ${exec_prefix} - bindir: ${bindir} - - compiler: ${CC} - cflags: ${CFLAGS} - ldflags: ${LDFLAGS} - - blogc-git-receiver: ${GIT_RECEIVER} - blogc-make: ${MAKE_} - blogc-runserver: ${RUNSERVER} - - tests: ${TESTS} - - ronn: ${RONN} - valgrind: ${VALGRIND} - rpmbuild: ${RPMBUILD} -") diff --git a/debian/blogc-git-receiver.install b/debian/blogc-git-receiver.install deleted file mode 100644 index ede6da4..0000000 --- a/debian/blogc-git-receiver.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin/blogc-git-receiver -usr/share/man/man1/blogc-git-receiver.1 diff --git a/debian/blogc-make.install b/debian/blogc-make.install deleted file mode 100644 index 44c459a..0000000 --- a/debian/blogc-make.install +++ /dev/null @@ -1,3 +0,0 @@ -usr/bin/blogc-make -usr/share/man/man1/blogc-make.1 -usr/share/man/man5/blogcfile.5 diff --git a/debian/blogc-runserver.install b/debian/blogc-runserver.install deleted file mode 100644 index debadc7..0000000 --- a/debian/blogc-runserver.install +++ /dev/null @@ -1,2 +0,0 @@ -usr/bin/blogc-runserver -usr/share/man/man1/blogc-runserver.1 diff --git a/debian/blogc.install b/debian/blogc.install deleted file mode 100644 index edb9ae3..0000000 --- a/debian/blogc.install +++ /dev/null @@ -1,6 +0,0 @@ -usr/bin/blogc -usr/share/man/man1/blogc.1 -usr/share/man/man7/blogc-pagination.7 -usr/share/man/man7/blogc-source.7 -usr/share/man/man7/blogc-template.7 -usr/share/man/man7/blogc-toctree.7 diff --git a/debian/changelog b/debian/changelog deleted file mode 100644 index d9ed199..0000000 --- a/debian/changelog +++ /dev/null @@ -1,5 +0,0 @@ -blogc (0.20.1-1~0upstream) unstable; urgency=medium - - * Upstream Release - - -- Rafael G. Martins <rafael@rafaelmartins.eng.br> Sat, 02 Jan 2021 19:38:56 +0100 diff --git a/debian/control b/debian/control deleted file mode 100644 index 741da73..0000000 --- a/debian/control +++ /dev/null @@ -1,41 +0,0 @@ -Source: blogc -Section: text -Priority: optional -Maintainer: Rafael G. Martins <rafael@rafaelmartins.eng.br> -Build-Depends: debhelper-compat (= 12), - git, - libcmocka-dev, - pkg-config -Standards-Version: 4.5.1 -Homepage: https://blogc.rgm.io/ -Vcs-Browser: https://github.com/blogc/blogc -Vcs-Git: https://github.com/blogc/blogc.git -Rules-Requires-Root: no - -Package: blogc -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Blog compiler - Main binary - -Package: blogc-git-receiver -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, - git, - make -Description: Blog compiler - Simple login shell/git hook to deploy blogc websites - -Package: blogc-make -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, - blogc, - blogc-runserver -Description: Blog compiler - Simple build tool for blogc - -Package: blogc-runserver -Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends} -Description: Blog compiler - Simple HTTP server to test blogc websites diff --git a/debian/copyright b/debian/copyright deleted file mode 100644 index 2880381..0000000 --- a/debian/copyright +++ /dev/null @@ -1,61 +0,0 @@ -Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: blogc -Upstream-Contact: Rafael G. Martins <rafael@rafaelmartins.eng.br> -Source: https://github.com/blogc/blogc - -Files: * -Copyright: 2014-2020, Rafael G. Martins <rafael@rafaelmartins.eng.br> -License: BSD-3-Clause - -Files: debian/* -Copyright: 2020 Rafael G. Martins <rafael@rafaelmartins.eng.br> -License: BSD-3-Clause - -Files: src/common/utf8.c -Copyright: 2008-2010 Bjoern Hoehrmann <bjoern@hoehrmann.de> - 2014-2019 Rafael G. Martins <rafael@rafaelmartins.eng.br> -License: MIT - -License: BSD-3-Clause - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions - are met: - 1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - 3. Neither the name of the University nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. - . - THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE HOLDERS OR - CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -License: MIT - Permission is hereby granted, free of charge, to any person obtaining a - copy of this software and associated documentation files (the "Software"), - to deal in the Software without restriction, including without limitation - the rights to use, copy, modify, merge, publish, distribute, sublicense, - and/or sell copies of the Software, and to permit persons to whom the - Software is furnished to do so, subject to the following conditions: - . - The above copyright notice and this permission notice shall be included - in all copies or substantial portions of the Software. - . - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. - IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY - CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, - TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE - SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/debian/rules b/debian/rules deleted file mode 100755 index 6a1a185..0000000 --- a/debian/rules +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/make -f - -#export DH_VERBOSE = 1 -export DEB_BUILD_MAINT_OPTIONS = hardening=+all optimize=-lto -export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic -export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed - -%: - dh $@ - -override_dh_auto_configure: - dh_auto_configure -- \ - --disable-ronn \ - --enable-git-receiver \ - --enable-make \ - --enable-runserver diff --git a/debian/source/format b/debian/source/format deleted file mode 100644 index 163aaf8..0000000 --- a/debian/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 deleted file mode 100644 index 4c4051e..0000000 --- a/m4/ax_pthread.m4 +++ /dev/null @@ -1,485 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_pthread.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PTHREAD([ACTION-IF-FOUND[, ACTION-IF-NOT-FOUND]]) -# -# DESCRIPTION -# -# This macro figures out how to build C programs using POSIX threads. It -# sets the PTHREAD_LIBS output variable to the threads library and linker -# flags, and the PTHREAD_CFLAGS output variable to any special C compiler -# flags that are needed. (The user can also force certain compiler -# flags/libs to be tested by setting these environment variables.) -# -# Also sets PTHREAD_CC to any special C compiler that is needed for -# multi-threaded programs (defaults to the value of CC otherwise). (This -# is necessary on AIX to use the special cc_r compiler alias.) -# -# NOTE: You are assumed to not only compile your program with these flags, -# but also to link with them as well. For example, you might link with -# $PTHREAD_CC $CFLAGS $PTHREAD_CFLAGS $LDFLAGS ... $PTHREAD_LIBS $LIBS -# -# If you are only building threaded programs, you may wish to use these -# variables in your default LIBS, CFLAGS, and CC: -# -# LIBS="$PTHREAD_LIBS $LIBS" -# CFLAGS="$CFLAGS $PTHREAD_CFLAGS" -# CC="$PTHREAD_CC" -# -# In addition, if the PTHREAD_CREATE_JOINABLE thread-attribute constant -# has a nonstandard name, this macro defines PTHREAD_CREATE_JOINABLE to -# that name (e.g. PTHREAD_CREATE_UNDETACHED on AIX). -# -# Also HAVE_PTHREAD_PRIO_INHERIT is defined if pthread is found and the -# PTHREAD_PRIO_INHERIT symbol is defined when compiling with -# PTHREAD_CFLAGS. -# -# ACTION-IF-FOUND is a list of shell commands to run if a threads library -# is found, and ACTION-IF-NOT-FOUND is a list of commands to run it if it -# is not found. If ACTION-IF-FOUND is not specified, the default action -# will define HAVE_PTHREAD. -# -# Please let the authors know if this macro fails on any platform, or if -# you have any other suggestions or comments. This macro was based on work -# by SGJ on autoconf scripts for FFTW (http://www.fftw.org/) (with help -# from M. Frigo), as well as ac_pthread and hb_pthread macros posted by -# Alejandro Forero Cuervo to the autoconf macro repository. We are also -# grateful for the helpful feedback of numerous users. -# -# Updated for Autoconf 2.68 by Daniel Richard G. -# -# LICENSE -# -# Copyright (c) 2008 Steven G. Johnson <stevenj@alum.mit.edu> -# Copyright (c) 2011 Daniel Richard G. <skunk@iSKUNK.ORG> -# -# This program is free software: you can redistribute it and/or modify it -# under the terms of the GNU General Public License as published by the -# Free Software Foundation, either version 3 of the License, or (at your -# option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -# Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program. If not, see <http://www.gnu.org/licenses/>. -# -# As a special exception, the respective Autoconf Macro's copyright owner -# gives unlimited permission to copy, distribute and modify the configure -# scripts that are the output of Autoconf when processing the Macro. You -# need not follow the terms of the GNU General Public License when using -# or distributing such scripts, even though portions of the text of the -# Macro appear in them. The GNU General Public License (GPL) does govern -# all other use of the material that constitutes the Autoconf Macro. -# -# This special exception to the GPL applies to versions of the Autoconf -# Macro released by the Autoconf Archive. When you make and distribute a -# modified version of the Autoconf Macro, you may extend this special -# exception to the GPL to apply to your modified version as well. - -#serial 23 - -AU_ALIAS([ACX_PTHREAD], [AX_PTHREAD]) -AC_DEFUN([AX_PTHREAD], [ -AC_REQUIRE([AC_CANONICAL_HOST]) -AC_REQUIRE([AC_PROG_CC]) -AC_REQUIRE([AC_PROG_SED]) -AC_LANG_PUSH([C]) -ax_pthread_ok=no - -# We used to check for pthread.h first, but this fails if pthread.h -# requires special compiler flags (e.g. on Tru64 or Sequent). -# It gets checked for in the link test anyway. - -# First of all, check if the user has set any of the PTHREAD_LIBS, -# etcetera environment variables, and if threads linking works using -# them: -if test "x$PTHREAD_CFLAGS$PTHREAD_LIBS" != "x"; then - ax_pthread_save_CC="$CC" - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - AS_IF([test "x$PTHREAD_CC" != "x"], [CC="$PTHREAD_CC"]) - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - AC_MSG_CHECKING([for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS]) - AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_join])], [ax_pthread_ok=yes]) - AC_MSG_RESULT([$ax_pthread_ok]) - if test "x$ax_pthread_ok" = "xno"; then - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" - fi - CC="$ax_pthread_save_CC" - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" -fi - -# We must check for the threads library under a number of different -# names; the ordering is very important because some systems -# (e.g. DEC) have both -lpthread and -lpthreads, where one of the -# libraries is broken (non-POSIX). - -# Create a list of thread flags to try. Items starting with a "-" are -# C compiler flags, and other items are library names, except for "none" -# which indicates that we try without any flags at all, and "pthread-config" -# which is a program returning the flags for the Pth emulation library. - -ax_pthread_flags="pthreads none -Kthread -pthread -pthreads -mthreads pthread --thread-safe -mt pthread-config" - -# The ordering *is* (sometimes) important. Some notes on the -# individual items follow: - -# pthreads: AIX (must check this before -lpthread) -# none: in case threads are in libc; should be tried before -Kthread and -# other compiler flags to prevent continual compiler warnings -# -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) -# -pthread: Linux/gcc (kernel threads), BSD/gcc (userland threads), Tru64 -# (Note: HP C rejects this with "bad form for `-t' option") -# -pthreads: Solaris/gcc (Note: HP C also rejects) -# -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it -# doesn't hurt to check since this sometimes defines pthreads and -# -D_REENTRANT too), HP C (must be checked before -lpthread, which -# is present but should not be used directly; and before -mthreads, -# because the compiler interprets this as "-mt" + "-hreads") -# -mthreads: Mingw32/gcc, Lynx/gcc -# pthread: Linux, etcetera -# --thread-safe: KAI C++ -# pthread-config: use pthread-config program (for GNU Pth library) - -case $host_os in - - freebsd*) - - # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) - # lthread: LinuxThreads port on FreeBSD (also preferred to -pthread) - - ax_pthread_flags="-kthread lthread $ax_pthread_flags" - ;; - - hpux*) - - # From the cc(1) man page: "[-mt] Sets various -D flags to enable - # multi-threading and also sets -lpthread." - - ax_pthread_flags="-mt -pthread pthread $ax_pthread_flags" - ;; - - openedition*) - - # IBM z/OS requires a feature-test macro to be defined in order to - # enable POSIX threads at all, so give the user a hint if this is - # not set. (We don't define these ourselves, as they can affect - # other portions of the system API in unpredictable ways.) - - AC_EGREP_CPP([AX_PTHREAD_ZOS_MISSING], - [ -# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS) - AX_PTHREAD_ZOS_MISSING -# endif - ], - [AC_MSG_WARN([IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support.])]) - ;; - - solaris*) - - # On Solaris (at least, for some versions), libc contains stubbed - # (non-functional) versions of the pthreads routines, so link-based - # tests will erroneously succeed. (N.B.: The stubs are missing - # pthread_cleanup_push, or rather a function called by this macro, - # so we could check for that, but who knows whether they'll stub - # that too in a future libc.) So we'll check first for the - # standard Solaris way of linking pthreads (-mt -lpthread). - - ax_pthread_flags="-mt,pthread pthread $ax_pthread_flags" - ;; -esac - -# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) - -AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread -pthreads $ax_pthread_flags"]) - -# The presence of a feature test macro requesting re-entrant function -# definitions is, on some systems, a strong hint that pthreads support is -# correctly enabled - -case $host_os in - darwin* | hpux* | linux* | osf* | solaris*) - ax_pthread_check_macro="_REENTRANT" - ;; - - aix*) - ax_pthread_check_macro="_THREAD_SAFE" - ;; - - *) - ax_pthread_check_macro="--" - ;; -esac -AS_IF([test "x$ax_pthread_check_macro" = "x--"], - [ax_pthread_check_cond=0], - [ax_pthread_check_cond="!defined($ax_pthread_check_macro)"]) - -# Are we compiling with Clang? - -AC_CACHE_CHECK([whether $CC is Clang], - [ax_cv_PTHREAD_CLANG], - [ax_cv_PTHREAD_CLANG=no - # Note that Autoconf sets GCC=yes for Clang as well as GCC - if test "x$GCC" = "xyes"; then - AC_EGREP_CPP([AX_PTHREAD_CC_IS_CLANG], - [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ -# if defined(__clang__) && defined(__llvm__) - AX_PTHREAD_CC_IS_CLANG -# endif - ], - [ax_cv_PTHREAD_CLANG=yes]) - fi - ]) -ax_pthread_clang="$ax_cv_PTHREAD_CLANG" - -ax_pthread_clang_warning=no - -# Clang needs special handling, because older versions handle the -pthread -# option in a rather... idiosyncratic way - -if test "x$ax_pthread_clang" = "xyes"; then - - # Clang takes -pthread; it has never supported any other flag - - # (Note 1: This will need to be revisited if a system that Clang - # supports has POSIX threads in a separate library. This tends not - # to be the way of modern systems, but it's conceivable.) - - # (Note 2: On some systems, notably Darwin, -pthread is not needed - # to get POSIX threads support; the API is always present and - # active. We could reasonably leave PTHREAD_CFLAGS empty. But - # -pthread does define _REENTRANT, and while the Darwin headers - # ignore this macro, third-party headers might not.) - - PTHREAD_CFLAGS="-pthread" - PTHREAD_LIBS= - - ax_pthread_ok=yes - - # However, older versions of Clang make a point of warning the user - # that, in an invocation where only linking and no compilation is - # taking place, the -pthread option has no effect ("argument unused - # during compilation"). They expect -pthread to be passed in only - # when source code is being compiled. - # - # Problem is, this is at odds with the way Automake and most other - # C build frameworks function, which is that the same flags used in - # compilation (CFLAGS) are also used in linking. Many systems - # supported by AX_PTHREAD require exactly this for POSIX threads - # support, and in fact it is often not straightforward to specify a - # flag that is used only in the compilation phase and not in - # linking. Such a scenario is extremely rare in practice. - # - # Even though use of the -pthread flag in linking would only print - # a warning, this can be a nuisance for well-run software projects - # that build with -Werror. So if the active version of Clang has - # this misfeature, we search for an option to squash it. - - AC_CACHE_CHECK([whether Clang needs flag to prevent "argument unused" warning when linking with -pthread], - [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG], - [ax_cv_PTHREAD_CLANG_NO_WARN_FLAG=unknown - # Create an alternate version of $ac_link that compiles and - # links in two steps (.c -> .o, .o -> exe) instead of one - # (.c -> exe), because the warning occurs only in the second - # step - ax_pthread_save_ac_link="$ac_link" - ax_pthread_sed='s/conftest\.\$ac_ext/conftest.$ac_objext/g' - ax_pthread_link_step=`$as_echo "$ac_link" | sed "$ax_pthread_sed"` - ax_pthread_2step_ac_link="($ac_compile) && (echo ==== >&5) && ($ax_pthread_link_step)" - ax_pthread_save_CFLAGS="$CFLAGS" - for ax_pthread_try in '' -Qunused-arguments -Wno-unused-command-line-argument unknown; do - AS_IF([test "x$ax_pthread_try" = "xunknown"], [break]) - CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS" - ac_link="$ax_pthread_save_ac_link" - AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], - [ac_link="$ax_pthread_2step_ac_link" - AC_LINK_IFELSE([AC_LANG_SOURCE([[int main(void){return 0;}]])], - [break]) - ]) - done - ac_link="$ax_pthread_save_ac_link" - CFLAGS="$ax_pthread_save_CFLAGS" - AS_IF([test "x$ax_pthread_try" = "x"], [ax_pthread_try=no]) - ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try" - ]) - - case "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" in - no | unknown) ;; - *) PTHREAD_CFLAGS="$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG $PTHREAD_CFLAGS" ;; - esac - -fi # $ax_pthread_clang = yes - -if test "x$ax_pthread_ok" = "xno"; then -for ax_pthread_try_flag in $ax_pthread_flags; do - - case $ax_pthread_try_flag in - none) - AC_MSG_CHECKING([whether pthreads work without any flags]) - ;; - - -mt,pthread) - AC_MSG_CHECKING([whether pthreads work with -mt -lpthread]) - PTHREAD_CFLAGS="-mt" - PTHREAD_LIBS="-lpthread" - ;; - - -*) - AC_MSG_CHECKING([whether pthreads work with $ax_pthread_try_flag]) - PTHREAD_CFLAGS="$ax_pthread_try_flag" - ;; - - pthread-config) - AC_CHECK_PROG([ax_pthread_config], [pthread-config], [yes], [no]) - AS_IF([test "x$ax_pthread_config" = "xno"], [continue]) - PTHREAD_CFLAGS="`pthread-config --cflags`" - PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`" - ;; - - *) - AC_MSG_CHECKING([for the pthreads library -l$ax_pthread_try_flag]) - PTHREAD_LIBS="-l$ax_pthread_try_flag" - ;; - esac - - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Check for various functions. We must include pthread.h, - # since some functions may be macros. (On the Sequent, we - # need a special flag -Kthread to make this header compile.) - # We check for pthread_join because it is in -lpthread on IRIX - # while pthread_create is in libc. We check for pthread_attr_init - # due to DEC craziness with -lpthreads. We check for - # pthread_cleanup_push because it is one of the few pthread - # functions on Solaris that doesn't have a non-functional libc stub. - # We try pthread_create on general principles. - - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h> -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void routine(void *a) { a = 0; } - static void *start_routine(void *a) { return a; }], - [pthread_t th; pthread_attr_t attr; - pthread_create(&th, 0, start_routine, 0); - pthread_join(th, 0); - pthread_attr_init(&attr); - pthread_cleanup_push(routine, 0); - pthread_cleanup_pop(0) /* ; */])], - [ax_pthread_ok=yes], - []) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - AC_MSG_RESULT([$ax_pthread_ok]) - AS_IF([test "x$ax_pthread_ok" = "xyes"], [break]) - - PTHREAD_LIBS="" - PTHREAD_CFLAGS="" -done -fi - -# Various other checks: -if test "x$ax_pthread_ok" = "xyes"; then - ax_pthread_save_CFLAGS="$CFLAGS" - ax_pthread_save_LIBS="$LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - LIBS="$PTHREAD_LIBS $LIBS" - - # Detect AIX lossage: JOINABLE attribute is called UNDETACHED. - AC_CACHE_CHECK([for joinable pthread attribute], - [ax_cv_PTHREAD_JOINABLE_ATTR], - [ax_cv_PTHREAD_JOINABLE_ATTR=unknown - for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do - AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <pthread.h>], - [int attr = $ax_pthread_attr; return attr /* ; */])], - [ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break], - []) - done - ]) - AS_IF([test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xunknown" && \ - test "x$ax_cv_PTHREAD_JOINABLE_ATTR" != "xPTHREAD_CREATE_JOINABLE" && \ - test "x$ax_pthread_joinable_attr_defined" != "xyes"], - [AC_DEFINE_UNQUOTED([PTHREAD_CREATE_JOINABLE], - [$ax_cv_PTHREAD_JOINABLE_ATTR], - [Define to necessary symbol if this constant - uses a non-standard name on your system.]) - ax_pthread_joinable_attr_defined=yes - ]) - - AC_CACHE_CHECK([whether more special flags are required for pthreads], - [ax_cv_PTHREAD_SPECIAL_FLAGS], - [ax_cv_PTHREAD_SPECIAL_FLAGS=no - case $host_os in - solaris*) - ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS" - ;; - esac - ]) - AS_IF([test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \ - test "x$ax_pthread_special_flags_added" != "xyes"], - [PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS" - ax_pthread_special_flags_added=yes]) - - AC_CACHE_CHECK([for PTHREAD_PRIO_INHERIT], - [ax_cv_PTHREAD_PRIO_INHERIT], - [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <pthread.h>]], - [[int i = PTHREAD_PRIO_INHERIT;]])], - [ax_cv_PTHREAD_PRIO_INHERIT=yes], - [ax_cv_PTHREAD_PRIO_INHERIT=no]) - ]) - AS_IF([test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \ - test "x$ax_pthread_prio_inherit_defined" != "xyes"], - [AC_DEFINE([HAVE_PTHREAD_PRIO_INHERIT], [1], [Have PTHREAD_PRIO_INHERIT.]) - ax_pthread_prio_inherit_defined=yes - ]) - - CFLAGS="$ax_pthread_save_CFLAGS" - LIBS="$ax_pthread_save_LIBS" - - # More AIX lossage: compile with *_r variant - if test "x$GCC" != "xyes"; then - case $host_os in - aix*) - AS_CASE(["x/$CC"], - [x*/c89|x*/c89_128|x*/c99|x*/c99_128|x*/cc|x*/cc128|x*/xlc|x*/xlc_v6|x*/xlc128|x*/xlc128_v6], - [#handle absolute path differently from PATH based program lookup - AS_CASE(["x$CC"], - [x/*], - [AS_IF([AS_EXECUTABLE_P([${CC}_r])],[PTHREAD_CC="${CC}_r"])], - [AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC])])]) - ;; - esac - fi -fi - -test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" - -AC_SUBST([PTHREAD_LIBS]) -AC_SUBST([PTHREAD_CFLAGS]) -AC_SUBST([PTHREAD_CC]) - -# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND: -if test "x$ax_pthread_ok" = "xyes"; then - ifelse([$1],,[AC_DEFINE([HAVE_PTHREAD],[1],[Define if you have POSIX threads libraries and header files.])],[$1]) - : -else - ax_pthread_ok=no - $2 -fi -AC_LANG_POP -])dnl AX_PTHREAD diff --git a/m4/pkg.m4 b/m4/pkg.m4 deleted file mode 100644 index 9a71878..0000000 --- a/m4/pkg.m4 +++ /dev/null @@ -1,159 +0,0 @@ -# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*- -# serial 1 (pkg-config-0.24) -# -# Copyright © 2004 Scott James Remnant <scott@netsplit.com>. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, but -# WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -# General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -# -# As a special exception to the GNU General Public License, if you -# distribute this file as part of a program that contains a -# configuration script generated by Autoconf, you may include it under -# the same distribution terms that you use for the rest of that program. - -# PKG_PROG_PKG_CONFIG([MIN-VERSION]) -# ---------------------------------- -AC_DEFUN([PKG_PROG_PKG_CONFIG], -[m4_pattern_forbid([^_?PKG_[A-Z_]+$]) -m4_pattern_allow([^PKG_CONFIG(_(PATH|LIBDIR|SYSROOT_DIR|ALLOW_SYSTEM_(CFLAGS|LIBS)))?$]) -m4_pattern_allow([^PKG_CONFIG_(DISABLE_UNINSTALLED|TOP_BUILD_DIR|DEBUG_SPEW)$]) -AC_ARG_VAR([PKG_CONFIG], [path to pkg-config utility]) -AC_ARG_VAR([PKG_CONFIG_PATH], [directories to add to pkg-config's search path]) -AC_ARG_VAR([PKG_CONFIG_LIBDIR], [path overriding pkg-config's built-in search path]) - -if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then - AC_PATH_TOOL([PKG_CONFIG], [pkg-config]) -fi -if test -n "$PKG_CONFIG"; then - _pkg_min_version=m4_default([$1], [0.9.0]) - AC_MSG_CHECKING([pkg-config is at least version $_pkg_min_version]) - if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then - AC_MSG_RESULT([yes]) - else - AC_MSG_RESULT([no]) - PKG_CONFIG="" - fi -fi[]dnl -])# PKG_PROG_PKG_CONFIG - -# PKG_CHECK_EXISTS(MODULES, [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) -# -# Check to see whether a particular set of modules exists. Similar -# to PKG_CHECK_MODULES(), but does not set variables or print errors. -# -# Please remember that m4 expands AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -# only at the first occurence in configure.ac, so if the first place -# it's called might be skipped (such as if it is within an "if", you -# have to call PKG_CHECK_EXISTS manually -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_EXISTS], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -if test -n "$PKG_CONFIG" && \ - AC_RUN_LOG([$PKG_CONFIG --exists --print-errors "$1"]); then - m4_default([$2], [:]) -m4_ifvaln([$3], [else - $3])dnl -fi]) - -# _PKG_CONFIG([VARIABLE], [COMMAND], [MODULES]) -# --------------------------------------------- -m4_define([_PKG_CONFIG], -[if test -n "$$1"; then - pkg_cv_[]$1="$$1" - elif test -n "$PKG_CONFIG"; then - PKG_CHECK_EXISTS([$3], - [pkg_cv_[]$1=`$PKG_CONFIG --[]$2 "$3" 2>/dev/null` - test "x$?" != "x0" && pkg_failed=yes ], - [pkg_failed=yes]) - else - pkg_failed=untried -fi[]dnl -])# _PKG_CONFIG - -# _PKG_SHORT_ERRORS_SUPPORTED -# ----------------------------- -AC_DEFUN([_PKG_SHORT_ERRORS_SUPPORTED], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG]) -if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then - _pkg_short_errors_supported=yes -else - _pkg_short_errors_supported=no -fi[]dnl -])# _PKG_SHORT_ERRORS_SUPPORTED - - -# PKG_CHECK_MODULES(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND], -# [ACTION-IF-NOT-FOUND]) -# -# -# Note that if there is a possibility the first call to -# PKG_CHECK_MODULES might not happen, you should be sure to include an -# explicit call to PKG_PROG_PKG_CONFIG in your configure.ac -# -# -# -------------------------------------------------------------- -AC_DEFUN([PKG_CHECK_MODULES], -[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl -AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl -AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl - -pkg_failed=no -AC_MSG_CHECKING([for $1]) - -_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2]) -_PKG_CONFIG([$1][_LIBS], [libs], [$2]) - -m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS -and $1[]_LIBS to avoid the need to call pkg-config. -See the pkg-config man page for more details.]) - -if test $pkg_failed = yes; then - AC_MSG_RESULT([no]) - _PKG_SHORT_ERRORS_SUPPORTED - if test $_pkg_short_errors_supported = yes; then - $1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --print-errors --cflags --libs "$2" 2>&1` - else - $1[]_PKG_ERRORS=`$PKG_CONFIG --print-errors --cflags --libs "$2" 2>&1` - fi - # Put the nasty error message in config.log where it belongs - echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD - - m4_default([$4], [AC_MSG_ERROR( -[Package requirements ($2) were not met: - -$$1_PKG_ERRORS - -Consider adjusting the PKG_CONFIG_PATH environment variable if you -installed software in a non-standard prefix. - -_PKG_TEXT])[]dnl - ]) -elif test $pkg_failed = untried; then - AC_MSG_RESULT([no]) - m4_default([$4], [AC_MSG_FAILURE( -[The pkg-config script could not be found or is too old. Make sure it -is in your PATH or set the PKG_CONFIG environment variable to the full -path to pkg-config. - -_PKG_TEXT - -To get pkg-config, see <http://pkg-config.freedesktop.org/>.])[]dnl - ]) -else - $1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS - $1[]_LIBS=$pkg_cv_[]$1[]_LIBS - AC_MSG_RESULT([yes]) - $3 -fi[]dnl -])# PKG_CHECK_MODULES diff --git a/maint/README.md b/maint/README.md deleted file mode 100644 index 27ff7d8..0000000 --- a/maint/README.md +++ /dev/null @@ -1,93 +0,0 @@ -# How to release a new blogc version - -These are some rough steps required to produce a blogc release. - - -## Define version number - -- Read repository logs: - ``` - $ git log v0.18.0..HEAD # replace with whatever latest release - ``` -- Follow this criteria: - - Only bug fixes: Bump micro version. - - Something new: Bump minor version, set micro to `0`. - - We have no plans to change major version so far. Keep it `0`. - - -## Prepare release - -- Write blog post (repository is https://github.com/blogc/blogc.rgm.io/) - ``` - $ cp content/news/blogc-0.18.0.txt content/news/blogc-0.19.0.txt # replace versions - $ vim blogcfile # change LATEST_RELEASE, add new post file to the end of [posts] - $ vim content/news/blogc-0.19.0.txt # write the content, based on what changed. put some placeholder DATE - $ blogc-make runserver - ``` -- Copy manpage sources from main repository (https://github.com/blogc/blogc): - ``` - $ cp -r ../blogc/man/* man/ - $ make -C man - ``` - ronn output is not idempotent. It may rewrite HTML for manpages that are unchanged. Make sure to discard these changes somehow with git. -- Write GitHub release draft. Content is similar to blog post. No need to include lots of links. Always append this to the end of text: - ``` - Please download the custom tarballs, not the files generated automatically by GitHub, they are garbage. - ``` - - -## Bump version - -- Make sure that all the code is in place. -- Edit `blogc.spec.in`. Check if dependencies and packaging are still correct. - - If something needs update, do it. Then commit, push and wait for [CI](https://github.com/blogc/blogc/actions). After successful build, grab a `.src.rpm` from https://distfiles.rgm.io/blogc/LATEST/, upload to a test [Copr](https://copr.fedorainfracloud.org/), wait until it builds and follow also next step. - - If everything is ok, add a changelog line to the top of the `%changelog` section. -- Update debian version: - - If something needs update, do it. Then commit, push and wait for [CI](https://github.com/blogc/blogc/actions). - - Run `dch`: - ``` - $ dch --distribution unstable --newversion 0.19.0-1~0upstream "Upstream Release" - ``` -- Commit, push and wait for [CI](https://github.com/blogc/blogc/actions). -- Create signed tag: - ``` - $ git tag -s -m 'blogc-0.19.0' v0.19.0 # replace with whatever version you defined before - ``` - This requires my (rafaelmartins) personal GPG key. If someone else needs to publish a release, please announce the new key in the blog post and GitHub release. -- Push signed tag: - ``` - $ git push origin v0.19.0 # replace with whatever version you defined before - ``` -- Wait for [CI](https://github.com/blogc/blogc/actions) to build the release files and push them to https://distfiles.rgm.io/blogc/. - - -## Releasing new version - -- Download new release files and sign them: - ``` - $ ./download_release.py - ``` - This requires my (rafaelmartins) personal GPG key to sign files. If someone else needs to publish a release, please edit the script to add new GPG key and announce it in the blog post and GitHub release. -- Grab files from `releases/0.19.0` (replace version) and upload to GitHub release draft, including `.asc` files. The `.src.rpm` and tarballs with debs can be omited. -- Publish release on GitHub. -- Fix blog post DATE, commit and push. - - -## Maintain downstream packages -- Upload `.src.rpm` file to the [official Copr](https://copr.fedorainfracloud.org/coprs/rafaelmartins/blogc/). The Copr is owned by rafaelmartins, there's no concept of organizations. I believe that an user could request publish access here: https://copr.fedorainfracloud.org/coprs/rafaelmartins/blogc/permissions/ -- Prepare and submit [termux-packages](https://github.com/termux/termux-packages) pull request. - - Edit `packages/blogc/build.sh`. Update version. - - Try to build package (it will fail): - ``` - $ ./scripts/run-docker.sh ./build-package.sh blogc - ``` - - Get new SHA256 hash from last command and update `packages/blogc/build.sh`. - - Build package: - ``` - $ ./scripts/run-docker.sh ./build-package.sh blogc - ``` - - If everything builds fine, commit and create pull request. - -## Celebrate - - \o/ diff --git a/maint/download_release.py b/maint/download_release.py deleted file mode 100755 index 6618972..0000000 --- a/maint/download_release.py +++ /dev/null @@ -1,49 +0,0 @@ -#!/usr/bin/env python3 -# coding: utf-8 - -import os -import re -import requests -import shutil -import subprocess -import sys - -re_version = re.compile(r'blogc-([^\'"]+)\.tar\.gz') -re_distfile = re.compile(r'(blogc[^\'"]+)\.sha512') -base_url = 'https://distfiles.rgm.io/blogc' -cwd = os.path.dirname(os.path.abspath(__file__)) -gpg_key = '0x47B8CCD75DBE6358' - - -def download_release(version): - if version is None: - release_url = '%s/LATEST' % (base_url,) - r = requests.get(release_url) - r.raise_for_status() - match = re_version.search(r.text) - if match is None: - raise RuntimeError('Could not guess version') - version = match.group(1) - else: - release_url = '%s/blogc-%s' % (base_url, version) - r = requests.get(release_url) - r.raise_for_status() - - dest_path = os.path.join(cwd, 'releases', version) - if os.path.exists(dest_path): - shutil.rmtree(dest_path) - os.makedirs(dest_path) - - for distfile in set(re_distfile.findall(r.text)): - file_url = '%s/%s' % (release_url, distfile) - subprocess.check_call(['wget', '-P', dest_path, file_url, - '%s.sha512' % file_url]) - subprocess.check_call(['sha512sum', '-c', '%s.sha512' % distfile], - cwd=dest_path) - subprocess.check_call(['gpg', '--local-user', gpg_key, '--detach-sign', - '--armor', distfile], - cwd=dest_path) - - -if __name__ == '__main__': - download_release(sys.argv[1] if len(sys.argv) > 1 else None) diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt new file mode 100644 index 0000000..e5666cd --- /dev/null +++ b/man/CMakeLists.txt @@ -0,0 +1,69 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +option(BUILD_MANPAGES "Build manpages." OFF) +if(BUILD_MANPAGES) + find_program(RONN ronn REQUIRED) + + set(man1 + blogc.1 + blogc-git-receiver.1 + blogc-make.1 + blogc-runserver.1 + ) + + set(man5 + blogcfile.5 + ) + + set(man7 + blogc-pagination.7 + blogc-source.7 + blogc-template.7 + blogc-toctree.7 + ) + + set(manpages + ${man1} + ${man5} + ${man7} + ) + + foreach(man ${manpages}) + add_custom_command( + OUTPUT ${man} + COMMAND + ${RONN} + --roff + --organization "Rafael G. Martins" + --manual "blogc Manual" + --output-dir ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/${man}.ronn + DEPENDS ${man}.ronn + ) + + add_custom_target(man-${man} + ALL + DEPENDS ${man} + ) + endforeach() + + foreach(man ${man1}) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${man} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man1 + ) + endforeach() + foreach(man ${man5}) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${man} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man5 + ) + endforeach() + foreach(man ${man7}) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${man} + DESTINATION ${CMAKE_INSTALL_MANDIR}/man7 + ) + endforeach() +endif() diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt new file mode 100644 index 0000000..cc5af5d --- /dev/null +++ b/src/CMakeLists.txt @@ -0,0 +1,22 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(common) + +option(BUILD_BLOGC_MAKE "Build blogc-make binary." OFF) +option(BUILD_BLOGC_MAKE_EMBEDDED "Build blogc-make embedded into blogc binary." OFF) +if(BUILD_BLOGC_MAKE OR BUILD_BLOGC_MAKE_EMBEDDED) + add_subdirectory(blogc-make) +endif() + +option(BUILD_BLOGC_RUNSERVER "Build blogc-runserver binary." OFF) +if(BUILD_BLOGC_RUNSERVER) + add_subdirectory(blogc-runserver) +endif() + +option(BUILD_BLOGC_GIT_RECEIVER "Build blogc-git-receiver binary." OFF) +if(BUILD_BLOGC_GIT_RECEIVER) + add_subdirectory(blogc-git-receiver) +endif() + +add_subdirectory(blogc) diff --git a/src/blogc-git-receiver/CMakeLists.txt b/src/blogc-git-receiver/CMakeLists.txt new file mode 100644 index 0000000..57f5ab6 --- /dev/null +++ b/src/blogc-git-receiver/CMakeLists.txt @@ -0,0 +1,41 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT DEFINED HAVE_DIRENT_H OR + NOT DEFINED HAVE_ERRNO_H OR + NOT DEFINED HAVE_LIBGEN_H OR + NOT DEFINED HAVE_SYS_TYPES_H OR + NOT DEFINED HAVE_SYS_STAT_H OR + NOT DEFINED HAVE_TIME_H OR + NOT DEFINED HAVE_UNISTD_H) + message(FATAL_ERROR "Missing header dependencies for blogc-git-receiver") +endif() + +add_library(libblogc_git_receiver STATIC + post-receive.c + post-receive.h + pre-receive-parser.c + pre-receive-parser.h + pre-receive.c + pre-receive.h + settings.c + settings.h + shell-command-parser.c + shell-command-parser.h + shell.c + shell.h +) + +target_link_libraries(libblogc_git_receiver PRIVATE + libblogc_common +) + +add_executable(blogc-git-receiver + main.c +) + +target_link_libraries(blogc-git-receiver PRIVATE + libblogc_git_receiver +) + +install(TARGETS blogc-git-receiver) diff --git a/src/blogc-make/CMakeLists.txt b/src/blogc-make/CMakeLists.txt new file mode 100644 index 0000000..778db37 --- /dev/null +++ b/src/blogc-make/CMakeLists.txt @@ -0,0 +1,50 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT DEFINED HAVE_DIRENT_H OR + NOT DEFINED HAVE_FCNTL_H OR + NOT DEFINED HAVE_LIBGEN_H OR + NOT DEFINED HAVE_SYS_STAT_H OR + NOT DEFINED HAVE_SYS_WAIT_H OR + NOT DEFINED HAVE_TIME_H OR + NOT DEFINED HAVE_UNISTD_H) + message(FATAL_ERROR "Missing header dependencies for blogc-make") +endif() + +add_library(libblogc_make STATIC + atom.c + atom.h + ctx.c + ctx.h + exec.c + exec.h + exec-native.c + exec-native.h + httpd.c + httpd.h + reloader.c + reloader.h + rules.c + rules.h + settings.c + settings.h + utils.c + utils.h +) + +target_link_libraries(libblogc_make PRIVATE + libblogc_common + m +) + +if(NOT BUILD_BLOGC_MAKE_EMBEDDED) + add_executable(blogc-make + main.c + ) + + target_link_libraries(blogc-make PRIVATE + libblogc_make + ) + + install(TARGETS blogc-make) +endif() diff --git a/src/blogc-make/main.c b/src/blogc-make/main.c index 5d3f686..7007c1a 100644 --- a/src/blogc-make/main.c +++ b/src/blogc-make/main.c @@ -14,6 +14,10 @@ #include "ctx.h" #include "rules.h" +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "Unknown" +#endif + static void print_help(void) @@ -70,7 +74,7 @@ main(int argc, char **argv) print_help(); goto cleanup; case 'v': - printf("%s\n", PACKAGE_STRING); + printf("blogc " PACKAGE_VERSION "\n"); goto cleanup; case 'D': dev = true; diff --git a/src/blogc-runserver/CMakeLists.txt b/src/blogc-runserver/CMakeLists.txt new file mode 100644 index 0000000..09f203e --- /dev/null +++ b/src/blogc-runserver/CMakeLists.txt @@ -0,0 +1,37 @@ +# SPDX-FileCopyrightText: 2022 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT DEFINED HAVE_ARPA_INET_H OR + NOT DEFINED HAVE_FCNTL_H OR + NOT DEFINED HAVE_LIMITS_H OR + NOT DEFINED HAVE_NETINET_IN_H OR + NOT DEFINED HAVE_SIGNAL_H OR + NOT DEFINED HAVE_SYS_SOCKET_H OR + NOT DEFINED HAVE_SYS_STAT_H OR + NOT DEFINED HAVE_SYS_TYPES_H OR + NOT DEFINED HAVE_UNISTD_H) + message(FATAL_ERROR "Missing header dependencies for blogc-runserver") +endif() + +add_library(libblogc_runserver STATIC + httpd-utils.c + httpd-utils.h + httpd.c + httpd.h + mime.c + mime.h +) + +target_link_libraries(libblogc_runserver PRIVATE + libblogc_common +) + +add_executable(blogc-runserver + main.c +) + +target_link_libraries(blogc-runserver PRIVATE + libblogc_runserver +) + +install(TARGETS blogc-runserver) diff --git a/src/blogc-runserver/main.c b/src/blogc-runserver/main.c index ca402ec..8abd83a 100644 --- a/src/blogc-runserver/main.c +++ b/src/blogc-runserver/main.c @@ -11,6 +11,10 @@ #include "../common/utils.h" #include "httpd.h" +#ifndef PACKAGE_VERSION +#define PACKAGE_VERSION "Unknown" +#endif + static void print_help(const char *default_host, const char *default_port) @@ -71,7 +75,7 @@ main(int argc, char **argv) print_help(default_host, default_port); goto cleanup; case 'v': - printf("%s\n", PACKAGE_STRING); + printf("blogc " PACKAGE_VERSION "\n"); goto cleanup; case 't': if (argv[i][2] != '\0') diff --git a/src/blogc/CMakeLists.txt b/src/blogc/CMakeLists.txt new file mode 100644 index 0000000..bdc3f02 --- /dev/null +++ b/src/blogc/CMakeLists.txt @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +add_library(libblogc STATIC + content-parser.c + content-parser.h + datetime-parser.c + datetime-parser.h + debug.c + debug.h + filelist-parser.c + filelist-parser.h + funcvars.c + funcvars.h + loader.c + loader.h + renderer.c + renderer.h + rusage.c + rusage.h + source-parser.c + source-parser.h + sysinfo.c + sysinfo.h + template-parser.c + template-parser.h + toctree.c + toctree.h +) + +target_link_libraries(libblogc PRIVATE + libblogc_common + m +) + +add_executable(blogc + main.c +) + +target_link_libraries(blogc PRIVATE + libblogc +) + +if(BUILD_BLOGC_MAKE_EMBEDDED) + target_sources(blogc PRIVATE + ../blogc-make/main.c + ) + + target_link_libraries(blogc PRIVATE + libblogc_make + ) + + target_compile_definitions(blogc PRIVATE + MAKE_EMBEDDED + ) +endif() + +install(TARGETS blogc) diff --git a/src/blogc/main.c b/src/blogc/main.c index 1e21464..fb28ca1 100644 --- a/src/blogc/main.c +++ b/src/blogc/main.c @@ -156,7 +156,7 @@ main(int argc, char **argv) blogc_print_help(); goto cleanup; case 'v': - printf("%s\n", PACKAGE_STRING); + printf("blogc " PACKAGE_VERSION "\n"); goto cleanup; case 'd': debug = true; diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt new file mode 100644 index 0000000..1619f95 --- /dev/null +++ b/src/common/CMakeLists.txt @@ -0,0 +1,21 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +add_library(libblogc_common STATIC + compat.c + compat.h + config-parser.c + config-parser.h + error.c + error.h + file.c + file.h + sort.c + sort.h + stdin.c + stdin.h + utf8.c + utf8.h + utils.c + utils.h +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt new file mode 100644 index 0000000..e1ca881 --- /dev/null +++ b/tests/CMakeLists.txt @@ -0,0 +1,91 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +find_package(PkgConfig REQUIRED) +pkg_check_modules(CMOCKA IMPORTED_TARGET cmocka) + +find_program(BASH bash HINTS /bin /usr/bin REQUIRED) +find_program(DIFF diff REQUIRED) +find_program(TEE tee REQUIRED) + +try_compile(HAVE_LD_WRAP + SOURCE_FROM_CONTENT + main.c + "#include <stdlib.h>\nvoid __real_exit(int status);\nvoid __wrap_exit(int s){__real_exit(0);}\nint main(){exit(1);}" + LINK_OPTIONS + "-Wl,--wrap=exit" +) + +function(blogc_executable_test _libname _src) + if (NOT CMOCKA_FOUND) + message(STATUS "Skipping test (cmocka not found): ${_libname}_check_${_src}") + return() + endif() + + cmake_parse_arguments(_blogc_executable_test + "" + "" + "WRAP" + ${ARGN} + ) + + if(DEFINED _blogc_executable_test_WRAP) + if(NOT HAVE_LD_WRAP) + message(STATUS "Skipping test (no ld wrap): ${_libname}_check_${_src}") + return() + endif() + endif() + + add_executable(${_libname}_check_${_src} + check_${_src}.c + ) + + if(DEFINED _blogc_executable_test_WRAP) + list(JOIN _blogc_executable_test_WRAP ",--wrap=" _wrap) + set_target_properties(${_libname}_check_${_src} + PROPERTIES LINK_FLAGS + "-Wl,--wrap=${_wrap}" + ) + endif() + + target_link_libraries(${_libname}_check_${_src} PRIVATE + PkgConfig::CMOCKA + lib${_libname} + ) + + add_test( + NAME ${_libname}_check_${_src} + COMMAND + ${CMAKE_SOURCE_DIR}/cmake/scripts/test.sh + ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_check_${_src} + ) +endfunction() + +function(blogc_script_test _libname _src) + configure_file( + check_${_src}.sh.in + ${_libname}_check_${_src}.sh + @ONLY + ) + add_test( + NAME ${_libname}_check_${_src}.sh + COMMAND + ${CMAKE_SOURCE_DIR}/cmake/scripts/test.sh + ${CMAKE_CURRENT_BINARY_DIR}/${_libname}_check_${_src}.sh + ) +endfunction() + +add_subdirectory(common) +add_subdirectory(blogc) + +if(BUILD_BLOGC_MAKE OR BUILD_BLOGC_MAKE_EMBEDDED) + add_subdirectory(blogc-make) +endif() + +if(BUILD_BLOGC_RUNSERVER) + add_subdirectory(blogc-runserver) +endif() + +if(BUILD_BLOGC_GIT_RECEIVER) + add_subdirectory(blogc-git-receiver) +endif() diff --git a/tests/blogc-git-receiver/CMakeLists.txt b/tests/blogc-git-receiver/CMakeLists.txt new file mode 100644 index 0000000..c0e88a7 --- /dev/null +++ b/tests/blogc-git-receiver/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +if(NOT Git_FOUND) + message(FATAL_ERROR "blogc-git-receiver tests require Git.") +endif() + +find_program(MAKE make gmake REQUIRED) +find_program(TAR tar REQUIRED) + +blogc_executable_test(blogc_git_receiver pre_receive_parser) +blogc_executable_test(blogc_git_receiver settings + WRAP + realpath +) +blogc_executable_test(blogc_git_receiver shell_command_parser) +blogc_script_test(blogc_git_receiver post_receive) +blogc_script_test(blogc_git_receiver pre_receive) +blogc_script_test(blogc_git_receiver shell) diff --git a/tests/blogc-git-receiver/check_post_receive.sh.in b/tests/blogc-git-receiver/check_post_receive.sh.in index 53535f4..831e032 100755 --- a/tests/blogc-git-receiver/check_post_receive.sh.in +++ b/tests/blogc-git-receiver/check_post_receive.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -20,7 +22,7 @@ trap trap_func EXIT mkdir -p "${TEMP}/repos" git init --bare "${TEMP}/repos/foo.git" &> /dev/null -ln -s "@abs_top_builddir@/blogc-git-receiver" "${TEMP}/repos/foo.git/hooks/post-receive" +ln -s "${BLOGC_GIT_RECEIVER}" "${TEMP}/repos/foo.git/hooks/post-receive" cat > "${TEMP}/tmp.txt" <<EOF blob diff --git a/tests/blogc-git-receiver/check_pre_receive.sh.in b/tests/blogc-git-receiver/check_pre_receive.sh.in index 2c36f4c..6a5dd30 100755 --- a/tests/blogc-git-receiver/check_pre_receive.sh.in +++ b/tests/blogc-git-receiver/check_pre_receive.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -20,7 +22,7 @@ trap trap_func EXIT mkdir -p "${TEMP}/repos" git init --bare "${TEMP}/repos/foo.git" &> /dev/null -SELF="@abs_top_builddir@/blogc-git-receiver" +SELF="${BLOGC_GIT_RECEIVER}" ln -s "${SELF}" "${TEMP}/repos/foo.git/hooks/pre-receive" diff --git a/tests/blogc-git-receiver/check_shell.sh.in b/tests/blogc-git-receiver/check_shell.sh.in index bf25029..fca9dea 100755 --- a/tests/blogc-git-receiver/check_shell.sh.in +++ b/tests/blogc-git-receiver/check_shell.sh.in @@ -6,6 +6,7 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC_GIT_RECEIVER="@CMAKE_BINARY_DIR@/src/blogc-git-receiver/blogc-git-receiver" TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -17,7 +18,7 @@ trap_func() { trap trap_func EXIT -SELF="@abs_top_builddir@/blogc-git-receiver" +SELF="${BLOGC_GIT_RECEIVER}" call_bgr() { [[ -n "${VALGRIND}" ]] && export __VALGRIND_ENABLED=1 diff --git a/tests/blogc-make/CMakeLists.txt b/tests/blogc-make/CMakeLists.txt new file mode 100644 index 0000000..9990eae --- /dev/null +++ b/tests/blogc-make/CMakeLists.txt @@ -0,0 +1,19 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_make atom) +blogc_executable_test(blogc_make exec + WRAP + access +) +blogc_executable_test(blogc_make rules) +blogc_executable_test(blogc_make settings) +blogc_executable_test(blogc_make utils) + +if(BUILD_BLOGC_MAKE_EMBEDDED) + set(_BLOGC_MAKE "${CMAKE_BINARY_DIR}/src/blogc/blogc -m") +else() + set(_BLOGC_MAKE "${CMAKE_BINARY_DIR}/src/blogc-make/blogc-make") +endif() + +blogc_script_test(blogc_make blogc_make) diff --git a/tests/blogc-make/check_blogc_make.sh.in b/tests/blogc-make/check_blogc_make.sh.in index d999840..429632c 100755 --- a/tests/blogc-make/check_blogc_make.sh.in +++ b/tests/blogc-make/check_blogc_make.sh.in @@ -7,7 +7,8 @@ set -xe -o pipefail export LC_ALL=C -export BLOGC=@abs_top_builddir@/blogc +export BLOGC="@CMAKE_BINARY_DIR@/src/blogc/blogc" +export BLOGC_MAKE="@_BLOGC_MAKE@" TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -33,7 +34,7 @@ SITE_TAGLINE = WAT?! BASE_DOMAIN = http://example.org EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 ### default settings with some posts @@ -81,7 +82,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -198,7 +199,7 @@ post10 post11 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" @@ -487,7 +488,7 @@ cat > "${TEMP}/proj/templates/atom.tmpl" <<EOF </feed> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" @@ -695,7 +696,7 @@ post10 post11 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" grep "_build/post/post02/index\\.html" "${TEMP}/output.txt" grep "_build/post/post03/index\\.html" "${TEMP}/output.txt" @@ -769,7 +770,7 @@ qwe asd EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/post/post01/index\\.html" "${TEMP}/output.txt" grep "_build/post/post02/index\\.html" "${TEMP}/output.txt" grep "_build/post/post03/index\\.html" "${TEMP}/output.txt" @@ -874,7 +875,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -981,7 +982,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -1096,7 +1097,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/page/1/index\\.html" "${TEMP}/output.txt" @@ -1203,7 +1204,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt" @@ -1408,7 +1409,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/atom\\.xml" "${TEMP}/output.txt" grep "_build/atom/tag1\\.xml" "${TEMP}/output.txt" @@ -1531,7 +1532,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/pagination/1\\.html" "${TEMP}/output.txt" @@ -1631,7 +1632,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1780,7 +1781,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1864,7 +1865,7 @@ d/xd f EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1903,7 +1904,7 @@ test "$(cat "${TEMP}/proj/_build/f/XDDDD")" = "FFFUUUUUU" ### clean rule -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" grep "_build/posts\\.html" "${TEMP}/output.txt" grep "_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1936,7 +1937,7 @@ rm "${TEMP}/output.txt" export OUTPUT_DIR="${TEMP}/___blogc_build" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "___blogc_build/posts\\.html" "${TEMP}/output.txt" grep "___blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "___blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -1965,7 +1966,7 @@ grep "___blogc_build/f/XDDDD" "${TEMP}/output.txt" rm "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" clean 2>&1 | tee "${TEMP}/output.txt" grep "___blogc_build/posts\\.html" "${TEMP}/output.txt" grep "___blogc_build/atoom/index\\.xml" "${TEMP}/output.txt" grep "___blogc_build/atoom/tag1/index\\.xml" "${TEMP}/output.txt" @@ -2001,7 +2002,7 @@ unset OUTPUT_DIR ### atom_dump rule -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" atom_dump | tee "${TEMP}/atom.xml" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" atom_dump | tee "${TEMP}/atom.xml" cat > "${TEMP}/expected-atom-dump.xml" <<EOF <?xml version="1.0" encoding="utf-8"?> @@ -2101,7 +2102,7 @@ foo bar EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/1/index\\.html" "${TEMP}/output.txt" @@ -2231,7 +2232,7 @@ tag1 tag2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/tag1/index\\.xml" "${TEMP}/output.txt" @@ -2406,7 +2407,7 @@ page1 page2 EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc-make -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" +${TESTS_ENVIRONMENT} ${BLOGC_MAKE} -f "${TEMP}/proj/blogcfile" 2>&1 | tee "${TEMP}/output.txt" grep "_build/index\\.html" "${TEMP}/output.txt" grep "_build/index\\.xml" "${TEMP}/output.txt" grep "_build/tag1/index\\.xml" "${TEMP}/output.txt" diff --git a/tests/blogc-runserver/CMakeLists.txt b/tests/blogc-runserver/CMakeLists.txt new file mode 100644 index 0000000..b2cdc4d --- /dev/null +++ b/tests/blogc-runserver/CMakeLists.txt @@ -0,0 +1,11 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_runserver httpd_utils + WRAP + read +) +blogc_executable_test(blogc_runserver mime + WRAP + access +) diff --git a/tests/blogc/CMakeLists.txt b/tests/blogc/CMakeLists.txt new file mode 100644 index 0000000..0156d7a --- /dev/null +++ b/tests/blogc/CMakeLists.txt @@ -0,0 +1,33 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc content_parser) +blogc_executable_test(blogc datetime_parser) +blogc_executable_test(blogc filelist_parser) +blogc_executable_test(blogc funcvars + WRAP + bc_file_get_contents +) +blogc_executable_test(blogc loader + WRAP + bc_file_get_contents +) +blogc_executable_test(blogc renderer) +blogc_executable_test(blogc rusage + WRAP + getrusage +) +blogc_executable_test(blogc source_parser) +blogc_executable_test(blogc sysinfo + WRAP + bc_file_get_contents + getenv + gethostbyname + gethostname + gmtime + time +) +blogc_executable_test(blogc sysinfo2) +blogc_executable_test(blogc template_parser) +blogc_executable_test(blogc toctree) +blogc_script_test(blogc blogc) diff --git a/tests/blogc/check_blogc.sh.in b/tests/blogc/check_blogc.sh.in index 8b23d3e..2bb2d75 100755 --- a/tests/blogc/check_blogc.sh.in +++ b/tests/blogc/check_blogc.sh.in @@ -7,6 +7,8 @@ set -xe -o pipefail export LC_ALL=C +export BLOGC="@CMAKE_BINARY_DIR@/src/blogc/blogc" + TEMP="$(mktemp -d)" [[ -n "${TEMP}" ]] @@ -16,7 +18,7 @@ trap_func() { trap trap_func EXIT -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc -v | grep blogc +${TESTS_ENVIRONMENT} ${BLOGC} -v | grep blogc cat > "${TEMP}/post1.txt" <<EOF TITLE: foo @@ -112,7 +114,7 @@ cat > "${TEMP}/expected-output.xml" <<EOF </feed> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -126,7 +128,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output.xml" "${TEMP}/expected-output.xml" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -140,7 +142,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output2.xml" "${TEMP}/expected-output.xml" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -153,7 +155,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output3.xml" "${TEMP}/expected-output.xml" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D AUTHOR_NAME=Chunda \ @@ -259,7 +261,7 @@ cat > "${TEMP}/expected-output.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -272,7 +274,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output.html" "${TEMP}/expected-output.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -285,7 +287,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output2.html" "${TEMP}/expected-output.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -297,7 +299,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output3.html" "${TEMP}/expected-output.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -342,7 +344,7 @@ cat > "${TEMP}/expected-output2.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -353,7 +355,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output5.html" "${TEMP}/expected-output2.html" -echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -364,7 +366,7 @@ echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output6.html" "${TEMP}/expected-output2.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -374,7 +376,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output7.html" "${TEMP}/expected-output2.html" -echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -422,7 +424,7 @@ cat > "${TEMP}/expected-output3.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -435,7 +437,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output9.html" "${TEMP}/expected-output3.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -448,7 +450,7 @@ echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_b diff -uN "${TEMP}/output10.html" "${TEMP}/expected-output3.html" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -460,7 +462,7 @@ ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ diff -uN "${TEMP}/output11.html" "${TEMP}/expected-output3.html" -echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +echo -e "${TEMP}/post1.txt\n${TEMP}/post2.txt" | ${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -510,7 +512,7 @@ cat > "${TEMP}/expected-output4.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -565,7 +567,7 @@ cat > "${TEMP}/expected-output5.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -607,7 +609,7 @@ cat > "${TEMP}/expected-output6.html" <<EOF </html> EOF -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D BASE_DOMAIN=http://bola.com/ \ -D BASE_URL= \ -D SITE_TITLE="Chunda's website" \ @@ -620,20 +622,20 @@ diff -uN "${TEMP}/output15.html" "${TEMP}/expected-output6.html" echo "{% block listig %}foo{% endblock %}\n" > "${TEMP}/error.tmpl" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -t "${TEMP}/error.tmpl" \ "${TEMP}/post1.txt" 2>&1 | tee "${TEMP}/output.txt" || true grep "blogc: error: template: Invalid block type" "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D 123=a 2>&1 | tee "${TEMP}/output.txt" || true grep \ "blogc: error: invalid value for -D (first character in configuration key must be uppercase): 123" \ "${TEMP}/output.txt" -${TESTS_ENVIRONMENT} @abs_top_builddir@/blogc \ +${TESTS_ENVIRONMENT} ${BLOGC} \ -D A1-3=a 2>&1 | tee "${TEMP}/output.txt" || true grep \ diff --git a/tests/common/CMakeLists.txt b/tests/common/CMakeLists.txt new file mode 100644 index 0000000..9d784fa --- /dev/null +++ b/tests/common/CMakeLists.txt @@ -0,0 +1,12 @@ +# SPDX-FileCopyrightText: 2024 Rafael G. Martins <rafael@rafaelmartins.eng.br> +# SPDX-License-Identifier: BSD-3-Clause + +blogc_executable_test(blogc_common config_parser) +blogc_executable_test(blogc_common error) +blogc_executable_test(blogc_common sort) +blogc_executable_test(blogc_common stdin + WRAP + fgetc +) +blogc_executable_test(blogc_common utf8) +blogc_executable_test(blogc_common utils) |