summaryrefslogtreecommitdiff
path: root/Makefile
blob: ee9e7b8dee482323699b0ef13f22d5db794fc97f (plain) (blame)
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
150
151
152
153
154
155
156
157
158
159
160
CC     =  clang
CFLAGS =  -std=c17 -Wall -Wextra -Wmissing-prototypes -Wpadded -pedantic-errors -Iinclude -fPIC
ifneq ($(thrdsafe),0)
CFLAGS += -Du8c_bethrdsafe
endif
ifeq ($(debug),1)
CFLAGS += -g
else
CFLAGS += -O3 -DNDEBUG
endif
LDFLAGS = -shared -lpthread
HDRS = \
	include/u8c/SIZE_C.h      \
	include/u8c/abrt.h        \
	include/u8c/col.h         \
	include/u8c/dbg.h         \
	include/u8c/dbgprint.h    \
	include/u8c/end.h         \
	include/u8c/errhandltyp.h \
	include/u8c/errtyp.h      \
	include/u8c/fmt.h         \
	include/u8c/fmttyp.h      \
	include/u8c/geterr.h      \
	include/u8c/init.h        \
	include/u8c/isalnum.h     \
	include/u8c/isalpha.h     \
	include/u8c/iscntrl.h     \
	include/u8c/isdigit.h     \
	include/u8c/ispunct.h     \
	include/u8c/isspace.h     \
	include/u8c/isxdigit.h    \
	include/u8c/print.h       \
	include/u8c/println.h     \
	include/u8c/regerrhandl.h \
	include/u8c/seterr.h      \
	include/u8c/setfmt.h      \
	include/u8c/thrdsafe.h    \
	include/u8c/u32alloc.h    \
	include/u8c/u32cat.h      \
	include/u8c/u32cmp.h      \
	include/u8c/u32cp.h       \
	include/u8c/u32fndchr.h   \
	include/u8c/u32fndpat.h   \
	include/u8c/u32free.h     \
	include/u8c/u32ins.h      \
	include/u8c/u32substr.h   \
	include/u8c/u32sz.h       \
	include/u8c/u8alloc.h     \
	include/u8c/u8dec.h       \
	include/u8c/u8enc.h       \
	include/u8c/u8free.h      \
	include/u8c/unimax.h      \
	include/u8c/ver.h         \
	include/u8c/vfmt.h        \
	include/u8c/vprint.h
HDRS_PRIV = \
	src/u8c/dat.h    \
	src/u8c/dattyp.h
SRCS = \
	src/u8c/abrt.c        \
	src/u8c/dat.c         \
	src/u8c/debug.c       \
	src/u8c/end.c         \
	src/u8c/fmt.c         \
	src/u8c/geterr.c      \
	src/u8c/init.c        \
	src/u8c/isalnum.c     \
	src/u8c/isalpha.c     \
	src/u8c/iscntrl.c     \
	src/u8c/isdigit.c     \
	src/u8c/isspace.c     \
	src/u8c/ispunct.c     \
	src/u8c/isxdigit.c    \
	src/u8c/print.c       \
	src/u8c/println.c     \
	src/u8c/regerrhandl.c \
	src/u8c/seterr.c      \
	src/u8c/setfmt.c      \
	src/u8c/thrdsafe.c    \
	src/u8c/u32alloc.c    \
	src/u8c/u32cat.c      \
	src/u8c/u32cmp.c      \
	src/u8c/u32cp.c       \
	src/u8c/u32fndchr.c   \
	src/u8c/u32fndpat.c   \
	src/u8c/u32free.c     \
	src/u8c/u32ins.c      \
	src/u8c/u32substr.c   \
	src/u8c/u32sz.c       \
	src/u8c/u8alloc.c     \
	src/u8c/u8dec.c       \
	src/u8c/u8enc.c       \
	src/u8c/u8free.c      \
	src/u8c/vfmt.c        \
	src/u8c/vprint.c
OBJS = $(SRCS:.c=.o)
LIB  = libu8c.so
$(LIB): $(OBJS)
	$(CC) $(LDFLAGS) $^ -o $@
$(OBJS): $(HDRS) $(HDRS_PRIV)
DOCS = \
	docs/u8c_abrt.3.zst        \
	docs/u8c_col.3.zst         \
	docs/u8c_dbg.3.zst         \
	docs/u8c_dbgprint.3.zst    \
	docs/u8c_end.3.zst         \
	docs/u8c_errhandltyp.3.zst \
	docs/u8c_errtyp.3.zst      \
	docs/u8c_fmt.3.zst         \
	docs/u8c_fmttyp.3.zst      \
	docs/u8c_geterr.3.zst      \
	docs/u8c_init.3.zst        \
	docs/u8c_isalnum.3.zst     \
	docs/u8c_isalpha.3.zst     \
	docs/u8c_iscntrl.3.zst     \
	docs/u8c_isdigit.3.zst      \
	docs/u8c_ispunct.3.zst     \
	docs/u8c_isspace.3.zst     \
	docs/u8c_isxdigit.3.zst    \
	docs/u8c_print.3.zst       \
	docs/u8c_println.3.zst     \
	docs/u8c_regerrhandl.3.zst \
	docs/u8c_seterr.3.zst      \
	docs/u8c_setfmt.3.zst      \
	docs/u8c_thrdsafe.3.zst    \
	docs/u8c_u8alloc.3.zst     \
	docs/u8c_u8dec.3.zst       \
	docs/u8c_u8enc.3.zst       \
	docs/u8c_u8free.3.zst      \
	docs/u8c_u32alloc.3.zst    \
	docs/u8c_u32cat.3.zst      \
	docs/u8c_u32cmp.3.zst      \
	docs/u8c_u32cp.3.zst       \
	docs/u8c_u32fndchr.3.zst   \
	docs/u8c_u32fndpat.3.zst   \
	docs/u8c_u32free.3.zst     \
	docs/u8c_u32ins.3.zst      \
	docs/u8c_u32substr.3.zst   \
	docs/u8c_u32sz.3.zst       \
	docs/u8c_unimax.3.zst      \
	docs/u8c_ver.3.zst         \
	docs/u8c_vfmt.3.zst        \
	docs/u8c_vprint.3.zst
$(DOCS):
	zstd -f $(DOCS:.zst=)
test: $(LIB) test.c
	$(CC) -std=c17 -Wall -Wextra -Wpedantic -Iinclude -O3 -g -L. -lu8c -o $@ [email protected]
.PHONY: clean docs install runtest
clean:
	rm --force test $(DOCS) $(LIB) $(OBJS)
docs: $(DOCS)
install: $(LIB) $(DOCS)
	mkdir --parents $(DESTDIR)/include/u8c
	mkdir --parents $(DESTDIR)/lib
	mkdir --parents $(DESTDIR)/share/man/man3
	install --mode=444 --verbose $(DOCS) $(DESTDIR)/share/man/man3
	install --mode=444 --verbose $(HDRS) $(DESTDIR)/include/u8c
	install --mode=555 --verbose $(LIB) $(DESTDIR)/lib
runtest: test
	export LD_LIBRARY_PATH=$(CURDIR) && ./$^