diff --git a/.gitignore b/.gitignore index 779b3dbcf..e811a1837 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,7 @@ go/mlr go/mlr.exe -./mlr -./mlr.exe +mlr +mlr.exe a.out *.dSYM catc diff --git a/Makefile b/Makefile index 0eaf2e192..199a2b8c2 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,7 @@ build: make -C go build - @echo Miller executable is: go/mlr + @echo "Miller executable is: ./mlr, or go\mlr.exe on Windows" check: make -C go check diff --git a/configure b/configure new file mode 100755 index 000000000..05179572c --- /dev/null +++ b/configure @@ -0,0 +1,27 @@ +#!/bin/bash + +usage() { + echo "Usage: $0 [--prefix {prefix directory}], e.g. /usr/local" 2>&1 + exit 1 +} + +prefix="/usr/local" +if [ $# -eq 0 ]; then + echo "Using $prefix" +elif [ $# -ne 2 ]; then + usage +else + if [ "$1" != "--prefix" ]; then + usage + fi + # Test for read access, not write access, since people can ./configure, make, + # and make check outside of sudo and then make install inside sudo. + prefix="$2" + if [ ! -d "$prefix" ]; then + echo "$0: could not find prefix directory \"$prefix\"" + exit 1 + fi +fi + +sed "s@PREFIX_TEMPLATE_IS_HERE@$prefix@" go/Makefile.in > go/Makefile +sed "s@PREFIX_TEMPLATE_IS_HERE@$prefix@" man/Makefile.in > man/Makefile diff --git a/go/Makefile b/go/Makefile index 1da98e72e..e1705b416 100644 --- a/go/Makefile +++ b/go/Makefile @@ -1,8 +1,11 @@ -# TODO: take from ../configure -INSTALLDIR=/usr/local/bin +# Please edit Makefile.in rather than Makefile, which is overwritten by ../configure. +PREFIX=/usr +INSTALLDIR=$(PREFIX)/bin +# Attempt cp; will fail on Windows but ignore and continue build: go build + -cp mlr .. check: # Unit tests (small number) diff --git a/go/Makefile.in b/go/Makefile.in new file mode 100644 index 000000000..643b5dbca --- /dev/null +++ b/go/Makefile.in @@ -0,0 +1,28 @@ +# Please edit Makefile.in rather than Makefile, which is overwritten by ../configure. +PREFIX=PREFIX_TEMPLATE_IS_HERE +INSTALLDIR=$(PREFIX)/bin + +# Attempt cp; will fail on Windows but ignore and continue +build: + go build + -cp mlr .. + +check: + # Unit tests (small number) + go test -v mlr/src/... + # Regression tests (large number) + # + # See ./regression_test.go for information on how to get more details + # for debugging. TL;DR is for CI jobs, we have 'go test -v'; for + # interactive use, instead of 'go test -v' simply use 'mlr regtest + # -vvv' or 'mlr regtest -s 20'. See also src/auxents/regtest. + go test -v + +install: build + cp mlr $(INSTALLDIR) + +fmt: + go fmt ./... + +# Go does its own dependency management, outside of make. +.PHONY: build fmt diff --git a/go/todo.txt b/go/todo.txt index dab1e6f19..d82c1bd73 100644 --- a/go/todo.txt +++ b/go/todo.txt @@ -2,6 +2,10 @@ PUNCHDOWN LIST * plan: + o conda etc + - get a link for rmd + - ./configure experiment + - miller.spec experiment o blockers: - fractional-strptime - cmp-matrices diff --git a/man/Makefile b/man/Makefile index 5b17b72c6..915c02410 100644 --- a/man/Makefile +++ b/man/Makefile @@ -1,9 +1,11 @@ +# Please edit Makefile.in rather than Makefile, which is overwritten by ../configure. +# # Respective MANPATH entries would include /usr/local/share/man or $HOME/man. # This should be run after make in the ../c directory but before make in the ../docs directory, # since ../go/mlr is used to autogenerate ./manpage.txt which is used in ../docs. # See also https://miller.readthedocs.io/en/latest/build.html#creating-a-new-release-for-developers -# TODO: take this from ./configure -INSTALLDIR=/usr/local/share/man/man1 +PREFIX=/usr +INSTALLDIR=$(PREFIX)/share/man/man1 # This is normally done only on a development host. Through CI and # package-installer, mlr.1 should be treated as an already-built artifact, diff --git a/man/Makefile.in b/man/Makefile.in new file mode 100644 index 000000000..accfca4df --- /dev/null +++ b/man/Makefile.in @@ -0,0 +1,31 @@ +# Please edit Makefile.in rather than Makefile, which is overwritten by ../configure. +# +# Respective MANPATH entries would include /usr/local/share/man or $HOME/man. +# This should be run after make in the ../c directory but before make in the ../docs directory, +# since ../go/mlr is used to autogenerate ./manpage.txt which is used in ../docs. +# See also https://miller.readthedocs.io/en/latest/build.html#creating-a-new-release-for-developers +PREFIX=PREFIX_TEMPLATE_IS_HERE +INSTALLDIR=$(PREFIX)/share/man/man1 + +# This is normally done only on a development host. Through CI and +# package-installer, mlr.1 should be treated as an already-built artifact, +# needing only to be copied to its install dir. +# Copying to man1/mlr1 is so that you can then put the Miller dir in your +# $MANPATH and do "man mlr". +build: .always + echo mkman start + ./mkman.rb > mlr.1 + ./mkman.rb | groff -man -Tascii | col -b | expand -8 > manpage.txt + cp manpage.txt ../docs/src/ + echo mkman end + mkdir ./man1 + cp mlr.1 ./man1 + +install: + mkdir -p $(INSTALLDIR) + cp mlr.1 $(INSTALLDIR)/mlr.1 + + +# ---------------------------------------------------------------- +.always: + true diff --git a/miller.spec b/miller.spec index 28426cb75..4239d8910 100644 --- a/miller.spec +++ b/miller.spec @@ -1,12 +1,14 @@ Summary: Name-indexed data processing tool Name: miller -Version: 5.10.2 +Version: 6.0.0 Release: 1%{?dist} License: BSD Source: https://github.com/johnkerl/miller/releases/download/%{version}/mlr-%{version}.tar.gz URL: https://miller.readthedocs.io +# gcc for cgo transitive dependency +BuildRequires: golang BuildRequires: gcc -BuildRequires: flex >= 2.5.35 +BuildRequires: systemd-rpm-macros %description Miller (mlr) allows name-indexed data such as CSV and JSON files to be @@ -16,17 +18,16 @@ streams data where possible so its memory requirements stay small. It works well with pipes and can feed "tail -f". %prep -%setup -q -n mlr-%{version} +%autosetup %build -%configure -%make_build +make build %check make check %install -%make_install +make install %files %license LICENSE.txt