projects/sencrypt

view Makefile @ 19:0bd16b428fc0

Allow local makefile overrides in local.mk
author Guido Berhoerster <guido+sencrypt@berhoerster.name>
date Wed Jul 31 11:21:59 2019 +0200 (2019-07-31)
parents b7309b030e8d
children 5f9dc8f3c53e
line source
1 #
2 # Copyright (C) 2014 Guido Berhoerster <guido+sencrypt@berhoerster.name>
3 #
4 # Permission is hereby granted, free of charge, to any person obtaining
5 # a copy of this software and associated documentation files (the
6 # "Software"), to deal in the Software without restriction, including
7 # without limitation the rights to use, copy, modify, merge, publish,
8 # distribute, sublicense, and/or sell copies of the Software, and to
9 # permit persons to whom the Software is furnished to do so, subject to
10 # the following conditions:
11 #
12 # The above copyright notice and this permission notice shall be included
13 # in all copies or substantial portions of the Software.
14 #
15 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 # CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 # TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 # SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #
24 PACKAGE = sencrypt
25 VERSION = 2
26 DISTNAME := $(PACKAGE)-$(VERSION)
27 DECRYPT_ALIAS = sdecrypt
29 # gcc, clang, icc, Sun/Solaris Studio
30 CC := $(CC) -std=c99
31 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c
32 # gcc, clang, icc
33 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
34 # Sun/Solaris Studio
35 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS)
36 # X makedepend
37 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) --
38 LINK.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
39 LINK.o = $(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH)
40 CP := cp
41 INSTALL := install
42 INSTALL.exec := $(INSTALL) -D -m 0755
43 INSTALL.data := $(INSTALL) -D -m 0644
44 INSTALL.link := $(CP) -f -P
45 PAX := pax
46 GZIP := gzip
47 SED := sed
48 XSLTPROC := xsltproc
49 DOCBOOK5_MANPAGES_STYLESHEET = http://docbook.sourceforge.net/release/xsl-ns/current/manpages/docbook.xsl
50 DOCBOOK5_MANPAGES_FLAGS = --stringparam man.authors.section.enabled 0 \
51 --stringparam man.copyright.section.enabled 0
53 define generate-manpage-rule =
54 $(addsuffix .%,$(basename $1)): $(addsuffix .%.xml,$(basename $(firstword $1))) docbook-update-source-data.xsl
55 $$(XSLTPROC) \
56 --xinclude \
57 --stringparam package $$(PACKAGE) \
58 --stringparam version $$(VERSION) \
59 docbook-update-source-data.xsl $$< | \
60 $$(XSLTPROC) \
61 --xinclude \
62 --output $(firstword $1) \
63 $$(DOCBOOK5_MANPAGES_FLAGS) \
64 $$(DOCBOOK5_MANPAGES_STYLESHEET) \
65 -
66 for alias in $(wordlist 2,$(words $1),$1); do \
67 ln -sf $(notdir $(firstword $1)) $$$$alias; \
68 done
69 endef
71 DESTDIR ?=
72 prefix ?= /usr/local
73 bindir ?= $(prefix)/bin
74 datadir ?= $(prefix)/share
75 mandir ?= $(datadir)/man
77 OS_NAME := $(shell uname -s)
78 OS_RELEASE := $(shell uname -r)
80 ifneq ($(findstring $(OS_NAME),Linux FreeBSD DragonFly NetBSD OpenBSD),)
81 HAVE_ERR_H ?= 1
82 else ifeq ($(OS_NAME),SunOS)
83 ifeq ($(OS_RELEASE),5.10)
84 HAVE_ERR_H ?= 0
85 else
86 HAVE_ERR_H ?= 1
87 endif
88 else ifeq ($(OS_NAME),AIX)
89 HAVE_ERR_H ?= 0
90 endif
92 OBJS = sencrypt.o
94 MANPAGES = $(PACKAGE).1 $(DECRYPT_ALIAS).1
96 .DEFAULT_TARGET = all
98 .PHONY: all clean clobber dist install
100 all: $(PACKAGE) $(OBJS) $(MANPAGES)
102 $(PACKAGE): XCPPFLAGS = -D_XOPEN_SOURCE=600 -DOPENSSL_LOAD_CONF
103 $(PACKAGE): XCFLAGS := $(shell getconf LFS_CFLAGS)
104 $(PACKAGE): LDLIBS := -lcrypto
105 $(PACKAGE): XLDFLAGS := $(shell getconf LFS_LDFLAGS)
106 ifeq ($(HAVE_ERR_H),1)
107 $(PACKAGE): XCPPFLAGS += -DHAVE_ERR_H
108 else
109 OBJS += err.o
110 endif
111 ifeq ($(OS_NAME),SunOS)
112 $(PACKAGE): XCPPFLAGS += -I/usr/xpg4/include
113 $(PACKAGE): XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib
114 endif
115 $(PACKAGE): $(OBJS)
116 $(LINK.o) $^ $(LDLIBS) -o $@
118 $(eval $(call generate-manpage-rule,$(MANPAGES)))
120 %.o: %.c
121 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d
122 $(COMPILE.c) -o $@ $<
124 install:
125 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)"
126 ln -f $(PACKAGE) "$(DESTDIR)$(bindir)/$(DECRYPT_ALIAS)"
127 for manpage in $(MANPAGES); do \
128 if [ -L $${manpage} ]; then \
129 $(INSTALL.link) $${manpage} \
130 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
131 else \
132 $(INSTALL.data) $${manpage} \
133 "$(DESTDIR)$(mandir)/man$${manpage##*.}/$${manpage##*/}"; \
134 fi \
135 done
137 clean:
138 rm -f $(PACKAGE) $(OBJS) $(MANPAGES)
140 clobber: clean
141 rm -f $(patsubst %.o,%.d,$(OBJS))
143 dist: clobber
144 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \
145 -s ',^\.$$,,' -s ',\./,$(DISTNAME)/,' . | \
146 $(GZIP) > $(DISTNAME).tar.gz
148 -include local.mk
150 -include $(patsubst %.o,%.d,$(OBJS))