From 47920915c7f68fd451d25a4450950ad0cb539727 Mon Sep 17 00:00:00 2001 From: artemis everfree Date: Sat, 1 Oct 2022 17:56:40 -0700 Subject: [PATCH] Update illumos support to the modern era (#24) * Update Solaris / Illumos support Old versions of Solaris did not have vasprintf, so darkhttpd defined one gated behind an ifdef. Oracle Solaris 10 has had vasprintf since 2011. Oracle Solaris 11 has had it since release. illumos (which also reports as `__sun`) also has it in all current incarnations. As a result, this ifdef'd block creates compiler errors due to a second definition of the function. This commit removes the block. This commit also adds `-lsendfile` to the Makefile for systems that report as `SunOS` in `uname` (Solaris and Illumos), which is necessary to link successfully in current day. * Comment on manually specifying CC in readme Some systems, including versions of illumos I use, do not have a `cc` alias to the system C compiler. Arguably this is a flaw in the distribution, but as a user, it's perhaps helpful to be reminded that this is an option. --- Makefile | 2 +- README.md | 6 ++++++ darkhttpd.c | 10 ---------- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 87f4695..c948c79 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ CC?=cc CFLAGS?=-O -LIBS=`[ \`uname\` = "SunOS" ] && echo -lsocket -lnsl` +LIBS=`[ \`uname\` = "SunOS" ] && echo -lsocket -lnsl -lsendfile` all: darkhttpd diff --git a/README.md b/README.md index d6654ab..225d842 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,12 @@ Simply run make: make ``` +If `cc` is not on your `PATH` as an alias to your C compiler, you may need to specify it. For example, + +``` +CC=gcc make +``` + ## How to run darkhttpd Serve /var/www/htdocs on the default port (80 if running as root, else 8080): diff --git a/darkhttpd.c b/darkhttpd.c index 8a607ee..afa2220 100644 --- a/darkhttpd.c +++ b/darkhttpd.c @@ -381,16 +381,6 @@ static char *xstrdup(const char *src) { return dest; } -#ifdef __sun /* unimpressed by Solaris */ -static int vasprintf(char **strp, const char *fmt, va_list ap) { - char tmp; - int result = vsnprintf(&tmp, 1, fmt, ap); - *strp = xmalloc(result+1); - result = vsnprintf(*strp, result+1, fmt, ap); - return result; -} -#endif - /* vasprintf() that dies if it fails. */ static unsigned int xvasprintf(char **ret, const char *format, va_list ap) __printflike(2,0);