summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2017-07-26 14:54:06 +0200
committerNatanael Copa <ncopa@alpinelinux.org>2017-07-26 14:59:11 +0200
commitc532b58b892ae2c9696306e11fe44491740b736d (patch)
tree0241fa5ee86584ca30267bdd435aa94d0ccb7772
parent0cfd2d8ec76692ec4567d07eb89a256c267a1527 (diff)
downloadaports-cache-master.tar.bz2
aports-cache-master.tar.xz
make use of program_invocation_name optionalHEADmaster
fixes build on linux
-rw-r--r--Makefile12
-rw-r--r--main.c5
2 files changed, 15 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 6bbed9e..38372f5 100644
--- a/Makefile
+++ b/Makefile
@@ -3,7 +3,17 @@ CC ?= gcc
LD ?= gcc
CFLAGS ?= -Werror -Wall -g -DDEBUG
-LDFLAGS ?=
+LDFLAGS ?=
+
+ifeq ($(shell uname),Darwin)
+HAVE_PROGRAM_INVOCATION_NAME=
+else
+HAVE_PROGRAM_INVOCATION_NAME=1
+endif
+
+ifeq ($(HAVE_PROGRAM_INVOCATION_NAME),1)
+CFLAGS += -DHAVE_PROGRAM_INVOCATION_NAME
+endif
aports-cache-objs := aports-cache.o
diff --git a/main.c b/main.c
index 4ee7aa8..f2320bc 100644
--- a/main.c
+++ b/main.c
@@ -11,7 +11,9 @@
#include "aports-cache.h"
+#ifndef HAVE_PROGRAM_INVOCATION_NAME
static char *program_invocation_name;
+#endif
static void usage(int exitcode)
{
@@ -45,8 +47,9 @@ int main(int argc, char *argv[])
int dirfd, rc;
char *shell_argv[] = {"/bin/sh", NULL};
+#ifndef HAVE_PROGRAM_INVOCATION_NAME
program_invocation_name = argv[0];
-
+#endif
while ((c = getopt_long(argc, argv, "fs:v", opts, &i)) != -1) {
switch(c) {