From 42487c8b04c84e9e86263d162bc39586128216de Mon Sep 17 00:00:00 2001 From: Vishnu Santhosh <24693424+vishnu-santhosh@users.noreply.github.com> Date: Thu, 21 May 2026 07:39:49 +0530 Subject: [PATCH] tiny-agent: switch to autotools build The Yocto recipe in meta-tiny-agent inherits the `autotools` class, which expects a standard `./configure && make && make install DESTDIR=...` flow. The hand-rolled Makefile supported none of what the recipe needs: - No `--host=` cross-compilation (Yocto builds on x86_64 host for arm/x86_64 target via sysroot + cross-toolchain) - No `DESTDIR` honored by install (breaks Yocto's `do_install`) - No `--prefix`/`--sysconfdir` for FHS-correct file placement - No `PKG_CHECK_MODULES` for sysroot-aware libcurl/jansson detection (needed in Phase 2) - No `make distcheck` to catch any of the above pre-package Re-implementing all of that manually would mean rewriting half of automake and getting it wrong. autoconf+automake is what Yocto expects, so we use it. configure.ac currently checks only for pty.h and forkpty() in libutil; libcurl, jansson, and systemd detection are deferred to the PRs that add code depending on them. Same source, same binary, same behavior - only the build system changes. Build: ./autogen.sh && ./configure && make Verify: make distcheck (passes clean) Clean: git clean -fdX (removes all gitignored autotools artifacts) Binary moves from build/pty_test to src/pty_test. --- tiny-agent/.gitignore | 26 ++++++++++++++++++++++++++ tiny-agent/Makefile | 19 ------------------- tiny-agent/Makefile.am | 3 +++ tiny-agent/autogen.sh | 2 ++ tiny-agent/configure.ac | 22 ++++++++++++++++++++++ tiny-agent/src/Makefile.am | 4 ++++ 6 files changed, 57 insertions(+), 19 deletions(-) delete mode 100644 tiny-agent/Makefile create mode 100644 tiny-agent/Makefile.am create mode 100755 tiny-agent/autogen.sh create mode 100644 tiny-agent/configure.ac create mode 100644 tiny-agent/src/Makefile.am diff --git a/tiny-agent/.gitignore b/tiny-agent/.gitignore index bffbdc5..6b08279 100644 --- a/tiny-agent/.gitignore +++ b/tiny-agent/.gitignore @@ -1,8 +1,34 @@ +# Hand-rolled build dir (legacy, kept for any in-flight bare-make users) build/ + +# Object files *.o +*.a + +# Autotools generated +Makefile Makefile.in configure +config.h +config.h.in +config.log +config.status + +# Autoreconf --force backup files (and any editor backups) +*~ aclocal.m4 autom4te.cache/ +build-aux/ +m4/ +stamp-h1 .deps/ .libs/ + +# Built binary +pty_test + +# Dist tarballs and distcheck temp dirs +*.tar.gz +*.tar.bz2 +*.tar.xz +tiny-agent-*/ diff --git a/tiny-agent/Makefile b/tiny-agent/Makefile deleted file mode 100644 index e8bcdce..0000000 --- a/tiny-agent/Makefile +++ /dev/null @@ -1,19 +0,0 @@ -CC = gcc -CFLAGS = -Wall -Wextra -std=c99 -g -LDFLAGS = -lutil - -SRC = src/pty.c -BIN = build/pty_test - -.PHONY: all clean - -all: $(BIN) - -$(BIN): $(SRC) | build - $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) - -build: - mkdir -p build - -clean: - rm -rf build diff --git a/tiny-agent/Makefile.am b/tiny-agent/Makefile.am new file mode 100644 index 0000000..5ff2f58 --- /dev/null +++ b/tiny-agent/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = src + +EXTRA_DIST = autogen.sh diff --git a/tiny-agent/autogen.sh b/tiny-agent/autogen.sh new file mode 100755 index 0000000..525de60 --- /dev/null +++ b/tiny-agent/autogen.sh @@ -0,0 +1,2 @@ +#!/bin/sh +exec autoreconf --install --force --verbose diff --git a/tiny-agent/configure.ac b/tiny-agent/configure.ac new file mode 100644 index 0000000..bf7036c --- /dev/null +++ b/tiny-agent/configure.ac @@ -0,0 +1,22 @@ +AC_PREREQ([2.69]) +AC_INIT([tiny-agent], [0.1.0], [https://github.com/vivekvjnk/tiny-agent/issues]) +AC_CONFIG_AUX_DIR([build-aux]) +AC_CONFIG_SRCDIR([src/pty.c]) +AC_CONFIG_HEADERS([config.h]) + +AM_INIT_AUTOMAKE([1.15 foreign subdir-objects -Wall -Werror]) +AM_SILENT_RULES([yes]) + +AC_PROG_CC +AC_PROG_INSTALL + +# PTY support +AC_CHECK_HEADER([pty.h], [], [AC_MSG_ERROR([pty.h not found])]) +AC_CHECK_LIB([util], [forkpty], [], + [AC_MSG_ERROR([libutil with forkpty() not found])]) + +AC_CONFIG_FILES([ + Makefile + src/Makefile +]) +AC_OUTPUT diff --git a/tiny-agent/src/Makefile.am b/tiny-agent/src/Makefile.am new file mode 100644 index 0000000..ef5765e --- /dev/null +++ b/tiny-agent/src/Makefile.am @@ -0,0 +1,4 @@ +AM_CFLAGS = -Wall -Wextra -std=c99 + +bin_PROGRAMS = pty_test +pty_test_SOURCES = pty.c