Mercurial > projects > rantaiwarna
changeset 10:4f6bf50dbc4a default tip
Detect the OS and configure build flags and libraries automatically
author | Guido Berhoerster <guido+rantaiwarna@berhoerster.name> |
---|---|
date | Tue, 13 Sep 2016 18:19:44 +0200 |
parents | 6cbf50148e87 |
children | |
files | Makefile board.c highscore.c rantaiwarna.c util.c |
diffstat | 5 files changed, 18 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/Makefile Tue Sep 13 16:27:32 2016 +0200 +++ b/Makefile Tue Sep 13 18:19:44 2016 +0200 @@ -1,5 +1,5 @@ # -# Copyright (C) 2014 Guido Berhoerster <guido+rantaiwarna@berhoerster.name> +# Copyright (C) 2016 Guido Berhoerster <guido+rantaiwarna@berhoerster.name> # # Permission is hereby granted, free of charge, to any person obtaining # a copy of this software and associated documentation files (the @@ -25,6 +25,8 @@ VERSION = 2 DISTNAME := $(PACKAGE)-$(VERSION) +# gcc, clang, icc, Sun/Solaris Studio +CC := $(CC) -std=c99 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c # gcc, clang, icc MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) @@ -41,7 +43,7 @@ GZIP := gzip SED := sed XSLTPROC := xsltproc -DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl +DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl define generate-manpage-rule = %.$(1): %.$(1).xml @@ -64,6 +66,9 @@ datadir ?= $(prefix)/share mandir ?= $(datadir)/man +OS_NAME := $(shell uname -s) +OS_RELEASE := $(shell uname -r) + OBJS = rantaiwarna.o board.o highscore.o util.o MANPAGES = $(PACKAGE).6 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \ @@ -75,18 +80,17 @@ all: $(PACKAGE) $(MANPAGES) -$(PACKAGE): XCPPFLAGS := -# Illumos/Solaris -#$(PACKAGE): XCPPFLAGS := -I/usr/xpg4/include -$(PACKAGE): XCFLAGS := -$(PACKAGE): LDLIBS := -lcurses -lm -# Linux, FreeBSD, OpenBSD -#$(PACKAGE): LDLIBS := -lncursesw -ltinfo -lm -# Illumos/Solaris, UnixWare, NetBSD -#$(PACKAGE): LDLIBS := -lcurses -lm -$(PACKAGE): XLDFLAGS := -# Illumos/Solaris -#$(PACKAGE): XLDFLAGS := -L/usr/xpg4/lib -R/usr/xpg4/lib +$(PACKAGE): XCPPFLAGS = -D_XOPEN_SOURCE=600 +$(PACKAGE): LDLIBS = -lm +ifeq ($(OS_NAME),SunOS) + $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include + $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib + $(PACKAGE): LDLIBS += -lcurses +else ifneq ($(findstring $(OS_NAME),UnixWare NetBSD),) + $(PACKAGE): LDLIBS += -lcurses +else + $(PACKAGE): LDLIBS += -lncursesw -ltinfo +endif $(PACKAGE): $(OBJS) $(LINK.o) $^ $(LDLIBS) -o $@
--- a/board.c Tue Sep 13 16:27:32 2016 +0200 +++ b/board.c Tue Sep 13 18:19:44 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <stdlib.h> #include <unistd.h> #include <curses.h> /* for OK, ERR */
--- a/highscore.c Tue Sep 13 16:27:32 2016 +0200 +++ b/highscore.c Tue Sep 13 18:19:44 2016 +0200 @@ -21,8 +21,6 @@ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#define _XOPEN_SOURCE 600 - #include <stdlib.h> #include <pwd.h> #include <unistd.h>