aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore12
-rw-r--r--Makefile53
-rw-r--r--Makefile.am4
-rw-r--r--configure.ac11
-rw-r--r--rpt.1.in2
-rw-r--r--rpt.c4
6 files changed, 60 insertions, 26 deletions
diff --git a/.gitignore b/.gitignore
index 199a4f0..ac0a86f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,8 +1,6 @@
-# C
-*.o
-
-# executable
rpt
-
-# manual pages
-*.gz
+rpt.o
+rpt.1
+rpt.1.gz
+*.tar.gz
+*.tar.gz.sig
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..e6c19b2
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,53 @@
+PREFIX ?= /usr/local
+CFLAGS ?= -O2 -g
+LDFLAGS ?=
+LIBS ?=
+
+
+
+REPEAT_VERSION := 1.4
+DATE := $(shell date '+%Y-%m-%d')
+
+__CFLAGS := -std=c99 -Wall \
+ -DREPEAT_VERSION=\"$(REPEAT_VERSION)\" \
+ -D_POSIX_C_SOURCE=200809L
+__LDFLAGS :=
+__LIBS :=
+
+all: rpt rpt.1.gz
+
+rpt: rpt.o
+ $(CC) -o $@ $^ $(__LDFLAGS) $(__LIBS) $(LDFLAGS) $(LIBS)
+
+rpt.o: rpt.c
+ $(CC) $(__CFLAGS) $(CFLAGS) -o $@ -c $<
+
+rpt.1.gz: rpt.1
+ gzip -9 -c $< > $@
+
+rpt.1: rpt.1.in
+ sed -e "s:@DATE@:$(DATE):" \
+ -e "s:@REPEAT_VERSION@:$(REPEAT_VERSION):" \
+ < $< \
+ > $@
+
+install: all
+ mkdir -p $(PREFIX)/bin
+ install --mode=0755 rpt $(PREFIX)/bin/
+
+ mkdir -p $(PREFIX)/share/man/man1
+ install --mode=0644 rpt.1.gz $(PREFIX)/share/man/man1/
+
+uninstall:
+ rm -rf $(PREFIX)/bin/rpt
+
+clean:
+ rm -rf rpt *.tar.gz rpt.o
+
+dist:
+ git archive \
+ --output="repeat-$(REPEAT_VERSION).tar.gz" \
+ --prefix="repeat-$(REPEAT_VERSION)/" \
+ HEAD
+
+.PHONY: all clean dist install uninstall
diff --git a/Makefile.am b/Makefile.am
deleted file mode 100644
index a321aac..0000000
--- a/Makefile.am
+++ /dev/null
@@ -1,4 +0,0 @@
-bin_PROGRAMS = rpt
-rpt_SOURCES = rpt.c
-AM_CFLAGS = -std=c99 -Wall -Wextra -g -O2 -D_POSIX_C_SOURCE=200809L
-dist_man1_MANS = rpt.1
diff --git a/configure.ac b/configure.ac
deleted file mode 100644
index 12d50ea..0000000
--- a/configure.ac
+++ /dev/null
@@ -1,11 +0,0 @@
-AC_INIT([repeat], [1.3.0])
-AM_INIT_AUTOMAKE([-Wall -Werror, foreign])
-: ${CFLAGS=""}
-AC_PROG_CC
-AM_SILENT_RULES([yes])
-AC_CONFIG_HEADERS([config.h])
-AC_CONFIG_FILES([
- Makefile
- rpt.1
-])
-AC_OUTPUT
diff --git a/rpt.1.in b/rpt.1.in
index 6a0ef04..301e080 100644
--- a/rpt.1.in
+++ b/rpt.1.in
@@ -1,7 +1,7 @@
.\" Copyright (C), 2024 Tristan Riehs
.\" You may distribute this file under the terms of the GNU Free
.\" Documentation License.
-.TH repeat 1 "2024-02-03" "repeat @VERSION@"
+.TH repeat 1 "@DATE@" "repeat @REPEAT_VERSION@"
.SH NAME
repeat \- repeat a shell command
.SH SYNOPSIS
diff --git a/rpt.c b/rpt.c
index 27ae24c..b356814 100644
--- a/rpt.c
+++ b/rpt.c
@@ -14,8 +14,6 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "config.h"
-
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
@@ -73,7 +71,7 @@ print_help()
void
print_version()
{
- puts(VERSION);
+ puts(REPEAT_VERSION);
}
void