Mercurial > projects > pwm
comparison Makefile @ 0:a7e41e1a79c8
Initial revision
author | Guido Berhoerster <guido+pwm@berhoerster.name> |
---|---|
date | Thu, 19 Jan 2017 22:39:51 +0100 |
parents | |
children | 55281f14dc9b |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:a7e41e1a79c8 |
---|---|
1 # | |
2 # Copyright (C) 2016 Guido Berhoerster <guido+pwm@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 # | |
23 | |
24 PACKAGE = pwm | |
25 VERSION = 1 | |
26 DISTNAME := $(PACKAGE)-$(VERSION) | |
27 | |
28 # gcc, clang, icc, Sun/Solaris Studio | |
29 CC := $(CC) -std=c99 | |
30 COMPILE.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(TARGET_ARCH) -c | |
31 # gcc, clang, icc | |
32 MAKEDEPEND.c = $(CC) -MM $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) | |
33 # Sun/Solaris Studio | |
34 #MAKEDEPEND.c = $(CC) -xM1 $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) | |
35 # X makedepend | |
36 #MAKEDEPEND.c = makedepend -f- -Y -- $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) -- | |
37 LINK.c = $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(XCPPFLAGS) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH) | |
38 LINK.o = $(CC) $(LDFLAGS) $(XLDFLAGS) $(TARGET_ARCH) | |
39 CP := cp | |
40 INSTALL := install | |
41 INSTALL.exec := $(INSTALL) -D -m 0755 | |
42 INSTALL.data := $(INSTALL) -D -m 0644 | |
43 INSTALL.link := $(CP) -f -P | |
44 PAX := pax | |
45 GZIP := gzip | |
46 SED := sed | |
47 | |
48 DESTDIR ?= | |
49 prefix ?= /usr/local | |
50 bindir ?= $(prefix)/bin | |
51 | |
52 OS_NAME := $(shell uname -s) | |
53 OS_RELEASE := $(shell uname -r) | |
54 | |
55 ifeq ($(OS_NAME),Linux) | |
56 HAVE_ASPRINTF ?= 1 | |
57 HAVE_ERR_H ?= 1 | |
58 HAVE_READPASSPHRASE_H ?= 0 | |
59 HAVE_SETPROGNAME ?= 0 | |
60 HAVE_SYS_TREE_H ?= 0 | |
61 else ifneq ($(findstring $(OS_NAME),FreeBSD DragonFly),) | |
62 HAVE_ASPRINTF ?= 1 | |
63 HAVE_ERR_H ?= 1 | |
64 HAVE_READPASSPHRASE_H ?= 1 | |
65 HAVE_SETPROGNAME ?= 1 | |
66 HAVE_SYS_TREE_H ?= 1 | |
67 else ifeq ($(OS_NAME),NetBSD) | |
68 HAVE_ASPRINTF ?= 1 | |
69 HAVE_ERR_H ?= 1 | |
70 HAVE_READPASSPHRASE_H ?= 0 | |
71 HAVE_SYS_TREE_H ?= 1 | |
72 HAVE_SETPROGNAME ?= 1 | |
73 else ifeq ($(OS_NAME),OpenBSD) | |
74 HAVE_ASPRINTF ?= 1 | |
75 HAVE_ERR_H ?= 1 | |
76 HAVE_READPASSPHRASE_H ?= 1 | |
77 HAVE_SYS_TREE_H ?= 1 | |
78 HAVE_SETPROGNAME ?= 1 | |
79 else ifeq ($(OS_NAME),SunOS) | |
80 ifeq ($(OS_RELEASE),5.10) | |
81 HAVE_ASPRINTF ?= 0 | |
82 HAVE_ERR_H ?= 0 | |
83 else | |
84 HAVE_ASPRINTF ?= 1 | |
85 HAVE_ERR_H ?= 1 | |
86 endif | |
87 HAVE_READPASSPHRASE_H ?= 0 | |
88 HAVE_SYS_TREE_H ?= 0 | |
89 HAVE_SETPROGNAME ?= 0 | |
90 else | |
91 HAVE_ASPRINTF ?= 0 | |
92 HAVE_ERR_H ?= 0 | |
93 HAVE_READPASSPHRASE_H ?= 0 | |
94 HAVE_SETPROGNAME ?= 0 | |
95 HAVE_SYS_TREE_H ?= 0 | |
96 endif | |
97 | |
98 OBJS = cmd.o \ | |
99 pwfile.o \ | |
100 pwm.o \ | |
101 tok.o \ | |
102 util.o | |
103 | |
104 .DEFAULT_TARGET = all | |
105 | |
106 .PHONY: all clean clobber dist install | |
107 | |
108 all: $(PACKAGE) | |
109 | |
110 XCPPFLAGS = -DPACKAGE=\"$(PACKAGE)\" \ | |
111 -DVERSION=\"$(VERSION)\" | |
112 LDLIBS = -lpws -lnettle | |
113 ifeq ($(HAVE_ERR_H),1) | |
114 XCPPFLAGS += -DHAVE_ERR_H | |
115 else | |
116 OBJS += compat/err.o | |
117 endif | |
118 ifeq ($(HAVE_READPASSPHRASE_H),1) | |
119 XCPPFLAGS += -DHAVE_READPASSPHRASE_H | |
120 else | |
121 OBJS += compat/readpassphrase.o | |
122 endif | |
123 ifeq ($(HAVE_SETPROGNAME),1) | |
124 XCPPFLAGS += -DHAVE_SETPROGNAME | |
125 else | |
126 OBJS += compat/setprogname.o | |
127 endif | |
128 ifeq ($(HAVE_SYS_TREE_H),1) | |
129 XCPPFLAGS += -DHAVE_SYS_TREE_H | |
130 endif | |
131 ifneq ($(findstring $(OS_NAME),FreeBSD DragonFly OpenBSD),) | |
132 XCPPFLAGS += -I/usr/local/include | |
133 XLDFLAGS += -L/usr/local/lib | |
134 else ifeq ($(OS_NAME),NetBSD) | |
135 XCPPFLAGS += -I/usr/pkg/include | |
136 XLDFLAGS += -L/usr/pkg/lib | |
137 endif | |
138 ifeq ($(findstring $(OS_NAME),FreeBSD DragonFly NetBSD OpenBSD),) | |
139 XCPPFLAGS += -D_XOPEN_SOURCE=600 | |
140 endif | |
141 ifeq ($(OS_NAME),SunOS) | |
142 XCPPFLAGS += -I/usr/xpg4/include -D__EXTENSIONS__ | |
143 XLDFLAGS += -L/usr/xpg4/lib -R/usr/xpg4/lib | |
144 endif | |
145 | |
146 $(PACKAGE): $(OBJS) | |
147 $(LINK.o) $^ $(LDLIBS) -o $@ | |
148 | |
149 %.o: %.c | |
150 $(MAKEDEPEND.c) $< | $(SED) -f deps.sed >$*.d | |
151 $(COMPILE.c) -o $@ $< | |
152 | |
153 install: | |
154 $(INSTALL.exec) $(PACKAGE) "$(DESTDIR)$(bindir)/$(PACKAGE)" | |
155 | |
156 clean: | |
157 rm -f $(PACKAGE) $(OBJS) | |
158 | |
159 clobber: clean | |
160 rm -f $(patsubst %.o,%.d,$(OBJS)) | |
161 | |
162 dist: clobber | |
163 $(PAX) -w -x ustar -s ',.*/\..*,,' -s ',./[^/]*\.tar\.gz,,' \ | |
164 -s ',^\.$$,,' -s ',\./,$(DISTNAME)/,' . | \ | |
165 $(GZIP) > $(DISTNAME).tar.gz | |
166 | |
167 -include $(patsubst %.o,%.d,$(OBJS)) |