comparison Makefile @ 12:14e58decdf87

Detect the OS and configure build flags and libraries automatically
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Tue, 13 Sep 2016 18:37:25 +0200
parents 27bc2d4947da
children 5a992d873084
comparison
equal deleted inserted replaced
11:27bc2d4947da 12:14e58decdf87
24 PACKAGE = sencrypt 24 PACKAGE = sencrypt
25 VERSION = 2 25 VERSION = 2
26 DISTNAME := $(PACKAGE)-$(VERSION) 26 DISTNAME := $(PACKAGE)-$(VERSION)
27 DECRYPT_ALIAS = sdecrypt 27 DECRYPT_ALIAS = sdecrypt
28 28
29 # gcc, clang, icc, Sun/Solaris Studio
30 CC := $(CC) -std=c99
29 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c 31 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c
30 # gcc, clang, icc 32 # gcc, clang, icc
31 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) 33 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
32 # Sun/Solaris Studio 34 # Sun/Solaris Studio
33 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) 35 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
63 prefix ?= /usr/local 65 prefix ?= /usr/local
64 bindir ?= $(prefix)/bin 66 bindir ?= $(prefix)/bin
65 datadir ?= $(prefix)/share 67 datadir ?= $(prefix)/share
66 mandir ?= $(datadir)/man 68 mandir ?= $(datadir)/man
67 69
68 HAVE_ERR_H ?= 1 70 OS_NAME := $(shell uname -s)
71 OS_RELEASE := $(shell uname -r)
72
73 ifneq ($(findstring $(OS_NAME),Linux FreeBSD DragonFly NetBSD OpenBSD),)
74 HAVE_ERR_H ?= 1
75 else ifeq ($(OS_NAME),SunOS)
76 ifeq ($(OS_RELEASE),5.10)
77 HAVE_ERR_H ?= 0
78 else
79 HAVE_ERR_H ?= 1
80 endif
81 endif
69 82
70 OBJS = sencrypt.o 83 OBJS = sencrypt.o
71 MANPAGES = $(PACKAGE).1 $(DECRYPT_ALIAS).1 84 MANPAGES = $(PACKAGE).1 $(DECRYPT_ALIAS).1
72 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \ 85 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
73 --stringparam man.copyright.section.enabled 0 86 --stringparam man.copyright.section.enabled 0
74 87
75 ifeq ($(HAVE_ERR_H),0)
76 OBJS += err.o
77 endif
78
79 .DEFAULT_TARGET = all 88 .DEFAULT_TARGET = all
80 89
81 .PHONY: all clean clobber dist install 90 .PHONY: all clean clobber dist install
82 91
83 all: $(PACKAGE) $(MANPAGES) 92 all: $(PACKAGE) $(OBJS) $(MANPAGES)
84 93
85 $(PACKAGE): XCPPFLAGS := -DOPENSSL_LOAD_CONF 94 $(PACKAGE): XCPPFLAGS = -D_XOPEN_SOURCE=600 -DOPENSSL_LOAD_CONF
86 ifeq ($(HAVE_ERR_H),1) 95 ifeq ($(HAVE_ERR_H),1)
87 $(PACKAGE): XCPPFLAGS += -DHAVE_ERR_H 96 $(PACKAGE): XCPPFLAGS += -DHAVE_ERR_H
97 else
98 OBJS += err.o
88 endif 99 endif
89 $(PACKAGE): XCFLAGS := $(shell getconf LFS_CFLAGS) 100 $(PACKAGE): XCFLAGS := $(shell getconf LFS_CFLAGS)
90 $(PACKAGE): LDLIBS := -lcrypto 101 $(PACKAGE): LDLIBS := -lcrypto
91 $(PACKAGE): XLDFLAGS := $(shell getconf LFS_LDFLAGS) 102 $(PACKAGE): XLDFLAGS := $(shell getconf LFS_LDFLAGS)
92 $(PACKAGE): $(OBJS) 103 $(PACKAGE): $(OBJS)