summaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 791643127c5348c1cde737f600c8f38be033c48f (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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# See LICENSE file for copyright and license details.
.POSIX:

# Choose either yes or no (determines whether system call,
# signal, and error tables, for the list operating systems,
# shall be compiled into the library)
LINUX_SUPPORT = $(DEFAULT_OS_SUPPORT_SELECTION)

# Choose operating system to compile the library for
OS = linux
# Linux:   linux
# Mac OS:  macos
# Windows: windows

CONFIGFILE = config.mk
include $(CONFIGFILE)




include mk/$(OS).mk

LIB_MAJOR = 1
LIB_MINOR = 0
LIB_VERSION = $(LIB_MAJOR).$(LIB_MINOR)
LIB_NAME = syscalls


all: libsyscalls.a libsyscalls.$(LIBEXT)

#extended for each support operating system to download the operating system's source code
download:


SUPPORTED_ARCHES =\
	ALPHA_LE\
	ALPHA_BE\
	AMD64\
	AMD64_X32\
	IA64_LE\
	IA64_BE\
	IA64_P32_LE\
	IA64_P32_BE\
	M68K\
	MICROBLAZE_32_LE\
	MICROBLAZE_32_BE\
	MICROBLAZE_64_LE\
	MICROBLAZE_64_BE\
	MIPS_O32_LE\
	MIPS_O32_BE\
	MIPS_N32_LE\
	MIPS_N32_BE\
	MIPS_N64_LE\
	MIPS_N64_BE\
	PARISC_32\
	PARISC_64\
	POWERPC_32_LE\
	POWERPC_32_BE\
	POWERPC_64_LE\
	POWERPC_64_BE\
	POWERPC_NOSPU_LE\
	POWERPC_NOSPU_BE\
	POWERPC_SPU_LE\
	POWERPC_SPU_BE\
	S390_32\
	S390_64\
	SH_LE\
	SH_BE\
	SPARC_32\
	SPARC_64_LE\
	SPARC_64_BE\
	I386\
	XTENSA_LE\
	XTENSA_BE
# Excluded because of incomplete support (see LIST_ARCH_SPECS in common.h):
#   ARM_OABI_LE ARM_OABI_BE ARM_EABI_LE ARM_EABI_BE

include $(CONFIGFILE)
# Reloading the user's config in case it limits supported architectures


#this not modify, this is a help variable to get the # symbol into sed scripts
h = '"$$(printf '\43\n')"'
#this not modify, this is a help variable to make [[:space:]] shorter
s = [[:space:]]

#extended for each support operating system with the operating system's name as appropriate for filenames
OPERATING_SYSTEMS =

#extended with supported architectures for each operating system
TEST_ENV =

#extended for each support operating system with the number of syscall parameters they use
NPARAMS =

#extended for each support operating system with the maximum used number of fields in its structs and unions
NFIELDS =

#extended for each support operating system
OBJ =\
	libsyscalls_get_datatype_description.o\
	libsyscalls_get_integer_alignment.o\
	libsyscalls_get_signals.o\
	libsyscalls_get_struct_description.o\
	libsyscalls_get_syscall.o\
	libsyscalls_get_syscall_display_info.o\
	libsyscalls_get_syscall_errors.o\
	libsyscalls_get_syscall_range.o\
	libsyscalls_find_named_number.o\
	libsyscalls_make_signed_integer.o\
	libsyscalls_parse_signed_integer.o\
	libsyscalls_perror.o\
	libsyscalls_section_value.o\
	libsyscalls_strerror.o\
	libsyscalls_syscalls_tables_.o\
	libsyscalls_to_tracee_endian.o\
	libsyscalls_to_tracer_endian.o\
	libsyscalls_unsection_value.o

#extended for each support operating system
HDR =\
	libsyscalls.h\
	common.h\
	generated/arches.h\
	generated/lowercase.h\
	generated/oses.h\
	generated/macros.h\
	$(SUBHDR)

SUBHDR =\
	libsyscalls/advanced.h\
	libsyscalls/internal-begin.h\
	libsyscalls/internal-end.h\
	libsyscalls/short-enums.h

TESTUTILS =\
	testutil/get-datatype-description.tu\
	testutil/get-error.tu\
	testutil/get-integer-alignment.tu\
	testutil/get-section-fraction.tu\
	testutil/get-signals.tu\
	testutil/get-syscall-errors.tu\
	testutil/get-syscall-range.tu\
	testutil/is-section-half.tu\
	testutil/is-section-quarter.tu\
	testutil/is-datatype-struct.tu\
	testutil/list-errors.tu\
	testutil/make-signed.tu\
	testutil/parse-signed.tu\
	testutil/perror-all.tu\
	testutil/perror-bad.tu\
	testutil/section-value.tu\
	testutil/strerror-all.tu\
	testutil/strerror-bad.tu\
	testutil/test-search.tu\
	testutil/to-tracee-endian.tu\
	testutil/to-tracer-endian.tu\
	testutil/unsection-value.tu



.SUFFIXES:
.SUFFIXES: .lo .o .c .tu


include linux/$(LINUX_SUPPORT).mk
include mk/generate.mk

include $(CONFIGFILE)
# Reloading the user's config as the makefiles for the OS
# may have made changes to what is supported

TEST_ENV += SUPPORTED_OSES="$(OPERATING_SYSTEMS)"

LOBJ = $(OBJ:.o=.lo)


$(OBJ): $(HDR)
$(LOBJ): $(HDR)
$(TESTUTILS): $(HDR) libsyscalls.a

.c.o:
	$(CC) -c -o $@ $< $(CFLAGS) $(IMPORTANT_CFLAGS) $(CPPFLAGS) $(IMPORTANT_CPPFLAGS)

.c.lo:
	$(CC) -fPIC -c -o $@ $< $(CFLAGS) $(IMPORTANT_CFLAGS) $(CPPFLAGS) $(IMPORTANT_CPPFLAGS)

.c.tu:
	$(CC) -o $@ $< libsyscalls.a $(CFLAGS) $(CPPFLAGS)

libsyscalls.a: $(OBJ)
	@rm -f -- $@
	$(AR) rc $@ $(OBJ)
	$(AR) ts $@ > /dev/null

libsyscalls.$(LIBEXT): $(LOBJ)
	$(CC) $(LIBFLAGS) -o $@ $(LOBJ) $(LDFLAGS)


check: $(TESTUTILS)
	env CPP="$(CPP)" $(TEST_ENV) ./test
	@if grep '^t=:' < ./test >/dev/null; then \
		printf '\033[1;33m%s\033[m\n' 'Warning! tests have been disabled' >&2; \
	fi
	@if grep '^alias p=' < ./test >/dev/null; then \
		printf '\033[1;33m%s\033[m\n' 'Warning! tests are running synchronously' >&2; \
	fi


install: libsyscalls.a libsyscalls.$(LIBEXT)
	mkdir -p -- "$(DESTDIR)$(PREFIX)/lib"
	mkdir -p -- "$(DESTDIR)$(PREFIX)/include/libsyscalls"
	cp -- libsyscalls.a "$(DESTDIR)$(PREFIX)/lib/"
	cp -- libsyscalls.$(LIBEXT) "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBMINOREXT)"
	$(FIX_INSTALL_NAME) "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBMINOREXT)"
	ln -sf -- libsyscalls.$(LIBMINOREXT) "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBMAJOREXT)"
	ln -sf -- libsyscalls.$(LIBMAJOREXT) "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBEXT)"
	cp -- libsyscalls.h "$(DESTDIR)$(PREFIX)/include/"
	cp -- $(SUBHDR) "$(DESTDIR)$(PREFIX)/include/libsyscalls/"

uninstall:
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsyscalls.a"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBMAJOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBMINOREXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/lib/libsyscalls.$(LIBEXT)"
	-rm -f -- "$(DESTDIR)$(PREFIX)/include/libsyscalls.h"
	-cd -- "$(DESTDIR)$(PREFIX)/include/" && rm -f -- $(SUBHDR)
	-rmdir -- "$(DESTDIR)$(PREFIX)/include/libsyscalls"


clean: buildclean
	-rm -rf -- $(OPERATING_SYSTEMS:=-src/)

buildclean: semiclean
	-rm -rf -- generated/ $(OPERATING_SYSTEMS:=-src/*/)

semiclean:
	-rm -f -- *.o *.lo *.su *.gch *.gcov *.gcno *.gcda .*.tmp .*.tmp.c
	-rm -f -- */*.o */*.lo */*.su */*.gch */*.gcov */*.gcno */*.gcda
	-rm -f -- *.a *.so *.so.* *.dll *.dylib *.$(LIBEXT) */*.tu
	-rm -f -- libsyscalls/short-enums.h

.PHONY: all download check install uninstall clean semiclean