-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
149 lines (114 loc) · 3.42 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
VERSION=0.5
#CC = clang -fno-color-diagnostics
# If you set D=1 on the command line then $(D:1=-g)
# returns -g, else it returns the default (-O2).
D = -O2
CFLAGS += -Wall $(D:1=-g)
# For dependencies
CFLAGS += -Wp,-MD,$(@D)/.$(@F).d
MAKEFLAGS += --no-print-directory
# Comment in to enable the log_* functions
# Currently unused. Mainly for debugging.
#CFLAGS += -DLOGGING
# Comment in to enable libcurl
CFLAGS += -DWANT_CURL
# For curl we do not need ssl/gzip
ifeq ($(findstring WANT_CURL,$(CFLAGS)),)
# Comment in to enable https via openssl
CFLAGS += -DWANT_OPENSSL
# Comment in to enable https via mbedtls
#CFLAGS += -DWANT_MBEDTLS
# Comment in to enable gzip encoding
CFLAGS += -DWANT_GZIP
# Comment in for zlib rather than gzip
#CFLAGS += -DWANT_ZLIB
#ZDIR = zlib
# Comment in for persistent connections
CFLAGS += -DREUSE_SOCKET
endif
# Currently I use gccgo
#GO=$(shell which gccgo 2>/dev/null)
#ifneq ($(GO),)
#EXTRA+=go-get-comics
#endif
GO ?= gccgo
CFILES := common.c
# Optionally add openssl
ifneq ($(findstring WANT_OPENSSL,$(CFLAGS)),)
CFLAGS += -DWANT_SSL
LIBS += -lssl -lcrypto
CFILES += openssl.c
endif
# Optionally add mbedtls
ifneq ($(findstring WANT_MBEDTLS,$(CFLAGS)),)
PDIR=mbedtls
CFLAGS += -DWANT_SSL -I$(PDIR)/include
LIBS += -L$(PDIR)/library -lmbedtls -lmbedx509 -lmbedcrypto
CFILES += mbedtls.c
endif
# Optionaly add gzip
ifneq ($(findstring WANT_ZLIB,$(CFLAGS)),)
ZLIB=$(ZDIR)/libz.a
LLIBS += $(ZLIB)
else
ifneq ($(findstring WANT_GZIP,$(CFLAGS)),)
LIBS += -lz
endif
endif
# Optionally add libcurl
ifneq ($(findstring WANT_CURL,$(CFLAGS)),)
LIBS += -lcurl
CFILES += curl.c
else
CFILES += http.c socket.c
endif
ifneq ($(findstring nto-qnx,$(shell $(CC) -dumpmachine)),)
LIBS += -lsocket
endif
LIBS += $(LLIBS)
COMMON := $(CFILES:.c=.o)
#
# Pretty print - "borrowed" from sparse Makefile
#
V = @
Q = $(V:1=)
QUIET_CC = $(Q:@=@echo ' CC '$@;)
QUIET_LINK = $(Q:@=@echo ' LINK '$@;)
QUIET_GO = $(Q:@=@echo ' GO '$@;)
%.o: %.c
$(QUIET_CC)$(CC) -o $@ -c $(CFLAGS) $<
all: get-comics link-check http-get $(EXTRA)
get-comics: get-comics.o $(COMMON) config.o my-parser.o $(LLIBS)
$(QUIET_LINK)$(CC) $(CFLAGS) -o get-comics $+ $(LIBS)
@if [ -x /usr/bin/etags ]; then /usr/bin/etags *.c *.h; fi
link-check: link-check.o $(COMMON) $(LLIBS)
$(QUIET_LINK)$(CC) $(CFLAGS) -o link-check $+ $(LIBS)
http-get: http-get.o $(COMMON) $(LLIBS)
$(QUIET_LINK)$(CC) $(CFLAGS) -o http-get $+ $(LIBS)
go-get-comics: get-comics.go
$(QUIET_GO)$(GO) -o $@ $+
$(ZLIB):
@$(MAKE) -C $(ZDIR)
*.o: get-comics.h
get-comics.html: get-comics.1
man2html get-comics.1 > get-comics.html
check:
sparse $(CFLAGS) get-comics.c $(CFILES) config.c my-parser.c
tarball: COPYING Makefile README* *.[ch] get-comics.1 comics.json
mkdir get-comics-$(VERSION)
cp $+ get-comics-$(VERSION)
tar zcf slackware/get-comics-$(VERSION).tar.gz get-comics-$(VERSION)
rm -rf get-comics-$(VERSION)
$(DESTDIR)/usr/share/get-comics/comics.json:
install -D -m 644 comics.json $(DESTDIR)/usr/share/get-comics/comics.json
install: all $(DESTDIR)/usr/share/get-comics/comics.json
install -D -s -m 755 get-comics $(DESTDIR)/usr/bin/get-comics
install -D -m 644 get-comics.1 $(DESTDIR)/usr/man/man1/get-comics.1
gzip -f $(DESTDIR)/usr/man/man1/get-comics.1
clean:
rm -f get-comics link-check http-get *.o .*.o.d get-comics.html TAGS
rm -f go-get-comics
ifneq ($(ZDIR),)
@make -C $(ZDIR) clean
endif
include $(wildcard .*.o.d)