diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fa4f56defb..4d5ebce18e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,48 +30,8 @@ jobs: - ppc64el - riscv64 - s390x - include: - - arch: amd64 - CC: x86_64-linux-gnu - - arch: arm64 - CC: aarch64-linux-gnu - - arch: armel - CC: arm-linux-gnueabi - - arch: armhf - CC: arm-linux-gnueabihf - - arch: i386 - CC: i686-linux-gnu - - arch: mips - CC: mips-linux-gnu - - arch: mips64 - CC: mips64-linux-gnuabi64 - - arch: mips64el - CC: mips64el-linux-gnuabi64 - - arch: mips64r6 - CC: mipsisa64r6-linux-gnuabi64 - - arch: mips64r6el - CC: mipsisa64r6el-linux-gnuabi64 - - arch: mipsel - CC: mipsel-linux-gnu - - arch: mipsr6 - CC: mipsisa32r6-linux-gnu - - arch: mipsr6el - CC: mipsisa32r6el-linux-gnu - - arch: powerpc - CC: powerpc-linux-gnu - - arch: ppc64el - CC: powerpc64le-linux-gnu - - arch: riscv64 - CC: riscv64-linux-gnu - - arch: s390x - CC: s390x-linux-gnu runs-on: ${{ matrix.arch == 'i386' && 'ubuntu-22.04' || 'ubuntu-24.04' }} env: - AR: ${{ matrix.CC }}-ar - CHOST: ${{ matrix.CC }} - CC: ${{ matrix.CC }}-gcc - CPP: ${{ matrix.CC }}-cpp - LDFLAGS: -s SUFFIX: linux-${{ matrix.arch }} steps: - name: Clone repository @@ -81,25 +41,17 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install -y automake autoconf libtool crossbuild-essential-${{ matrix.arch }} + sudo apt-get install -y crossbuild-essential-${{ matrix.arch }} meson - name: Build run: | - autoreconf -i - ./configure \ - --host=${{ matrix.CC }} \ - --disable-docs \ - --with-oniguruma=builtin \ - --enable-static \ - --enable-all-static \ - CFLAGS="-O2 -pthread -fstack-protector-all" - make -j"$(nproc)" - file ./jq - cp ./jq jq-${{ env.SUFFIX }} + meson setup _build -Doniguruma=builtin --cross-file .github/workflows/cross-compilation/linux-${{ matrix.arch }}.txt + ninja -v -C _build + cp _build/src/jq jq-${{ env.SUFFIX }} - name: Test # Only run tests for amd64 matching the CI machine arch if: ${{ matrix.arch == 'amd64' }} run: | - make check VERBOSE=yes + ninja -v -C _build test git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -108,8 +60,7 @@ jobs: name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt - name: Upload artifacts uses: actions/upload-artifact@v7 with: @@ -132,7 +83,6 @@ jobs: target: arm64-apple-darwin runs-on: macos-14 env: - LDFLAGS: -dead_strip SUFFIX: macos-${{ matrix.arch }} steps: - name: Clone repository @@ -143,28 +93,19 @@ jobs: run: | # brew update sometimes fails with "Fetching /usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask failed!" brew update || brew update-reset - brew install autoconf automake libtool + brew install meson - name: Set CC run: | echo "CC=clang -target ${{ matrix.target }}$(uname -r)" >> "$GITHUB_ENV" - name: Build run: | - autoreconf -i - ./configure \ - --host="${{ matrix.target }}$(uname -r)" \ - --disable-docs \ - --with-oniguruma=builtin \ - --disable-shared \ - --enable-static \ - --enable-all-static \ - CFLAGS="-O2 -pthread -fstack-protector-all" - make -j"$(sysctl -n hw.logicalcpu)" - strip ./jq - file ./jq - cp ./jq jq-${{ env.SUFFIX }} + meson setup _build -Ddocs=false -Doniguruma=builtin -Ddefault_library=static -Dbuildtype=release -Dstrip=true -Dbison=auto + ninja -v -C _build + file _build/src/jq + cp _build/src/jq jq-${{ env.SUFFIX }} - name: Test run: | - make check VERBOSE=yes + ninja -v -C _build test git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -173,8 +114,7 @@ jobs: name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt - name: Upload artifacts uses: actions/upload-artifact@v7 with: @@ -203,7 +143,6 @@ jobs: os: windows-11-arm runs-on: ${{ matrix.os }} env: - LDFLAGS: -s SUFFIX: windows-${{ matrix.arch }} defaults: run: @@ -223,27 +162,19 @@ jobs: install: >- base-devel git - autoconf - automake - libtool pacboy: >- + meson + cmake toolchain:p - name: Build run: | - autoreconf -i - ./configure \ - --disable-docs \ - --with-oniguruma=builtin \ - --disable-shared \ - --enable-static \ - --enable-all-static \ - CFLAGS="-O2 -pthread -fstack-protector-all -Wl,--stack,8388608" - make -j$(nproc) - file ./jq.exe - cp ./jq.exe jq-${{ env.SUFFIX }}.exe + meson setup _build -Ddocs=false -Doniguruma=builtin -Ddefault_library=static + ninja -v -C _build + file _build/src/jq + cp _build/src/jq.exe jq-${{ env.SUFFIX }}.exe - name: Test run: | - make check VERBOSE=yes + ninja -v -C _build test git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -252,8 +183,7 @@ jobs: name: test-logs-${{ env.SUFFIX }} retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt - name: Upload artifacts uses: actions/upload-artifact@v7 with: @@ -272,16 +202,12 @@ jobs: - name: Install packages run: | sudo apt-get update -qq - sudo apt-get install -y automake autoconf + sudo apt-get install -y meson - name: Create dist run: | - autoreconf -i - ./configure \ - --disable-docs \ - --with-oniguruma=builtin - make distcheck - make dist dist-zip - git diff --exit-code + meson setup _build -Doniguruma=builtin -Ddocs=false + meson dist -C _build --formats xztar + meson dist -C _build --formats zip --no-tests - name: Upload artifacts uses: actions/upload-artifact@v7 with: @@ -289,8 +215,8 @@ jobs: if-no-files-found: error retention-days: 7 path: | - jq-*.tar.gz - jq-*.zip + _build/meson-dist/jq-*.tar* + _build/meson-dist/jq-*.zip docker: runs-on: ubuntu-latest diff --git a/.github/workflows/cross-compilation/linux-amd64.txt b/.github/workflows/cross-compilation/linux-amd64.txt new file mode 100644 index 0000000000..5413b3f452 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-amd64.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'x86_64-linux-gnu-gcc' +cpp = 'x86_64-linux-gnu-g++' +ar = 'x86_64-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'amd64' +cpu = 'amd64' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-arm64.txt b/.github/workflows/cross-compilation/linux-arm64.txt new file mode 100644 index 0000000000..3bc9b2b374 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-arm64.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'aarch64-linux-gnu-gcc' +cpp = 'aarch64-linux-gnu-g++' +ar = 'aarch64-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'arm64' +cpu = 'arm64' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-armel.txt b/.github/workflows/cross-compilation/linux-armel.txt new file mode 100644 index 0000000000..1c717cb5ea --- /dev/null +++ b/.github/workflows/cross-compilation/linux-armel.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'arm-linux-gnueabi-gcc' +cpp = 'arm-linux-gnueabi-g++' +ar = 'arm-linux-gnueabi-ar' + +[host_machine] +system = 'linux' +cpu_family = 'armel' +cpu = 'armel' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-armhf.txt b/.github/workflows/cross-compilation/linux-armhf.txt new file mode 100644 index 0000000000..f0697682ad --- /dev/null +++ b/.github/workflows/cross-compilation/linux-armhf.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'arm-linux-gnueabihf-gcc' +cpp = 'arm-linux-gnueabihf-g++' +ar = 'arm-linux-gnueabihf-ar' + +[host_machine] +system = 'linux' +cpu_family = 'armhf' +cpu = 'armhf' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-i386.txt b/.github/workflows/cross-compilation/linux-i386.txt new file mode 100644 index 0000000000..e27e9ce674 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-i386.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'i686-linux-gnu-gcc' +cpp = 'i686-linux-gnu-g++' +ar = 'i686-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'i386' +cpu = 'i386' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mips.txt b/.github/workflows/cross-compilation/linux-mips.txt new file mode 100644 index 0000000000..bf9fb80541 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mips.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mips-linux-gnu-gcc' +cpp = 'mips-linux-gnu-g++' +ar = 'mips-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mips' +cpu = 'mips' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mips64.txt b/.github/workflows/cross-compilation/linux-mips64.txt new file mode 100644 index 0000000000..47976bde41 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mips64.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mips64-linux-gnuabi64-gcc' +cpp = 'mips64-linux-gnuabi64-g++' +ar = 'mips64-linux-gnuabi64-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mips64' +cpu = 'mips64' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mips64el.txt b/.github/workflows/cross-compilation/linux-mips64el.txt new file mode 100644 index 0000000000..37bc9d2c84 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mips64el.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mips64el-linux-gnuabi64-gcc' +cpp = 'mips64el-linux-gnuabi64-g++' +ar = 'mips64el-linux-gnuabi64-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mips64el' +cpu = 'mips64el' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mips64r6.txt b/.github/workflows/cross-compilation/linux-mips64r6.txt new file mode 100644 index 0000000000..9651cbe5e4 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mips64r6.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mipsisa64r6-linux-gnuabi64-gcc' +cpp = 'mipsisa64r6-linux-gnuabi64-g++' +ar = 'mipsisa64r6-linux-gnuabi64-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mips64r6' +cpu = 'mips64r6' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mips64r6el.txt b/.github/workflows/cross-compilation/linux-mips64r6el.txt new file mode 100644 index 0000000000..ef2e07dce4 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mips64r6el.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mipsisa64r6el-linux-gnuabi64-gcc' +cpp = 'mipsisa64r6el-linux-gnuabi64-g++' +ar = 'mipsisa64r6el-linux-gnuabi64-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mips64r6el' +cpu = 'mips64r6el' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mipsel.txt b/.github/workflows/cross-compilation/linux-mipsel.txt new file mode 100644 index 0000000000..8636911972 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mipsel.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mipsel-linux-gnu-gcc' +cpp = 'mipsel-linux-gnu-g++' +ar = 'mipsel-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mipsel' +cpu = 'mipsel' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mipsr6.txt b/.github/workflows/cross-compilation/linux-mipsr6.txt new file mode 100644 index 0000000000..2768fba116 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mipsr6.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mipsisa32r6-linux-gnu-gcc' +cpp = 'mipsisa32r6-linux-gnu-g++' +ar = 'mipsisa32r6-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mipsr6' +cpu = 'mipsr6' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-mipsr6el.txt b/.github/workflows/cross-compilation/linux-mipsr6el.txt new file mode 100644 index 0000000000..96960ea6c6 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-mipsr6el.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'mipsisa32r6el-linux-gnu-gcc' +cpp = 'mipsisa32r6el-linux-gnu-g++' +ar = 'mipsisa32r6el-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'mipsr6el' +cpu = 'mipsr6el' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-powerpc.txt b/.github/workflows/cross-compilation/linux-powerpc.txt new file mode 100644 index 0000000000..eb70f5adb9 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-powerpc.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'powerpc-linux-gnu-gcc' +cpp = 'powerpc-linux-gnu-g++' +ar = 'powerpc-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'powerpc' +cpu = 'powerpc' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-ppc64el.txt b/.github/workflows/cross-compilation/linux-ppc64el.txt new file mode 100644 index 0000000000..bdde0151d9 --- /dev/null +++ b/.github/workflows/cross-compilation/linux-ppc64el.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'powerpc64le-linux-gnu-gcc' +cpp = 'powerpc64le-linux-gnu-g++' +ar = 'powerpc64le-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'ppc64el' +cpu = 'ppc64el' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-riscv64.txt b/.github/workflows/cross-compilation/linux-riscv64.txt new file mode 100644 index 0000000000..b7f7b34f0b --- /dev/null +++ b/.github/workflows/cross-compilation/linux-riscv64.txt @@ -0,0 +1,10 @@ +[binaries] +c = 'riscv64-linux-gnu-gcc' +cpp = 'riscv64-linux-gnu-g++' +ar = 'riscv64-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 'riscv64' +cpu = 'riscv64' +endian = 'little' diff --git a/.github/workflows/cross-compilation/linux-s390x.txt b/.github/workflows/cross-compilation/linux-s390x.txt new file mode 100644 index 0000000000..0396978d3e --- /dev/null +++ b/.github/workflows/cross-compilation/linux-s390x.txt @@ -0,0 +1,10 @@ +[binaries] +c = 's390x-linux-gnu-gcc' +cpp = 's390x-linux-gnu-g++' +ar = 's390x-linux-gnu-ar' + +[host_machine] +system = 'linux' +cpu_family = 's390x' +cpu = 's390x' +endian = 'little' diff --git a/.github/workflows/decnum.yml b/.github/workflows/decnum.yml index 81c7d91e70..a79a54cfa6 100644 --- a/.github/workflows/decnum.yml +++ b/.github/workflows/decnum.yml @@ -16,20 +16,17 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install -y automake autoconf libtool + sudo apt-get install -y meson - name: Build run: | - autoreconf -i - ./configure \ - --disable-docs \ - --disable-maintainer-mode \ - --disable-decnum - make -j"$(nproc)" - file ./jq + meson setup _build -Ddocs=false -Ddecnum=false + ninja -v -C _build + file _build/src/jq - name: Test run: | - diff <(echo 100000000000000000000 | ./jq) <(echo 1e+20) - make check VERBOSE=yes + cd _build + diff <(echo 100000000000000000000 | ./src/jq) <(echo 1e+20) + meson test -v git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -38,5 +35,4 @@ jobs: name: test-logs-decnum-disabled retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt diff --git a/.github/workflows/manpage.yml b/.github/workflows/manpage.yml index 9c77b7ec1f..6693d12501 100644 --- a/.github/workflows/manpage.yml +++ b/.github/workflows/manpage.yml @@ -21,6 +21,10 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v6 + - name: Install packages + run: | + sudo apt-get update + sudo apt-get install -y meson - name: Setup Python uses: actions/setup-python@v6 with: @@ -36,16 +40,13 @@ jobs: working-directory: docs - name: Configure run: | - autoreconf -i - ./configure --enable-docs + meson setup _build -Doniguruma=false - name: Build man page, man.test, manonig.test run: | - mv jq.1.prebuilt jq.1.old - rm -f tests/man.test manonig.test - make jq.1.prebuilt tests/man.test tests/manonig.test + ninja -v -C _build docs/jq.1 build_mantests - name: Make sure that jq.1.prebuilt, man.test, manonig.test are up to date run: | git diff --exit-code tests/man.test tests/manonig.test # skip build date in jq.1.prebuilt test -s jq.1.prebuilt - diff -- <(tail -n +3 jq.1.old) <(tail -n +3 jq.1.prebuilt) + diff -- <(tail -n +3 jq.1.prebuilt) <(tail -n +3 _build/docs/jq.1) diff --git a/.github/workflows/oniguruma.yml b/.github/workflows/oniguruma.yml index ea36ddf27e..58746ded28 100644 --- a/.github/workflows/oniguruma.yml +++ b/.github/workflows/oniguruma.yml @@ -16,20 +16,17 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install -y automake autoconf libtool valgrind libonig-dev + sudo apt-get install -y meson valgrind libonig-dev - name: Build run: | - autoreconf -i - ./configure \ - --disable-docs \ - --enable-valgrind \ - --with-oniguruma=yes - make -j"$(nproc)" - file ./jq + meson setup _build -Ddocs=false -Dvalgrind=true -Doniguruma=system + ninja -v -C _build + file _build/src/jq - name: Test run: | - ./jq -n '"" | test("")' - make check VERBOSE=yes + cd _build + ./src/jq -n '"" | test("")' + meson test -v git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -38,8 +35,7 @@ jobs: name: test-logs-oniguruma-installed retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt disabled: runs-on: ubuntu-24.04 @@ -49,20 +45,17 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install -y automake autoconf libtool valgrind + sudo apt-get install -y meson - name: Build run: | - autoreconf -i - ./configure \ - --disable-docs \ - --enable-valgrind \ - --with-oniguruma=no - make -j"$(nproc)" - file ./jq + meson setup _build -Ddocs=false -Dvalgrind=true -Doniguruma=false + ninja -v -C _build + file _build/src/jq - name: Test run: | - ! ./jq -n '"" | test("")' - make check VERBOSE=yes + cd _build + ! ./src/jq -n '"" | test("")' + meson test -v git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -71,5 +64,4 @@ jobs: name: test-logs-oniguruma-disabled retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt diff --git a/.github/workflows/scanbuild.yml b/.github/workflows/scanbuild.yml index 21800a1500..337131718c 100644 --- a/.github/workflows/scanbuild.yml +++ b/.github/workflows/scanbuild.yml @@ -16,17 +16,16 @@ jobs: - name: Install packages run: | sudo apt-get update -qq - sudo apt-get install -y automake autoconf gdb valgrind clang clang-tools + sudo apt-get install -y meson valgrind clang clang-tools echo "CC=clang" >> "$GITHUB_ENV" - name: Build run: | - autoreconf -i - ./configure --enable-valgrind CFLAGS="-g -O0" - scan-build --keep-going --exclude vendor/ make -j"$(nproc)" + meson setup -Dvalgrind=true -Dbuildtype=debug + scan-build --keep-going --exclude vendor/ ninja -v -C _build - name: Test run: | ulimit -c unlimited - scan-build --keep-going --exclude vendor/ make -j"$(nproc)" check + scan-build --keep-going --exclude vendor/ ninja -v -C _build test - name: Core dump stacks run: | if [[ -f core ]]; then @@ -37,7 +36,7 @@ jobs: - name: Test logs if: ${{ failure() }} run: | - cat test-suite.log tests/*.log + cat _build/meson-logs/testlog.txt - name: Upload Logs uses: actions/upload-artifact@v7 with: diff --git a/.github/workflows/valgrind.yml b/.github/workflows/valgrind.yml index c698a8e59f..91ac065f45 100644 --- a/.github/workflows/valgrind.yml +++ b/.github/workflows/valgrind.yml @@ -16,19 +16,16 @@ jobs: - name: Install packages run: | sudo apt-get update - sudo apt-get install -y automake autoconf libtool valgrind + sudo apt-get install -y meson valgrind - name: Build run: | - autoreconf -i - ./configure \ - --disable-docs \ - --enable-valgrind \ - --with-oniguruma=builtin - make -j"$(nproc)" - file ./jq + meson setup _build -Ddocs=false -Dvalgrind=true -Doniguruma=builtin + ninja -v -C _build + file _build/src/jq - name: Test run: | - make check VERBOSE=yes + cd _build + meson test -v git diff --exit-code - name: Upload Test Logs if: ${{ failure() }} @@ -37,5 +34,4 @@ jobs: name: test-logs-valgrind-linux retention-days: 7 path: | - test-suite.log - tests/*.log + _build/meson-logs/testlog.txt diff --git a/.gitignore b/.gitignore index 7df2dae6d8..0af90a0fec 100644 --- a/.gitignore +++ b/.gitignore @@ -1,55 +1,8 @@ -*.o -*.a -*.lo -*.la -*.lai -*.so -*.so.* -*.gcda -*.gcno -*.gcov -*~ -.*.sw[a-p] -tags - -jq -!tests/modules/lib/jq/ -jq.1 +/_build/ +/build/ +/.build/ -# Generated source -src/builtin.inc -src/config_opts.inc -*.pc - -# Autotools junk -.libs -.deps -.dirstamp -libtool -*.log -stamp-h1 -config.log -config.status -autom4te.cache -confdefs.h -conftest* -INSTALL -Makefile -jq-*.tar.gz -jq-*.zip -configure -aclocal.m4 -Makefile.in -version.h -.remake-version-h -config.cache -*.rpm -m4/libtool.m4 -m4/ltoptions.m4 -m4/ltsugar.m4 -m4/ltversion.m4 -m4/lt~obsolete.m4 -tests/*.trs +*~ # Docs output docs/output diff --git a/.gitmodules b/.gitmodules index 193b803046..dc53894bf9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "vendor/oniguruma"] - path = vendor/oniguruma +[submodule "subprojects/oniguruma"] + path = subprojects/oniguruma url = https://github.com/kkos/oniguruma.git diff --git a/Makefile.am b/Makefile.am deleted file mode 100644 index acb94435f4..0000000000 --- a/Makefile.am +++ /dev/null @@ -1,258 +0,0 @@ - -### C source files to be built and distributed. - -LIBJQ_INCS = src/builtin.h src/bytecode.h src/compile.h \ - src/exec_stack.h src/jq_parser.h src/jv_alloc.h src/jv_dtoa.h \ - src/jv_unicode.h src/jv_utf8_tables.h src/lexer.l src/libm.h \ - src/linker.h src/locfile.h src/opcode_list.h src/parser.y \ - src/util.h src/jv_dtoa_tsd.h src/jv_thread.h src/jv_private.h \ - vendor/decNumber/decContext.h vendor/decNumber/decNumber.h \ - vendor/decNumber/decNumberLocal.h - -LIBJQ_SRC = src/builtin.c src/bytecode.c src/compile.c src/execute.c \ - src/jq_test.c src/jv.c src/jv_alloc.c src/jv_aux.c \ - src/jv_dtoa.c src/jv_file.c src/jv_parse.c src/jv_print.c \ - src/jv_unicode.c src/linker.c src/locfile.c src/util.c \ - src/jv_dtoa_tsd.c \ - vendor/decNumber/decContext.c vendor/decNumber/decNumber.c \ - ${LIBJQ_INCS} - -### C build options - -AM_CFLAGS = -Wextra -Wall -Wno-unused-parameter -Wno-unused-function \ - -Woverlength-strings -Wstrict-prototypes - -if WIN32 -AM_CFLAGS += -municode -endif - -ACLOCAL_AMFLAGS = -I config/m4 - -### Generating the lexer and parser - -# While there is some autoconf macro support for lex/flex, it doesn't support -# header file creation so we'll use good old make -if MAINTAINER_MODE -BUILT_SOURCES = src/lexer.h src/lexer.c src/parser.h src/parser.c \ - src/builtin.inc src/config_opts.inc src/version.h -src/lexer.c: src/lexer.l - $(AM_V_LEX) flex -o src/lexer.c --header-file=src/lexer.h $< -src/lexer.h: src/lexer.c -else -BUILT_SOURCES = src/builtin.inc src/config_opts.inc src/version.h -.y.c: - $(AM_V_YACC) [ "$(/dev/null`" = "x$$ver" || touch .remake-version-h -src/version.h: .remake-version-h - mkdir -p src - $(AM_V_GEN) $(generate_ver); echo "$$ver" > $@ -src/config_opts.inc: - mkdir -p src - $(AM_V_GEN) if test -x ./config.status; then \ - ./config.status --config; \ - else echo "(unknown)"; \ - fi | sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/"/' -e 's/^/#define JQ_CONFIG /' > $@ -src/main.c: src/version.h src/config_opts.inc - -src/builtin.inc: $(srcdir)/src/builtin.jq - mkdir -p src - $(AM_V_GEN) od -v -A n -t o1 -- $< | \ - sed -e 's/$$/ /' \ - -e 's/\([0123456789]\) /\1, /g' \ - -e 's/ $$//' \ - -e 's/ 0/ 0/g' \ - -e 's/ \([123456789]\)/ 0\1/g' > $@ -src/builtin.o: src/builtin.inc - -CLEANFILES = src/version.h .remake-version-h src/builtin.inc src/config_opts.inc - -bin_PROGRAMS = jq -jq_SOURCES = src/main.c -jq_LDADD = libjq.la -lm - -if ENABLE_ALL_STATIC -jq_LDFLAGS = -all-static -endif - -### Tests (make check) - -TESTS = tests/mantest tests/jqtest tests/shtest tests/utf8test tests/base64test tests/uritest -if !WIN32 -TESTS += tests/optionaltest -endif - -AM_TESTS_ENVIRONMENT = JQ=$(abs_builddir)/jq -if ENABLE_VALGRIND -AM_TESTS_ENVIRONMENT += ENABLE_VALGRIND=1 -endif - -# This is a magic make variable that causes it to treat tests/man.test as a -# DATA-type dependency for the check target. As a result, it will attempt to -# run any defined targets for tests/man.test as a dependency for check. This -# allows us to ensure that the tests are up-to-date if the manual has been updated -check_DATA = tests/man.test - -### Building the man tests - -# We use the examples in the manual as additional tests, to ensure they always work. -# As a result, we need to rebuild the tests if the manual has been updated. -# Making changes to the manpage without having the python deps means your -# tests won't run. If you aren't making changes to the examples, you probably -# don't care. But if you are, then you need to run the tests anyway. -tests/man.test tests/manonig.test: $(srcdir)/docs/content/manual/dev/manual.yml -if ENABLE_DOCS - $(AM_V_GEN) ( cd ${abs_srcdir}/docs && \ - $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \ - $(PIPENV) run python build_mantests.py ) -else - @echo Changes to the manual.yml require docs to be enabled to update the manual test. - @echo As a result, the manual test is out of date. -endif - -### Building the manpage - -# We build the docs from the manpage yml. If no changes have been made to the -# manpage, then we'll end up using the cached version. Otherwise, we need to -# rebuild it. -man_MANS = jq.1 -jq.1.prebuilt: $(srcdir)/docs/content/manual/dev/manual.yml -if ENABLE_DOCS - $(AM_V_GEN) ( cd ${abs_srcdir}/docs && \ - $(PIPENV) run python validate_manual_schema.py content/manual/dev/manual.yml && \ - $(PIPENV) run python build_manpage.py ) > $@ -else - @echo Changes to the manual.yml require docs to be enabled to update the manpage. - @echo As a result, the manpage is out of date. -endif - -jq.1: jq.1.prebuilt - $(AM_V_GEN) cp $(srcdir)/jq.1.prebuilt $@ - -CLEANFILES += jq.1 - -### Build oniguruma - -if BUILD_ONIGURUMA -libjq_la_LIBADD += vendor/oniguruma/src/.libs/libonig.la -jq_LDADD += vendor/oniguruma/src/.libs/libonig.la -SUBDIRS = vendor/oniguruma -endif - -AM_CFLAGS += $(onig_CFLAGS) - -if WITH_ONIGURUMA -TESTS += tests/onigtest tests/manonigtest -endif - -### Packaging - -install-binaries: $(BUILT_SOURCES) - $(MAKE) $(AM_MAKEFLAGS) install-exec - -DOC_FILES = docs/content docs/public docs/templates \ - docs/Pipfile docs/Pipfile.lock docs/build_manpage.py \ - docs/build_mantests.py docs/build_website.py docs/README.md \ - docs/validate_manual_schema.py docs/manual_schema.yml - -EXTRA_DIST = $(DOC_FILES) $(man_MANS) $(TESTS) $(TEST_LOG_COMPILER) \ - jq.1.prebuilt jq.spec src/lexer.c src/lexer.h src/parser.c \ - src/parser.h src/version.h src/builtin.jq scripts/version \ - libjq.pc \ - tests/modules/a.jq tests/modules/b/b.jq tests/modules/c/c.jq \ - tests/modules/c/d.jq tests/modules/data.json \ - tests/modules/home1/.jq tests/modules/home2/.jq/g.jq \ - tests/modules/lib/jq/e/e.jq tests/modules/lib/jq/f.jq \ - tests/modules/shadow1.jq tests/modules/shadow2.jq \ - tests/modules/syntaxerror/syntaxerror.jq \ - tests/modules/test_bind_order.jq \ - tests/modules/test_bind_order0.jq \ - tests/modules/test_bind_order1.jq \ - tests/modules/test_bind_order2.jq \ - tests/onig.supp tests/local.supp \ - tests/setup tests/torture/input0.json \ - tests/optional.test tests/man.test tests/manonig.test \ - tests/jq.test tests/onig.test tests/base64.test tests/uri.test \ - tests/jq-f-test.sh \ - tests/no-main-program.jq tests/yes-main-program.jq - -AM_DISTCHECK_CONFIGURE_FLAGS=--with-oniguruma=builtin - -# README.md is expected in GitHub projects, good stuff in it, so we'll -# distribute it and install it with the package in the doc directory. -dist_doc_DATA = README.md NEWS.md COPYING AUTHORS - -pkgconfigdir = $(libdir)/pkgconfig -pkgconfig_DATA = libjq.pc - -RELEASE ?= 1 -rpm: dist jq.spec - @echo "Packaging jq as an RPM ..." - mkdir -p rpm/SOURCES rpm/BUILD rpm/BUILDROOT rpm/RPMS rpm/SPECS - cp jq-$(VERSION).tar.gz rpm/SOURCES/ - rpmbuild -tb --define "_topdir ${PWD}/rpm" --define "_prefix /usr" --define "myver $(VERSION)" --define "myrel ${RELEASE}" rpm/SOURCES/jq-$(VERSION).tar.gz - find rpm/RPMS/ -name "*.rpm" -exec mv {} ./ \; - rm -rf rpm diff --git a/build/.gitignore b/build/.gitignore deleted file mode 100644 index f59ec20aab..0000000000 --- a/build/.gitignore +++ /dev/null @@ -1 +0,0 @@ -* \ No newline at end of file diff --git a/config/.gitignore b/config/.gitignore deleted file mode 100644 index 517595a7ce..0000000000 --- a/config/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -config.guess -config.sub -compile -depcomp -install-sh -ltmain.sh -missing -ylwrap -test-driver -ar-lib diff --git a/config/m4/.gitignore b/config/m4/.gitignore deleted file mode 100644 index 603556284a..0000000000 --- a/config/m4/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -libtool.m4 -lt*.m4 \ No newline at end of file diff --git a/config/m4/check-math-func.m4 b/config/m4/check-math-func.m4 deleted file mode 100644 index c080068e13..0000000000 --- a/config/m4/check-math-func.m4 +++ /dev/null @@ -1,9 +0,0 @@ -dnl AC_CHECK_MATH_FUNC(func) -AC_DEFUN([AC_CHECK_MATH_FUNC], [ - AC_LANG(C) - AC_CHECK_LIB([m],[$1],[ - m4_define([ac_tr_func], [HAVE_]m4_toupper($1)) - AC_DEFINE(ac_tr_func, 1, [Define if you have the $1 math function.]) - ],[ - ]) -]) diff --git a/config/m4/find-func-no-libs.m4 b/config/m4/find-func-no-libs.m4 deleted file mode 100644 index f47cd6e688..0000000000 --- a/config/m4/find-func-no-libs.m4 +++ /dev/null @@ -1,8 +0,0 @@ -dnl Shamelessly stolen from Heimdal -dnl -dnl Look for function in any of the specified libraries -dnl - -dnl AC_FIND_FUNC_NO_LIBS(func, libraries, includes, arguments, extra libs, extra args) -AC_DEFUN([AC_FIND_FUNC_NO_LIBS], [ -AC_FIND_FUNC_NO_LIBS2([$1], ["" $2], [$3], [$4], [$5], [$6])]) diff --git a/config/m4/find-func-no-libs2.m4 b/config/m4/find-func-no-libs2.m4 deleted file mode 100644 index ee9410a59c..0000000000 --- a/config/m4/find-func-no-libs2.m4 +++ /dev/null @@ -1,62 +0,0 @@ -dnl Shamelessly stolen from Heimdal -dnl -dnl Look for function in any of the specified libraries -dnl - -dnl AC_FIND_FUNC_NO_LIBS2(func, libraries, includes, arguments, extra libs, extra args) -AC_DEFUN([AC_FIND_FUNC_NO_LIBS2], [ - -AC_MSG_CHECKING([for $1]) -AC_CACHE_VAL(ac_cv_funclib_$1, -[ -if eval "test \"\$ac_cv_func_$1\" != yes" ; then - ac_save_LIBS="$LIBS" - for ac_lib in $2; do - case "$ac_lib" in - "") ;; - yes) ac_lib="" ;; - no) continue ;; - -l*) ;; - *) ac_lib="-l$ac_lib" ;; - esac - LIBS="$6 $ac_lib $5 $ac_save_LIBS" - AC_LINK_IFELSE([AC_LANG_PROGRAM([[$3]],[[$1($4)]])],[eval "if test -n \"$ac_lib\";then ac_cv_funclib_$1=$ac_lib; else ac_cv_funclib_$1=yes; fi";break]) - done - eval "ac_cv_funclib_$1=\${ac_cv_funclib_$1-no}" - LIBS="$ac_save_LIBS" -fi -]) - -eval "ac_res=\$ac_cv_funclib_$1" - -if false; then - AC_CHECK_FUNCS($1) -dnl AC_CHECK_LIBS($2, foo) -fi -# $1 -eval "ac_tr_func=HAVE_[]upcase($1)" -eval "ac_tr_lib=HAVE_LIB[]upcase($ac_res | sed -e 's/-l//')" -eval "LIB_$1=$ac_res" - -case "$ac_res" in - yes) - eval "ac_cv_func_$1=yes" - eval "LIB_$1=" - AC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if the $1 function is available.]) - AC_MSG_RESULT([yes]) - ;; - no) - eval "ac_cv_func_$1=no" - eval "LIB_$1=" - AC_MSG_RESULT([no]) - ;; - *) - eval "ac_cv_func_$1=yes" - eval "ac_cv_lib_`echo "$ac_res" | sed 's/-l//'`=yes" - AC_DEFINE_UNQUOTED($ac_tr_func, 1, [Define if you have the $1 function.]) - AC_DEFINE_UNQUOTED($ac_tr_lib, 1, [Define if you have the $2 library.]) - AC_MSG_RESULT([yes, in $ac_res]) - ;; -esac -AC_SUBST(LIB_$1) -]) diff --git a/config/m4/find-func.m4 b/config/m4/find-func.m4 deleted file mode 100644 index a4b0290ff2..0000000000 --- a/config/m4/find-func.m4 +++ /dev/null @@ -1,9 +0,0 @@ -dnl Shamelessly stolen from Heimdal -dnl -dnl AC_FIND_FUNC(func, libraries, includes, arguments) -AC_DEFUN([AC_FIND_FUNC], [ -AC_FIND_FUNC_NO_LIBS([$1], [$2], [$3], [$4]) -if test -n "$LIB_$1"; then - LIBS="$LIB_$1 $LIBS" -fi -]) diff --git a/config/m4/misc.m4 b/config/m4/misc.m4 deleted file mode 100644 index 3dd16bd99b..0000000000 --- a/config/m4/misc.m4 +++ /dev/null @@ -1,3 +0,0 @@ - -dnl Shamelessly stolen from Heimdal -AC_DEFUN([upcase],[`echo $1 | tr abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ`])dnl diff --git a/configure.ac b/configure.ac deleted file mode 100644 index f7067a4341..0000000000 --- a/configure.ac +++ /dev/null @@ -1,305 +0,0 @@ -m4_define([jq_version], m4_esyscmd_s([scripts/version]))) - -AC_INIT([jq],[jq_version],[https://github.com/jqlang/jq/issues],[jq],[https://jqlang.org]) - -dnl Created autoconf implementation thompson@dtosolutions, 26NOV12 -AC_PREREQ([2.65]) -AC_CONFIG_AUX_DIR([config]) -AC_USE_SYSTEM_EXTENSIONS - -dnl Prefer GNU make on Solaris where /usr/bin/make is not suitable -AS_IF([test -z "$MAKE"], [ - AS_CASE(["`uname -s`"], [SunOS], [MAKE=/usr/gnu/bin/make]) -]) - -AM_INIT_AUTOMAKE([1.11.2 subdir-objects parallel-tests foreign -Wall]) -AM_SILENT_RULES([yes]) -AM_PROG_AR -AM_MAINTAINER_MODE([disable]) -AC_PROG_CC -m4_version_prereq([2.70], [], [AC_PROG_CC_STDC]) -AC_PROG_CPP_WERROR -AC_PROG_YACC -AC_OBJEXT -AC_EXEEXT -LT_INIT([shared static win32-dll]) -AM_PROG_CC_C_O - -AC_SYS_LARGEFILE # issue 2167 - -dnl couldn't use AM_PROG_LEX as it doesn't support header files like the -dnl AC_PROG_YACC macros... - -dnl check bison version - -if test "$USE_MAINTAINER_MODE" = yes; then - if test "$YACC" != "bison -y"; then - AC_MSG_CHECKING([bison version]) - AC_MSG_RESULT([not bison]) - else - AX_PROG_BISON_VERSION([3], - [], - [AC_MSG_ERROR([You need bison version 3.0 or greater])]) - fi - - AC_CHECK_PROGS(LEX, flex lex) -fi - -AC_CHECK_FUNCS(memmem) - -AC_CHECK_HEADER("sys/cygwin.h", [have_cygwin=1;]) -AC_CHECK_HEADER("shlwapi.h",[have_shlwapi=1;]) -AM_CONDITIONAL([WIN32], [test "x$have_shlwapi" = x1 && test ! "x$have_cygwin" = x1]) - -dnl Running tests with Valgrind is slow. It is faster to iterate on -dnl code without Valgrind until tests pass, then enable Valgrind and -dnl fix leaks. -AC_ARG_ENABLE([valgrind], - AS_HELP_STRING([--enable-valgrind],[enable Valgrind during testing])) - -dnl Address sanitizer (ASan) -AC_ARG_ENABLE([asan], - AS_HELP_STRING([--enable-asan],[enable address sanitizer])) - -dnl Undefined Behavior Sanitizer -AC_ARG_ENABLE([ubsan], - AS_HELP_STRING([--enable-ubsan],[enable undefined behavior sanitizer])) - -dnl Code coverage -AC_ARG_ENABLE([gcov], - AS_HELP_STRING([--enable-gcov],[enable gcov code coverage tool])) - -dnl Don't attempt to build docs if python deps aren't installed -AC_ARG_ENABLE([docs], - AS_HELP_STRING([--disable-docs],[do not build docs]), [], [enable_docs=yes]) - -dnl Don't attempt to build the error injection object (if there is no LD_PRELOAD support) -AC_ARG_ENABLE([error-injection], - AS_HELP_STRING([--enable-error-injection],[build and test with error injection])) - -dnl Enable building all static -AC_ARG_ENABLE([all-static], - AS_HELP_STRING([--enable-all-static],[link jq with static libraries only])) - -dnl find pipenv -AC_ARG_VAR([PIPENV], [pipenv command]) -AC_CHECK_PROGS([PIPENV], pipenv) - -AS_IF([test "x$enable_docs" != "xno"],[ - AC_CACHE_CHECK([for Python dependencies], [jq_cv_python_deps],[ - jq_cv_python_deps=yes - AS_IF([test "x$PIPENV" = "x" || \ - ! bmsg="`cd ${srcdir}/docs; LC_ALL=$LANG "$PIPENV" --venv`"],[ - jq_cv_python_deps=no - ]) - ]) - - AS_IF([test "x$jq_cv_python_deps" != "xyes"], [ - AC_MSG_WARN([Error checking python dependencies: $bmsg -***************************************************************** -* Python dependencies for building jq documentation not found. * -* You can still build, install and hack on jq, but the manpage * -* will not be rebuilt and new manpage tests will not be run. * -* See docs/README.md for how to install the docs dependencies. * -*****************************************************************]) - enable_docs=no - ]) -]) - -dnl Disable decNumber support -AC_ARG_ENABLE([decnum], - AS_HELP_STRING([--disable-decnum],[disable decnum support])) - -AS_IF([test "x$enable_decnum" != "xno"],[ - AC_DEFINE([USE_DECNUM], 1, [Define to enable decnum support.]) -]) - -AM_CONDITIONAL([ENABLE_VALGRIND], [test "x$enable_valgrind" = xyes]) -AM_CONDITIONAL([ENABLE_ASAN], [test "x$enable_asan" = xyes]) -AM_CONDITIONAL([ENABLE_UBSAN], [test "x$enable_ubsan" = xyes]) -AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes]) -AM_CONDITIONAL([ENABLE_DOCS], [test "x$enable_docs" != xno]) -AM_CONDITIONAL([ENABLE_ERROR_INJECTION], [test "x$enable_error_injection" = xyes]) -AM_CONDITIONAL([ENABLE_ALL_STATIC], [test "x$enable_all_static" = xyes]) - -dnl Find pthread, if we have it. We do this first because we may set -pthread on CFLAGS -dnl which can cause various macros to be defined (__REENTRANT on Darwin, for example) -AX_PTHREAD([ - AC_DEFINE([HAVE_PTHREAD], [1], [Define to enable POSIX threads support.]) - LIBS="$PTHREAD_LIBS $LIBS" - CFLAGS="$CFLAGS $PTHREAD_CFLAGS" - CC="$PTHREAD_CC" -]) - -AC_FUNC_ALLOCA - -AC_FIND_FUNC([isatty], [c], [#include ], [0]) -AC_FIND_FUNC([_isatty], [c], [#include ], [0]) -AC_FIND_FUNC([strptime], [c], [#include ], [0, 0, 0]) -AC_FIND_FUNC([strftime], [c], [#include ], [0, 0, 0, 0]) -AC_FIND_FUNC([setenv], [c], [#include ], [0, 0, 0]) -AC_FIND_FUNC([timegm], [c], [#include ], [0]) -AC_FIND_FUNC([gmtime_r], [c], [#include ], [0, 0]) -AC_FIND_FUNC([gmtime], [c], [#include ], [0]) -AC_FIND_FUNC([localtime_r], [c], [#include ], [0, 0]) -AC_FIND_FUNC([localtime], [c], [#include ], [0]) -AC_FIND_FUNC([gettimeofday], [c], [#include ], [0, 0]) -AC_CHECK_MEMBER([struct tm.tm_gmtoff], [AC_DEFINE([HAVE_TM_TM_GMT_OFF],1,[Define to 1 if the system has the tm_gmt_off field in struct tm])], - [], [[#include ]]) -AC_CHECK_MEMBER([struct tm.__tm_gmtoff], [AC_DEFINE([HAVE_TM___TM_GMT_OFF],1,[Define to 1 if the system has the __tm_gmt_off field in struct tm])], - [], [[#include ]]) -AC_FIND_FUNC([setlocale], [c], [#include ], [0,0]) -AC_FIND_FUNC([arc4random], [c], [#include ], []) -AC_FIND_FUNC([getentropy], [c], [#include ], [0, 0]) - -dnl Figure out if we have the pthread functions we actually need -AC_FIND_FUNC_NO_LIBS([pthread_key_create], [], [#include ], [NULL, NULL]) -AC_FIND_FUNC_NO_LIBS([pthread_once], [], [#include ], [NULL, NULL]) -AC_FIND_FUNC_NO_LIBS([atexit], [], [#include ], [NULL]) - -dnl libm math.h functions -AC_CHECK_MATH_FUNC(acos) -AC_CHECK_MATH_FUNC(acosh) -AC_CHECK_MATH_FUNC(asin) -AC_CHECK_MATH_FUNC(asinh) -AC_CHECK_MATH_FUNC(atan2) -AC_CHECK_MATH_FUNC(atan) -AC_CHECK_MATH_FUNC(atanh) -AC_CHECK_MATH_FUNC(cbrt) -AC_CHECK_MATH_FUNC(ceil) -AC_CHECK_MATH_FUNC(copysign) -AC_CHECK_MATH_FUNC(cos) -AC_CHECK_MATH_FUNC(cosh) -AC_CHECK_MATH_FUNC(drem) -AC_CHECK_MATH_FUNC(erf) -AC_CHECK_MATH_FUNC(erfc) -AC_CHECK_MATH_FUNC(exp10) -AC_CHECK_MATH_FUNC(__exp10) dnl macOS has an __exp10 -AC_CHECK_MATH_FUNC(exp2) -AC_CHECK_MATH_FUNC(exp) -AC_CHECK_MATH_FUNC(expm1) -AC_CHECK_MATH_FUNC(fabs) -AC_CHECK_MATH_FUNC(fdim) -AC_CHECK_MATH_FUNC(floor) -AC_CHECK_MATH_FUNC(fma) -AC_CHECK_MATH_FUNC(fmax) -AC_CHECK_MATH_FUNC(fmin) -AC_CHECK_MATH_FUNC(fmod) -AC_CHECK_MATH_FUNC(frexp) -AC_CHECK_MATH_FUNC(gamma) -AC_CHECK_MATH_FUNC(hypot) -AC_CHECK_MATH_FUNC(j0) -AC_CHECK_MATH_FUNC(j1) -AC_CHECK_MATH_FUNC(jn) -AC_CHECK_MATH_FUNC(ldexp) -AC_CHECK_MATH_FUNC(lgamma) -AC_CHECK_MATH_FUNC(log10) -AC_CHECK_MATH_FUNC(log1p) -AC_CHECK_MATH_FUNC(log2) -AC_CHECK_MATH_FUNC(log) -AC_CHECK_MATH_FUNC(logb) -AC_CHECK_MATH_FUNC(modf) -AC_CHECK_MATH_FUNC(lgamma_r) -AC_CHECK_MATH_FUNC(nearbyint) -AC_CHECK_MATH_FUNC(nextafter) -AC_CHECK_MATH_FUNC(nexttoward) -AC_CHECK_MATH_FUNC(pow) -AC_CHECK_MATH_FUNC(remainder) -AC_CHECK_MATH_FUNC(rint) -AC_CHECK_MATH_FUNC(round) -AC_CHECK_MATH_FUNC(scalb) -AC_CHECK_MATH_FUNC(scalbln) -AC_CHECK_MATH_FUNC(significand) -dnl scalbn and ilogb are used on macos to replace significand if we don't have frexp -AC_CHECK_MATH_FUNC(scalbn) -AC_CHECK_MATH_FUNC(ilogb) - -AC_CHECK_MATH_FUNC(sin) -AC_CHECK_MATH_FUNC(sinh) -AC_CHECK_MATH_FUNC(sqrt) -AC_CHECK_MATH_FUNC(tan) -AC_CHECK_MATH_FUNC(tanh) -AC_CHECK_MATH_FUNC(tgamma) -AC_CHECK_MATH_FUNC(trunc) -AC_CHECK_MATH_FUNC(y0) -AC_CHECK_MATH_FUNC(y1) -AC_CHECK_MATH_FUNC(yn) - -dnl Thread local storage -have___thread=no -AC_MSG_CHECKING(for thread-local storage) -AC_LINK_IFELSE([AC_LANG_SOURCE([ -static __thread int x ; -int main () { x = 123; return x; } -])], have___thread=yes) -if test $have___thread = yes; then - AC_DEFINE([HAVE___THREAD],1,[Define to 1 if the system supports __thread]) -fi -AC_MSG_RESULT($have___thread) - -AC_C_BIGENDIAN( - AC_DEFINE([IEEE_MC68k], 1, [machine is bigendian]), - AC_DEFINE([IEEE_8087], 1, [machine is littleendian]), - AC_MSG_ERROR(unknown endianness), - AC_MSG_ERROR(universal endianness not supported) -) - -dnl Oniguruma -AC_ARG_WITH([oniguruma], - [AS_HELP_STRING([--with-oniguruma=prefix], - [try this for a non-standard install prefix of the oniguruma library])], , - [with_oniguruma=yes]) - -onig_CFLAGS= -onig_LDFLAGS= -build_oniguruma=no -AS_IF([test "x$with_oniguruma" != xno], [ - save_CFLAGS="$CFLAGS" - save_LDFLAGS="$LDFLAGS" - AS_IF([test "x$with_oniguruma" != xyes], [ - AS_IF([test "x$with_oniguruma" = xbuiltin], [ - build_oniguruma=yes - ], [ - onig_CFLAGS="-I${with_oniguruma}/include" - onig_LDFLAGS="-L${with_oniguruma}/lib" - ]) - ]) - AS_IF([test "x$build_oniguruma" = xno], [ - # check for ONIGURUMA library, either in /usr or where requested - CFLAGS="$CFLAGS $onig_CFLAGS" - LDFLAGS="$LDFLAGS $onig_LDFLAGS" - AC_CHECK_HEADER("oniguruma.h", - AC_CHECK_LIB([onig],[onig_version])) - # handle check results - AS_IF([test "x$ac_cv_lib_onig_onig_version" != "xyes"], [ - build_oniguruma=yes - AC_MSG_NOTICE([Oniguruma was not found. Will use the packaged oniguruma.]) - ]) - ]) - AS_IF([test "x$build_oniguruma" = xyes && test -f "${srcdir}/vendor/oniguruma/configure.ac" ], [ - onig_CFLAGS="-I${srcdir}/vendor/oniguruma/src" - onig_LDFLAGS="-L${srcdir}/vendor/oniguruma/src -Wl,-rpath,${libdir}" - AC_CONFIG_SUBDIRS([vendor/oniguruma]) - AC_DEFINE([HAVE_LIBONIG],1,[Define to 1 if the system includes libonig]) - ]) - CFLAGS="$save_CFLAGS" - LDFLAGS="$save_LDFLAGS" -]) -AC_SUBST(onig_CFLAGS) -AC_SUBST(onig_LDFLAGS) - -AM_CONDITIONAL([BUILD_ONIGURUMA], [test "x$build_oniguruma" = xyes]) -AM_CONDITIONAL([WITH_ONIGURUMA], [test "x$with_oniguruma" != xno]) - -dnl On Solaris, strptime clears the tm structure before parsing. This breaks the -dnl sentinel logic in builtin.c, which then incorrectly assumes that strptime set -dnl tm_wday and tm_yday. Defining _STRPTIME_DONTZERO disables that behavior. -AS_IF([test "x`uname -s 2>/dev/null`" = "xSunOS"], [ - CPPFLAGS="$CPPFLAGS -D_STRPTIME_DONTZERO" -]) - - -AC_CONFIG_MACRO_DIRS([config/m4 m4]) -AC_CONFIG_FILES([Makefile libjq.pc]) -AC_OUTPUT - diff --git a/docs/meson.build b/docs/meson.build new file mode 100644 index 0000000000..7a52ebb726 --- /dev/null +++ b/docs/meson.build @@ -0,0 +1,57 @@ +pipenv = find_program('pipenv', required: false) +if not pipenv.found() + warning(f''' + Error checking python dependencies: + ***************************************************************** + * Python dependencies for building jq documentation not found. * + * You can still build, install and hack on jq, but the manpage * + * will not be rebuilt and new manpage tests will not be run. * + * See docs/README.md for how to install the docs dependencies. * + ***************************************************************** + ''') + subdir_done() +endif + +docs_pipenv = custom_target('docs_pipenv', + command: [ + 'sh', '-c', + '(cd @0@ && pipenv sync) && touch docs/pipenv.flag'.format(meson.current_source_dir()) + ], + depend_files: [ + 'Pipfile', + 'Pipfile.lock' + ], + output: 'pipenv.flag', +) + +run_target('build_mantests', + command: [ + 'sh', '-c', + 'cd @0@;'.format(meson.current_source_dir()) + + 'pipenv run ./validate_manual_schema.py content/manual/dev/manual.yml;' + + 'pipenv run ./build_mantests.py', + ], + depends: [docs_pipenv] +) + + +custom_target('manpage', + command: [ + 'sh', '-c', + 'cd @0@;'.format(meson.current_source_dir()) + + 'pipenv run ./validate_manual_schema.py content/manual/dev/manual.yml;' + + 'pipenv run ./build_manpage.py', + ], + capture: true, + output: 'jq.1', + install: true, + install_dir: get_option('mandir'), + depends: [docs_pipenv] +) + +install_data( + '../README.md', + '../AUTHORS', + '../NEWS.md', + install_dir: get_option('datadir') / 'doc' / 'jq', +) diff --git a/libjq.pc.in b/libjq.pc.in deleted file mode 100644 index e8dc7c86bd..0000000000 --- a/libjq.pc.in +++ /dev/null @@ -1,11 +0,0 @@ -prefix=@prefix@ -exec_prefix=@exec_prefix@ -libdir=@libdir@ -includedir=@includedir@ - -Name: libjq -URL: https://jqlang.org/ -Description: Library to process JSON using a query language -Version: @VERSION@ -Libs: -L${libdir} -ljq -Cflags: -I${includedir} diff --git a/m4/ax_compare_version.m4 b/m4/ax_compare_version.m4 deleted file mode 100644 index 74dc0fdd9a..0000000000 --- a/m4/ax_compare_version.m4 +++ /dev/null @@ -1,177 +0,0 @@ -# =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_compare_version.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_COMPARE_VERSION(VERSION_A, OP, VERSION_B, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) -# -# DESCRIPTION -# -# This macro compares two version strings. Due to the various number of -# minor-version numbers that can exist, and the fact that string -# comparisons are not compatible with numeric comparisons, this is not -# necessarily trivial to do in a autoconf script. This macro makes doing -# these comparisons easy. -# -# The six basic comparisons are available, as well as checking equality -# limited to a certain number of minor-version levels. -# -# The operator OP determines what type of comparison to do, and can be one -# of: -# -# eq - equal (test A == B) -# ne - not equal (test A != B) -# le - less than or equal (test A <= B) -# ge - greater than or equal (test A >= B) -# lt - less than (test A < B) -# gt - greater than (test A > B) -# -# Additionally, the eq and ne operator can have a number after it to limit -# the test to that number of minor versions. -# -# eq0 - equal up to the length of the shorter version -# ne0 - not equal up to the length of the shorter version -# eqN - equal up to N sub-version levels -# neN - not equal up to N sub-version levels -# -# When the condition is true, shell commands ACTION-IF-TRUE are run, -# otherwise shell commands ACTION-IF-FALSE are run. The environment -# variable 'ax_compare_version' is always set to either 'true' or 'false' -# as well. -# -# Examples: -# -# AX_COMPARE_VERSION([3.15.7],[lt],[3.15.8]) -# AX_COMPARE_VERSION([3.15],[lt],[3.15.8]) -# -# would both be true. -# -# AX_COMPARE_VERSION([3.15.7],[eq],[3.15.8]) -# AX_COMPARE_VERSION([3.15],[gt],[3.15.8]) -# -# would both be false. -# -# AX_COMPARE_VERSION([3.15.7],[eq2],[3.15.8]) -# -# would be true because it is only comparing two minor versions. -# -# AX_COMPARE_VERSION([3.15.7],[eq0],[3.15]) -# -# would be true because it is only comparing the lesser number of minor -# versions of the two values. -# -# Note: The characters that separate the version numbers do not matter. An -# empty string is the same as version 0. OP is evaluated by autoconf, not -# configure, so must be a string, not a variable. -# -# The author would like to acknowledge Guido Draheim whose advice about -# the m4_case and m4_ifvaln functions make this macro only include the -# portions necessary to perform the specific comparison specified by the -# OP argument in the final configure script. -# -# LICENSE -# -# Copyright (c) 2008 Tim Toolan -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 11 - -dnl ######################################################################### -AC_DEFUN([AX_COMPARE_VERSION], [ - AC_REQUIRE([AC_PROG_AWK]) - - # Used to indicate true or false condition - ax_compare_version=false - - # Convert the two version strings to be compared into a format that - # allows a simple string comparison. The end result is that a version - # string of the form 1.12.5-r617 will be converted to the form - # 0001001200050617. In other words, each number is zero padded to four - # digits, and non digits are removed. - AS_VAR_PUSHDEF([A],[ax_compare_version_A]) - A=`echo "$1" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g'` - - AS_VAR_PUSHDEF([B],[ax_compare_version_B]) - B=`echo "$3" | sed -e 's/\([[0-9]]*\)/Z\1Z/g' \ - -e 's/Z\([[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/Z\([[0-9]][[0-9]][[0-9]]\)Z/Z0\1Z/g' \ - -e 's/[[^0-9]]//g'` - - dnl # In the case of le, ge, lt, and gt, the strings are sorted as necessary - dnl # then the first line is used to determine if the condition is true. - dnl # The sed right after the echo is to remove any indented white space. - m4_case(m4_tolower($2), - [lt],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/false/;s/x${B}/true/;1q"` - ], - [gt],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort | sed "s/x${A}/false/;s/x${B}/true/;1q"` - ], - [le],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort | sed "s/x${A}/true/;s/x${B}/false/;1q"` - ], - [ge],[ - ax_compare_version=`echo "x$A -x$B" | sed 's/^ *//' | sort -r | sed "s/x${A}/true/;s/x${B}/false/;1q"` - ],[ - dnl Split the operator from the subversion count if present. - m4_bmatch(m4_substr($2,2), - [0],[ - # A count of zero means use the length of the shorter version. - # Determine the number of characters in A and B. - ax_compare_version_len_A=`echo "$A" | $AWK '{print(length)}'` - ax_compare_version_len_B=`echo "$B" | $AWK '{print(length)}'` - - # Set A to no more than B's length and B to no more than A's length. - A=`echo "$A" | sed "s/\(.\{$ax_compare_version_len_B\}\).*/\1/"` - B=`echo "$B" | sed "s/\(.\{$ax_compare_version_len_A\}\).*/\1/"` - ], - [[0-9]+],[ - # A count greater than zero means use only that many subversions - A=`echo "$A" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` - B=`echo "$B" | sed "s/\(\([[0-9]]\{4\}\)\{m4_substr($2,2)\}\).*/\1/"` - ], - [.+],[ - AC_WARNING( - [illegal OP numeric parameter: $2]) - ],[]) - - # Pad zeros at end of numbers to make same length. - ax_compare_version_tmp_A="$A`echo $B | sed 's/./0/g'`" - B="$B`echo $A | sed 's/./0/g'`" - A="$ax_compare_version_tmp_A" - - # Check for equality or inequality as necessary. - m4_case(m4_tolower(m4_substr($2,0,2)), - [eq],[ - test "x$A" = "x$B" && ax_compare_version=true - ], - [ne],[ - test "x$A" != "x$B" && ax_compare_version=true - ],[ - AC_WARNING([illegal OP parameter: $2]) - ]) - ]) - - AS_VAR_POPDEF([A])dnl - AS_VAR_POPDEF([B])dnl - - dnl # Execute ACTION-IF-TRUE / ACTION-IF-FALSE. - if test "$ax_compare_version" = "true" ; then - m4_ifvaln([$4],[$4],[:])dnl - m4_ifvaln([$5],[else $5])dnl - fi -]) dnl AX_COMPARE_VERSION diff --git a/m4/ax_prog_bison_version.m4 b/m4/ax_prog_bison_version.m4 deleted file mode 100644 index e3b5292071..0000000000 --- a/m4/ax_prog_bison_version.m4 +++ /dev/null @@ -1,68 +0,0 @@ -# =========================================================================== -# Modified from -# http://www.gnu.org/software/autoconf-archive/ax_prog_perl_version.html -# =========================================================================== -# -# SYNOPSIS -# -# AX_PROG_BISON_VERSION([VERSION],[ACTION-IF-TRUE],[ACTION-IF-FALSE]) -# -# DESCRIPTION -# -# Makes sure that bison supports the version indicated. If true the shell -# commands in ACTION-IF-TRUE are executed. If not the shell commands in -# ACTION-IF-FALSE are run. Note if $PERL is not set the macro will fail. -# -# Example: -# -# AC_PROG_YACC -# AX_PROG_BISON_VERSION([3.0.0],[ ... ],[ ... ]) -# -# This will check to make sure that the bison you have supports at least -# version 3.0.0. -# -# NOTE: This macro uses the $YACC variable to perform the check. -# AX_WITH_YACC can be used to set that variable prior to running this -# macro. The $BISON_VERSION variable will be set with the detected -# version. -# -# LICENSE -# -# Copyright (c) 2009 Francesco Salvestrini -# -# Copying and distribution of this file, with or without modification, are -# permitted in any medium without royalty provided the copyright notice -# and this notice are preserved. This file is offered as-is, without any -# warranty. - -#serial 12 - -AC_DEFUN([AX_PROG_BISON_VERSION],[ - AC_REQUIRE([AC_PROG_SED]) - AC_REQUIRE([AC_PROG_GREP]) - - AS_IF([test -n "$YACC"],[ - ax_bison_version="$1" - - AC_MSG_CHECKING([for bison version]) - changequote(<<,>>) - bison_version=`$YACC --version 2>&1 \ - | $GREP bison \ - | $SED -e 's/^[^0-9]*//' -e 's/[^0-9]*$//'` - changequote([,]) - AC_MSG_RESULT($bison_version) - - AC_SUBST([BISON_VERSION],[$bison_version]) - - AX_COMPARE_VERSION([$ax_bison_version],[le],[$bison_version],[ - : - $2 - ],[ - : - $3 - ]) - ],[ - AC_MSG_WARN([could not find bison]) - $3 - ]) -]) diff --git a/m4/ax_pthread.m4 b/m4/ax_pthread.m4 deleted file mode 100644 index 9f35d13914..0000000000 --- a/m4/ax_pthread.m4 +++ /dev/null @@ -1,522 +0,0 @@ -# =========================================================================== -# https://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 and PTHREAD_CXX to any special C compiler that is -# needed for multi-threaded programs (defaults to the value of CC -# respectively CXX otherwise). (This is necessary on e.g. AIX to use the -# special cc_r/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 -# $PTHREAD_CXX $CXXFLAGS $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" -# CXXFLAGS="$CXXFLAGS $PTHREAD_CFLAGS" -# CC="$PTHREAD_CC" -# CXX="$PTHREAD_CXX" -# -# 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 -# Copyright (c) 2011 Daniel Richard G. -# Copyright (c) 2019 Marc Stevens -# -# 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 . -# -# 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 31 - -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"]) - AS_IF([test "x$PTHREAD_CXX" != "x"], [CXX="$PTHREAD_CXX"]) - 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 with a "," contain both -# C compiler flags (before ",") and linker flags (after ","). Other items -# starting with a "-" are C compiler flags, and remaining 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,-lpthread pthread $ax_pthread_flags" - ;; -esac - -# 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" - - -# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC) - -# Note that for GCC and Clang -pthread generally implies -lpthread, -# except when -nostdlib is passed. -# This is problematic using libtool to build C++ shared libraries with pthread: -# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460 -# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333 -# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555 -# To solve this, first try -pthread together with -lpthread for GCC - -AS_IF([test "x$GCC" = "xyes"], - [ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"]) - -# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first - -AS_IF([test "x$ax_pthread_clang" = "xyes"], - [ax_pthread_flags="-pthread,-lpthread -pthread"]) - - -# 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)"]) - - -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]) - ;; - - *,*) - PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"` - PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"` - AC_MSG_CHECKING([whether pthreads work with "$PTHREAD_CFLAGS" and "$PTHREAD_LIBS"]) - ;; - - -*) - 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 -# if $ax_pthread_check_cond -# error "$ax_pthread_check_macro must be defined" -# endif - static void *some_global = NULL; - static void routine(void *a) - { - /* To avoid any unused-parameter or - unused-but-set-parameter warning. */ - some_global = a; - } - 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 - - -# 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.) - - # 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 - - - -# 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 ], - [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 ]], - [[int i = PTHREAD_PRIO_INHERIT; - return i;]])], - [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"]) - AS_IF([test "x${CXX}" != "x"], [AS_IF([AS_EXECUTABLE_P([${CXX}_r])],[PTHREAD_CXX="${CXX}_r"])]) - ], - [ - AC_CHECK_PROGS([PTHREAD_CC],[${CC}_r],[$CC]) - AS_IF([test "x${CXX}" != "x"], [AC_CHECK_PROGS([PTHREAD_CXX],[${CXX}_r],[$CXX])]) - ] - ) - ]) - ;; - esac - fi -fi - -test -n "$PTHREAD_CC" || PTHREAD_CC="$CC" -test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX" - -AC_SUBST([PTHREAD_LIBS]) -AC_SUBST([PTHREAD_CFLAGS]) -AC_SUBST([PTHREAD_CC]) -AC_SUBST([PTHREAD_CXX]) - -# 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/meson.build b/meson.build new file mode 100644 index 0000000000..f488e41f57 --- /dev/null +++ b/meson.build @@ -0,0 +1,144 @@ +project( + 'jq', + 'c', + version: run_command(['scripts/version'], check: true).stdout().strip(), + default_options: ['warning_level=3'] +) + +meson.add_dist_script(['scripts/version', 'set-dist', meson.project_version()]) + +project_url = 'https://jqlang.org' + +pkgconfig = import('pkgconfig') + +config = configuration_data() +cc = meson.get_compiler('c') + +############################################################################## +# Check dependencies + +flex = find_program(['flex', 'lex'], required: get_option('bison')) +yacc = find_program('bison', version: '>=3.0', required: get_option('bison')) + +if target_machine.endian() == 'big' + config.set10('IEEE_MC68k', true) +elif target_machine.endian() == 'little' + config.set10('IEEE_8087', true) +else + error('unsupported endianness', target_machine.endian()) +endif + +have_cygwin = cc.has_header('sys/cygwin.h') +have_shlwapi = cc.has_header('shlwapi.h') +# fixme: target_machine.system() == 'windows' ? +is_win32 = have_shlwapi and not have_cygwin +shlwapi = is_win32 ? cc.find_library('shlwapi') : dependency('', required: false) + +config.set_quoted('VERSION', meson.project_version()) + +source_arguments = [ + '-D_ALL_SOURCE=1', + '-D_DARWIN_C_SOURCE=1', + '-D_GNU_SOURCE=1', + '-D_HPUX_ALT_XOPEN_SOCKET_API=1', + '-D_NETBSD_SOURCE=1', + '-D_OPENBSD_SOURCE=1', + '-D_POSIX_PTHREAD_SEMANTICS=1', + '-D_TANDEM_SOURCE=1', + '-D__EXTENSIONS__=1', +] +add_project_arguments(source_arguments, language: 'c') + +config.set10('USE_DECNUM', get_option('decnum')) + +math = cc.find_library('m', required : false) + +threads = dependency('threads') +config.set10('HAVE_PTHREAD', threads.found()) + +have_thread_local = cc.links(''' + static __thread int x ; + int main () { x = 123; return x; } + ''', + name: 'thread local test' +) +config.set10('HAVE___THREAD', have_thread_local) + +check_funcs = { + 'memmem': '', + 'isatty': '#include ', + '_isatty': '#include ', + 'strptime': '#include ', + 'strftime': '#include ', + 'setenv': '#include ', + 'timegm': '#include ', + 'gmtime_r': '#include ', + 'gmtime': '#include ', + 'localtime_r': '#include ', + 'localtime': '#include ', + 'gettimeofday': '#include ', + 'setlocale': '#include ', + 'arc4random': '#include ', + 'getentropy': '#include ', + 'pthread_key_create': '#include ', + 'pthread_once': '#include ', + 'atexit': '#include ', +} + +check_funcs_math = [ + 'acos', 'acosh', 'asin', 'asinh', 'atan2', 'atan', 'atanh', 'cbrt', 'ceil', + 'copysign', 'cos', 'cosh', 'drem', 'erf', 'erfc', 'exp10', 'exp2', 'exp', + 'expm1', 'fabs', 'fdim', 'floor', 'fma', 'fmax', 'fmin', 'fmod', 'frexp', + 'gamma', 'hypot', 'j0', 'j1', 'jn', 'ldexp', 'lgamma', 'log10', 'log1p', + 'log2', 'log', 'logb', 'modf', 'lgamma_r', 'nearbyint', 'nextafter', + 'nexttoward', 'pow', 'remainder', 'rint', 'round', 'scalb', 'scalbln', + 'significand', 'sin', 'sinh', 'sqrt', 'tan', 'tanh', 'tgamma', 'trunc', + 'y0', 'y1', 'yn', + # scalbn and ilogb are used on macos to replace significand if we don't have frexp + 'scalbn', 'ilogb', + # macOS has an __exp10 + '__exp10', +] +foreach func : check_funcs_math + check_funcs = check_funcs + {func: '#include '} +endforeach + +foreach func, include : check_funcs + macro = f'HAVE_@0@'.format(func.underscorify().to_upper()) + config.set10(macro, cc.has_function(func, args: source_arguments, prefix: include, dependencies: math)) +endforeach + +config.set10('HAVE_TM_TM_GMT_OFF', cc.has_member('struct tm', 'tm_gmtoff', prefix: '#include ')) +config.set10('HAVE_TM___TM_GMT_OFF', cc.has_member('struct tm', '__tm_gmtoff', prefix: '#include ')) + +config.set10('HAVE_ALLOCA_H', cc.has_header('alloca.h')) +config.set10('HAVE_ALLOCA', cc.has_function('alloca', prefix: '#include ')) + +check_headers = [ + 'dlfcn.h', + 'inttypes.h', + 'stdint.h', + 'stdio.h', + 'stdlib.h', + 'strings.h', + 'string.h', + 'sys/stat.h', + 'sys/types.h', + 'unistd.h', + 'wchar.h', +] + +foreach header: check_headers + macro = f'HAVE_@0@'.format(header.underscorify().to_upper()) + config.set10(macro, cc.has_header(header)) +endforeach + + +root_include = include_directories('.') + +if get_option('docs') + subdir('docs') +endif +subdir('vendor') +subdir('src') +subdir('tests') diff --git a/meson_options.txt b/meson_options.txt new file mode 100644 index 0000000000..6f2d75e905 --- /dev/null +++ b/meson_options.txt @@ -0,0 +1,10 @@ +option('decnum', type: 'boolean', value: true, description: 'decnum support') +option('oniguruma', type: 'combo', value: 'builtin', choices: ['system', 'builtin', 'false'], description: 'oniguruma support') + +option('bison', type: 'feature', value: 'enabled', description: 'Require flex / bison or use prebuilt files') + +option('error-injection', type: 'boolean', value: false, description: 'build and test with error injection') +option('all-static', type: 'boolean', value: false, description: 'link jq with static libraries only') + +option('docs', type: 'boolean', value: true, description: 'build docs') +option('valgrind', type: 'boolean', value: false, description: 'enable Valgrind during testing') diff --git a/scripts/generate_builtin_inc b/scripts/generate_builtin_inc new file mode 100755 index 0000000000..22682a350e --- /dev/null +++ b/scripts/generate_builtin_inc @@ -0,0 +1,13 @@ +#!/usr/bin/env sh +set -eu + +input=$1 +output=$2 + +od -v -A n -t o1 -- "$input" \ +| sed -e 's/$/ /' \ + -e 's/\([0123456789]\) /\1, /g' \ + -e 's/ $//' \ + -e 's/ 0/ 0/g' \ + -e 's/ \([123456789]\)/ 0\1/g' \ +> "$output" diff --git a/scripts/version b/scripts/version index f24a18d9db..18223f0a10 100755 --- a/scripts/version +++ b/scripts/version @@ -1,6 +1,13 @@ #!/bin/sh set -eu +if [ "${1:-}" = "set-dist" ]; then + sed -i "s|^ *version: run_command.*|version: '$2',|" "$MESON_PROJECT_DIST_ROOT/meson.build" + # meson rewrite works fine starting with v1.10 + # meson rewrite --sourcedir="$MESON_PROJECT_DIST_ROOT" kwargs set project / version "$2" + exit +fi + cd "$(dirname "$0")/../" test -e .git || exit 1 diff --git a/src/meson.build b/src/meson.build new file mode 100644 index 0000000000..9859d0b165 --- /dev/null +++ b/src/meson.build @@ -0,0 +1,133 @@ + +version_file = vcs_tag( + command: ['../scripts/version'], + input: 'version.h.in', + output: 'version.h', +) + +builtin_inc = custom_target( + command: ['../scripts/generate_builtin_inc', '@INPUT@', '@OUTPUT@'], + input: 'builtin.jq', + output: 'builtin.inc', +) + +# TODO: +config_opts_inc = custom_target( + command: ['echo', '#define JQ_CONFIG ""'], + capture: true, + output: 'config_opts.inc', +) + +# Support unavailable flex, bison tools +if flex.found() + lexer_c_h = custom_target( + command: [flex, '-o', '@OUTPUT0@', '--header-file=@OUTPUT1@', '@INPUT@'], + input: 'lexer.l', + output: ['lexer.c', 'lexer.h'], + ) +else + lexer_c_h = ['lexer.c', 'lexer.h'] +endif + +if yacc.found() + parser_c_h = custom_target( + command: [yacc, '-o', '@OUTPUT0@', '--header=@OUTPUT1@', '@INPUT@'], + input: 'parser.y', + output: ['parser.c', 'parser.h'], + ) +else + parser_c_h = ['parser.c', 'parser.h'] +endif + +source_files = [ + 'builtin.c', + 'bytecode.c', + 'compile.c', + 'execute.c', + 'jq_test.c', + 'jv.c', + 'jv_alloc.c', + 'jv_aux.c', + 'jv_dtoa.c', + 'jv_dtoa_tsd.c', + 'jv_file.c', + 'jv_parse.c', + 'jv_print.c', + 'jv_unicode.c', + 'linker.c', + 'locfile.c', + 'util.c', + builtin_inc, + lexer_c_h, + parser_c_h, +] + +c_args = [ + '-Wno-unused-parameter', + '-Wno-unused-function', + '-Wno-pedantic', +] + +foreach key : config.keys() + value = config.get(key) + if f'@value@' != '0' + c_args += [f'-D@key@=@value@'] + endif +endforeach + +if is_win32 + c_args += ['-municode', '-DWIN32'] +endif + + +libinject_errors = static_library('inject_errors', + 'inject_errors.c', + c_args: c_args, + build_by_default: false, +) + + +libjq = library('jq', + source_files, + c_args: c_args, + include_directories: [ + root_include, + ], + dependencies: [ + decnumber, + math, + shlwapi, + oniguruma, + threads, + ], + link_with: [ + get_option('error-injection') ? libinject_errors : [], + ], + link_args: [ + # '-Wl,-export-symbols-regex=^j[qv]_', + # '-Wl,-version-info=1:4:0', + ], + install: true, + version: '1.0.4', +) +# TODO: linker version script + +install_headers('jq.h', 'jv.h') + +pkgconfig.generate(libjq, + name: 'libjq', + url: project_url, + version: meson.project_version(), + description: 'Library to process JSON using a query language', +) + + +jq = executable('jq', + 'main.c', + version_file, + config_opts_inc, + c_args: c_args, + link_with: [libjq], + include_directories: [root_include], + install: true, +) diff --git a/src/version.h.in b/src/version.h.in new file mode 100644 index 0000000000..dab65fd72c --- /dev/null +++ b/src/version.h.in @@ -0,0 +1 @@ +#define JQ_VERSION "@VERSION@" diff --git a/subprojects/oniguruma b/subprojects/oniguruma new file mode 160000 index 0000000000..f95747b462 --- /dev/null +++ b/subprojects/oniguruma @@ -0,0 +1 @@ +Subproject commit f95747b462de672b6f8dbdeb478245ddf061ca53 diff --git a/tests/meson.build b/tests/meson.build new file mode 100644 index 0000000000..526cf7954a --- /dev/null +++ b/tests/meson.build @@ -0,0 +1,28 @@ + +tests = [ + 'mantest', + 'jqtest', + 'shtest', + 'utf8test', + 'base64test', + 'uritest', +] + +if not is_win32 + tests += ['optionaltest'] +endif + +if oniguruma.found() + tests += ['onigtest', 'manonigtest'] +endif + +foreach test: tests + test( + test, + find_program(test), + env: { + 'JQ': jq.full_path(), + 'ENABLE_VALGRIND': get_option('valgrind') ? '1' : '0', + } + ) +endforeach diff --git a/vendor/meson.build b/vendor/meson.build new file mode 100644 index 0000000000..146dc3a33e --- /dev/null +++ b/vendor/meson.build @@ -0,0 +1,38 @@ +vendor_include = include_directories('.') + + +decnumber_lib = static_library('decNumber', + 'decNumber/decContext.c', + 'decNumber/decNumber.c', +) + +decnumber = declare_dependency( + link_with: decnumber_lib, + include_directories: vendor_include, +) + + +if get_option('oniguruma') == 'system' + oniguruma = declare_dependency( + dependencies: dependency('oniguruma'), + compile_args: ['-DHAVE_LIBONIG'], + ) +elif get_option('oniguruma') == 'builtin' + cmake = import('cmake') + oniguruma_opts = cmake.subproject_options() + oniguruma_opts.add_cmake_defines({'BUILD_SHARED_LIBS': false}) + oniguruma_opts.add_cmake_defines({'CMAKE_POSITION_INDEPENDENT_CODE': true}) + oniguruma_opts.append_compile_args('c', '-w') + oniguruma_proj = cmake.subproject( + 'oniguruma', + options: oniguruma_opts, + ) + + oniguruma_dep = oniguruma_proj.dependency('onig') + oniguruma = declare_dependency( + dependencies: oniguruma_dep, + compile_args: ['-DHAVE_LIBONIG'], + ) +else + oniguruma = dependency('', required: false) +endif diff --git a/vendor/oniguruma b/vendor/oniguruma deleted file mode 160000 index 4ef89209a2..0000000000 --- a/vendor/oniguruma +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4ef89209a239c1aea328cf13c05a2807e5c146d1