-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.in
208 lines (161 loc) · 6.17 KB
/
Makefile.in
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
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
#
# Makefile.in/Makefile, build rules for pseudo
#
# Copyright (c) 2008-2015 Wind River Systems, Inc.
#
# SPDX-License-Identifier: LGPL-2.1-only
#
# configuration flags
PREFIX=@PREFIX@
LIBDIR=@LIBDIR@
SUFFIX=@SUFFIX@
SQLITE=@SQLITE@
SQLITE_LIB=@SQLITE_LIB@
SQLITE_MEMORY=@SQLITE_MEMORY@
FORCE_ASYNC=@FORCE_ASYNC@
EPOLL=@EPOLL@
XATTR=@XATTR@
XATTRDB=@XATTRDB@
PROFILING=@PROFILING@
ifeq (true,$(PROFILING))
PSEUDO_PROFILE=$(BIN)/pseudo_profile
else
PSEUDO_PROFILE=
endif
define cond
$(if $(filter true,$($(1))),-D$(2))
endef
OPTDEFS=$(call cond,XATTR,PSEUDO_XATTR_SUPPORT) \
$(call cond,XATTRDB,PSEUDO_XATTRDB) \
$(call cond,PROFILING,PSEUDO_PROFILING)
PASSWD_FALLBACK=@PASSWD_FALLBACK@
BITS=@BITS@
ARCH_FLAGS=@ARCH_FLAGS@
MARK64=@MARK64@
RPATH=@RPATH@
VERSION=1.9.0
LIB=@LIB@
BIN=bin
LOCALSTATE=var/pseudo
BINDIR=$(PREFIX)/$(BIN)
LOCALSTATEDIR=$(PREFIX)/$(LOCALSTATE)
CFLAGS_BASE=-pipe -std=gnu99 -Wall -W -Wextra -Wno-deprecated-declarations
CFLAGS_CODE=-fPIC -D_LARGEFILE64_SOURCE -D_ATFILE_SOURCE $(ARCH_FLAGS)
CFLAGS_DEFS=-DPSEUDO_PREFIX='"$(PREFIX)"' -DPSEUDO_SUFFIX='"$(SUFFIX)"' -DPSEUDO_BINDIR='"$(BIN)"' -DPSEUDO_LIBDIR='"$(LIB)"' -DPSEUDO_LOCALSTATEDIR='"$(LOCALSTATE)"' -DPSEUDO_VERSION='"$(VERSION)"' $(SQLITE_MEMORY) $(FORCE_ASYNC) -DPSEUDO_PASSWD_FALLBACK='$(PASSWD_FALLBACK)' $(OPTDEFS) $(EPOLL)
CFLAGS_DEBUG=-O2 -g
@DEFAULT_SQLITE@CFLAGS_SQL=-L$(SQLITE)/$(SQLITE_LIB) -I$(SQLITE)/include $(RPATH)
CFLAGS_PSEUDO=$(CFLAGS_BASE) $(CFLAGS_CODE) $(CFLAGS_DEFS) \
$(CFLAGS_DEBUG) $(CFLAGS_SQL)
GLOB_PATTERN=guts/*.c
GUTS=$(filter-out "$(GLOB_PATTERN)",$(wildcard $(GLOB_PATTERN)))
SOURCES=$(wildcard *.c)
OBJS=$(subst .c,.o,$(SOURCES))
TESTS=$(patsubst %.c,%,$(wildcard test/*.c))
SHOBJS=pseudo_tables.o pseudo_util.o
DBOBJS=pseudo_db.o
WRAPOBJS=pseudo_wrappers.o
# needed for anything that links with pseduo_client.o, pretty much
CLIENT_LDFLAGS=-ldl -lpthread
DB_LDFLAGS=@SQLITE_LDARG@ -lpthread
PSEUDO=$(BIN)/pseudo
PSEUDODB=$(BIN)/pseudodb
PSEUDOLOG=$(BIN)/pseudolog
LIBPSEUDO=$(LIB)/libpseudo.so
TEMPLATES=templates/guts templates/wrapfuncs.c templates/wrapfuncs.h templates/wrapper_table
TABLES=table_templates/pseudo_tables.c table_templates/pseudo_tables.h
all: $(LIBPSEUDO) $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) $(PSEUDO_PROFILE)
test: all $(TESTS) | $(BIN) $(LIB)
./run_tests.sh -v
test/%: test/%.c
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $@ $<
install-lib: $(LIBPSEUDO)
mkdir -p $(DESTDIR)$(LIBDIR)
cp $(LIBPSEUDO) $(DESTDIR)$(LIBDIR)
$(if $(SUFFIX),cp $(LIBPSEUDO) $(DESTDIR)$(LIBDIR)/libpseudo$(SUFFIX).so,:)
install-bin: $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) $(PSEUDO_PROFILE)
mkdir -p $(DESTDIR)$(BINDIR)
cp $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) $(PSEUDO_PROFILE) $(DESTDIR)$(BINDIR)
install-data:
mkdir -p $(DESTDIR)$(LOCALSTATEDIR)
install: all install-lib install-bin install-data
$(BIN) $(LIB):
mkdir -p $@
pseudo: $(PSEUDO)
$(PSEUDO): pseudo.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_server.o pseudo_ipc.o | $(BIN)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $(PSEUDO) \
pseudo.o pseudo_server.o pseudo_client.o pseudo_ipc.o \
$(DBOBJS) $(SHOBJS) $(LDFLAGS) $(DB_LDFLAGS) $(CLIENT_LDFLAGS)
pseudolog: $(PSEUDOLOG)
$(PSEUDOLOG): pseudolog.o $(SHOBJS) $(DBOBJS) pseudo_client.o pseudo_ipc.o | $(BIN)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $(PSEUDOLOG) pseudolog.o pseudo_client.o pseudo_ipc.o \
$(DBOBJS) $(SHOBJS) $(LDFLAGS) $(DB_LDFLAGS) $(CLIENT_LDFLAGS)
pseudodb: $(PSEUDODB)
$(PSEUDODB): pseudodb.o $(SHOBJS) $(DBOBJS) pseudo_ipc.o | $(BIN)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o $(PSEUDODB) pseudodb.o \
$(DBOBJS) $(SHOBJS) pseudo_ipc.o $(LDFLAGS) $(DB_LDFLAGS) $(CLIENT_LDFLAGS)
libpseudo: $(LIBPSEUDO)
$(LIBPSEUDO): $(WRAPOBJS) pseudo_client.o pseudo_ipc.o $(SHOBJS) | $(LIB)
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -shared -o $(LIBPSEUDO) \
pseudo_client.o pseudo_ipc.o \
$(WRAPOBJS) $(SHOBJS) $(LDFLAGS) $(CLIENT_LDFLAGS)
# *everything* now relies on stuff that's generated in the
# wrapper process.
%.o: %.c pseudo_wrapfuncs.h
$(CC) -c $(CPPFLAGS) $(CFLAGS) $(CFLAGS_PSEUDO) $<
$(OBJS): pseudo_tables.h
pseudo_client.o pseudo_server.o pseudo_ipc.o: pseudo_ipc.h
pseudo_client.o: pseudo_client.h
pseudo_server.o: pseudo_server.h
tables: enums/*.in maketables templatefile.py $(TABLES)
./maketables enums/*.in
wrappers: makewrappers templatefile.py $(TEMPLATES) ports/*/wrapfuncs.in
CC="$(CC) $(CFLAGS) $(CFLAGS_PSEUDO)" ./makewrappers "xattr=$(XATTR)"
.SECONDARY: tables wrappers
pseudo_wrapfuncs.c pseudo_wrapfuncs.h: wrappers
pseudo_tables.c pseudo_tables.h: tables
pseudo_tables.o: pseudo_tables.c
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -c -o pseudo_tables.o pseudo_tables.c
# no-strict-aliasing is needed for the function pointer trickery.
pseudo_wrappers.o: $(GUTS) pseudo_wrappers.c pseudo_wrapfuncs.c pseudo_wrapfuncs.h pseudo_tables.h
$(CC) -fno-strict-aliasing $(CFLAGS) $(CFLAGS_PSEUDO) -D_GNU_SOURCE -c -o pseudo_wrappers.o pseudo_wrappers.c
offsets32:
$(CC) -m32 -o offsets32 offsets.c
offsets64:
$(CC) -m64 -o offsets64 offsets.c
$(PSEUDO_PROFILE): pseudo_profile | $(BIN)
cp pseudo_profile $(BIN)
pseudo_profile: Makefile pseudo_profile.c tables wrappers
$(CC) $(CFLAGS) $(CFLAGS_PSEUDO) -o pseudo_profile pseudo_profile.c
clean:
rm -f *.o $(LIBPSEUDO) $(PSEUDO) $(PSEUDODB) $(PSEUDOLOG) \
$(TESTS) \
pseudo_wrapfuncs.h pseudo_wrapfuncs.c \
pseudo_wrapper_table.c \
pseudo_tables.c pseudo_tables.h \
pseudo_ports.h port_wrappers.c \
offsets32 offsets64 \
pseudo_profile \
port_deps.mk func_deps.mk
touch port_deps.mk func_deps.mk
distclean: clean
rm -f Makefile port_deps.mk func_deps.mk
rm -rf ./$(BIN) ./$(LIB) ./$(LOCALSTATE) ./__pycache__
@echo "WARNING: Makefile has been removed. You must reconfigure to do anything else."
nuke: distclean
case "$(PREFIX)" in "`pwd`"/*) rm -rf "$(PREFIX)";; esac
@echo "WARNING: Removed $(PREFIX)."
tarball:
@test -d .git || ( echo >&2 "Tarball can only be made from git tree."; exit 1)
rm -rf pseudo-$(VERSION)
mkdir -p pseudo-$(VERSION)
( parent=$(PWD); \
cd pseudo-$(VERSION) && \
git clone $$parent && \
mv pseudo/* . && \
rm -rf pseudo/.git* && \
rmdir pseudo \
)
tar cjf pseudo-$(VERSION).tar.bz2 pseudo-$(VERSION)
# Note when we need to rebuild pseudo_wrappers.o
include port_deps.mk
include func_deps.mk