From: Alyssa Ross <hi@alyssa.is>
To: devel@spectrum-os.org
Subject: [PATCH ucspi-vsock 4/7] configure: create, to generate config.h
Date: Fri, 19 Mar 2021 02:56:49 +0000 [thread overview]
Message-ID: <20210319025648.17925-4-hi@alyssa.is> (raw)
In-Reply-To: <20210319025349.8839-2-hi@alyssa.is>
This will allow programs to refer to BINDIR to find other ucspi-vsock
programs, which allows programs to be implemented in terms of each
other.
---
This is how the new vsockserver program will know where to find
vsockserver-socketbinder and vsockserverd.
.gitignore | 5 ++++-
Makefile => Makefile.in | 12 ++++++++--
configure | 49 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 63 insertions(+), 3 deletions(-)
rename Makefile => Makefile.in (78%)
create mode 100755 configure
diff --git a/.gitignore b/.gitignore
index a63eff4..89a0408 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,9 @@
# SPDX-License-Identifier: GPL-2.0-or-later
-# SPDX-FileCopyrightText: 2020 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2020-2021 Alyssa Ross <hi@alyssa.is>
*.o
+*.tmp
vsockclient
vsockserver
+config.h
+Makefile
diff --git a/Makefile b/Makefile.in
similarity index 78%
rename from Makefile
rename to Makefile.in
index e05e32f..3260e85 100644
--- a/Makefile
+++ b/Makefile.in
@@ -7,8 +7,8 @@ CFLAGS = -Wall -Wextra -O -g
INSTALL = install
INSTALL_PROGRAM = $(INSTALL)
-prefix = /usr/local
-bindir = $(prefix)/bin
+prefix = @PREFIX@
+bindir = @BINDIR@
PROGRAMS = vsockclient vsockserver
@@ -20,6 +20,10 @@ install: $(PROGRAMS)
$(INSTALL_PROGRAM) $(PROGRAMS) $(DESTDIR)$(bindir)
.PHONY: install
+config.h: configure
+ @echo "Error: config.h is outdated. Please re-run ./configure." >&2
+ @exit 1
+
vsockclient: vsockclient.o env.o log.o num.o vsock.o
$(CC) $(LDFLAGS) -o $@ $@.o env.o log.o num.o vsock.o $(LDLIBS)
vsockserver: vsockserver.o env.o log.o num.o vsock.o
@@ -31,3 +35,7 @@ vsockserver.o: env.h log.h num.h vsock.h
clean:
rm -f $(PROGRAMS) *.o
.PHONY: clean
+
+distclean: clean
+ rm -f config.h Makefile *.tmp
+.PHONY: distclean
diff --git a/configure b/configure
new file mode 100755
index 0000000..38c926c
--- /dev/null
+++ b/configure
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+# SPDX-License-Identifier: GPL-2.0-or-later
+# SPDX-FileCopyrightText: 2021 Alyssa Ross <hi@alyssa.is>
+
+set -ue
+
+prefix=/usr/local
+bindir=
+
+unrecognized=
+
+for arg; do
+ if [ "$arg" = "--help" ]; then
+ cat <<EOF
+Usage: $0 [OPTION]..."
+
+Options:
+ -h, --help
+ --prefix=PREFIX Default: /usr/local
+ --bindir=BINDIR Default: PREFIX/bin
+EOF
+ exit
+ fi
+done
+
+for arg; do
+ if printf "%s" "$arg" | grep -q "^--prefix="; then
+ prefix="$(printf "%s" "$arg" | cut -d= -f2-)"
+ elif printf "%s" "$arg" | grep -q "^--bindir="; then
+ bindir="$(printf "%s" "$arg" | cut -d= -f2-)"
+ else
+ unrecognized="$unrecognized $arg"
+ fi
+done
+
+bindir="${bindir:-$prefix/bin}"
+
+echo "// Generated by $0${*:+ $*}" > config.h.tmp
+echo "#define PREFIX \"$prefix\"" >> config.h.tmp
+echo "#define BINDIR \"$bindir\"" >> config.h.tmp
+mv config.h.tmp config.h
+
+sed -e "s#@PREFIX@#$prefix#g" -e "s#@BINDIR@#$bindir#g" Makefile.in > Makefile.tmp
+mv Makefile.tmp Makefile
+
+if [ -n "$unrecognized" ]; then
+ echo "Warning: unrecognized options:$unrecognized" >&2
+fi
--
2.30.0
next prev parent reply other threads:[~2021-03-19 3:02 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-03-19 3:23 Broken threading fix Alyssa Ross
2021-03-19 2:56 ` [PATCH ucspi-vsock 1/7] vsock: get cid and port instead of just cid Alyssa Ross
2021-03-19 2:53 ` [PATCH ucspi-vsock 0/7] Extract vsockserver-socketbinder and vsockserverd Alyssa Ross
2021-03-19 3:19 ` Alyssa Ross
2021-03-19 2:56 ` [PATCH ucspi-vsock 2/7] vsock: check socket family before reading sockaddr Alyssa Ross
2021-03-19 2:56 ` [PATCH ucspi-vsock 3/7] vsockserver: switch to a non-blocking socket Alyssa Ross
2021-03-19 2:56 ` Alyssa Ross [this message]
2021-03-19 2:56 ` [PATCH ucspi-vsock 5/7] log: add die function Alyssa Ross
2021-03-19 2:56 ` [PATCH ucspi-vsock 6/7] exec: add execzp() Alyssa Ross
2021-03-19 3:17 ` [PATCH ucspi-vsock 7/7] Extract vsockserver-socketbinder and vsockserverd Alyssa Ross
2021-03-19 3:39 ` Cole Helbling
2021-03-20 20:24 ` Alyssa Ross
2021-03-21 2:52 ` Cole Helbling
2021-03-21 14:33 ` Alyssa Ross
2021-03-21 14:38 ` Alyssa Ross
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210319025648.17925-4-hi@alyssa.is \
--to=hi@alyssa.is \
--cc=devel@spectrum-os.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://spectrum-os.org/git/crosvm
https://spectrum-os.org/git/doc
https://spectrum-os.org/git/mktuntap
https://spectrum-os.org/git/nixpkgs
https://spectrum-os.org/git/spectrum
https://spectrum-os.org/git/ucspi-vsock
https://spectrum-os.org/git/www
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).