-
Notifications
You must be signed in to change notification settings - Fork 20
/
makefile.in
435 lines (353 loc) · 11.7 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
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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
#
# Copyright (c) 2008, 2009, 2010 Joseph Gaeddert
# Copyright (c) 2008, 2009, 2010 Virginia Polytechnic
# Institute & State University
#
# This file is part of liquid.
#
# liquid is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# liquid is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with liquid. If not, see <http://www.gnu.org/licenses/>.
#
#
# Makefile for liquid fixed-point math libraries
#
# Targets:
# all : dynamic shared-library object (e.g. libliquidfpm.so)
# help : print list of targets
# install : install the dynamic shared library object and header file(s)
# uninstall : uninstall the library and header file(s)
# bench : build and run benchmarking program
# check : build and run autotest program
# clean : clean all targets (bench, check, examples, etc)
# distclean : removes everything except the originally distributed files
#
# autoconf initialization macros
NAME := @PACKAGE_NAME@
VERSION := @PACKAGE_VERSION@
BUGREPORT := @PACKAGE_BUGREPORT@
# paths
srcdir = @srcdir@
libdir = @libdir@
prefix = @prefix@
exec_prefix = @exec_prefix@
VPATH = @srcdir@
include_dirs := . include
vpath %.h $(include_dirs)
# programs
CC := @CC@
MV := mv -f
RM := rm -f
SED := @SED@
GREP := @GREP@
AR := ar
RANLIB := @RANLIB@
AS := as
# flags
INCLUDE_CFLAGS = $(addprefix -I ,$(include_dirs))
CONFIG_CFLAGS = @ARCH_OPTION@ @DEBUG_OPTION@
CFLAGS += $(INCLUDE_CFLAGS) -g -O2 -Wall -fPIC $(CONFIG_CFLAGS)
LDFLAGS += @LIBS@
ARFLAGS = r
ASFLAGS += -g -I./genlib
#ASFLAGS += -arch ppc7400
# define constants
# qtype : name of fixed-point object, e.g. 'q32'
# qtype_intbits : number of integer bits in type
# qtype_fracbits : number of fractional bits in type
qtype = @QTYPE@
qtype_intbits = @QTYPE_INTBITS@
qtype_fracbits = @QTYPE_FRACBITS@
# Target collection
#
# Information about targets is collected in these variables
programs :=
sources :=
libraries :=
extra_clean :=
objects = $(patsubst %.c,%.o,$(sources))
all:
sources += \
src/libliquidfpm.c \
src/qfloat.c \
src/inv.newton.c \
src/kaiser.c \
src/log2.polyfit.c \
src/log2.shiftadd.c \
src/exp2.polyfit.c \
src/exp2.shiftadd.c \
src/qtype_div.port.c \
src/qtype_div.inv.newton.c \
src/qtype_dotprod.port.c \
src/sqrt.newton.c \
src/sincos.pwpolyfit.c \
src/sincos.cordic.c \
src/sinhcosh.cordic.c \
src/atan.pwpolyfit.c \
src/atan.cordic.c \
src/complex_arithmetic.c \
src/complex_conversion.c \
src/complex_log.c \
src/complex_trig.c \
src/math.transcendentals.c \
src/loglogbesseli0.pwpoly.c \
src/ratio.c \
src/utility.c
# src/qtype_mul.port.c (portlibs)
autotest_headers = \
autotest/qtype_constants_autotest.h \
autotest/atan2_cordic_autotest.h \
autotest/cqtype_add_autotest.h \
autotest/cqtype_mul_autotest.h \
autotest/cqtype_trig_autotest.h \
autotest/exp2_shiftadd_autotest.h \
autotest/inv_newton_autotest.h \
autotest/libversion_autotest.h \
autotest/log2_shiftadd_autotest.h \
autotest/qtype_add_autotest.h \
autotest/qtype_sub_autotest.h \
autotest/qtype_mul_autotest.h \
autotest/qtype_div_autotest.h \
autotest/qtype_div_inv_newton_autotest.h \
autotest/sinc_autotest.h \
autotest/sincos_cordic_autotest.h \
autotest/sqrt_newton_autotest.h
# autotest/sinhcosh_cordic_autotest.h
extra_clean +=
#
# Dependencies
#
# complex data types
src/cq32.o : src/cq32.c src/complex_arithmetic.c src/complex_conversion.c src/complex_trig.c src/complex_log.c
# Force objects to be dependent upon headers
$(objects) : ./include/liquidfpm.h ./include/liquidfpm.internal.h ./config.h
#
# gentab : auto-generated tables
#
gentabs := \
constants \
atan2.pwpolyfit \
math.transcendentals \
logsin \
sincos.cordic \
sincos.pwpoly \
sinhcosh.cordic \
logexp.shiftadd \
logexp.polyfit
# Examples:
# gentab_scripts : gentab/gentab.math.transcendentals.c
# gentab_programs : gentab/gentab.math.transcendentals
# gentab_targets : gentab/math.transcendentals.qtype.c
# gentab_objects : gentab/math.transcendentals.qtype.o
gentab_scripts = $(patsubst %,gentab/gentab.%.c,$(gentabs))
gentab_programs = $(patsubst %.c,%,$(gentab_scripts))
gentab_targets = $(patsubst %,gentab/%.$(qtype).c,$(gentabs))
gentab_objects = $(patsubst %.c,%.o,$(gentab_targets))
# Build the gentab program. This is done natively as the
# result is a program that generates a source file to be
# built for the target system.
$(gentab_programs) : % : %.c ./include/liquidfpm.h
$(CC) $(INCLUDE_CFLAGS) -lm $< -o $@
# Run the natively-built program to generate the source
# file. This file is to be built for the target system.
$(gentab_targets) : gentab/%.$(qtype).c : gentab/gentab.%
./$< -n $(qtype) -i $(qtype_intbits) -f $(qtype_fracbits) > $@
# Label the programs and targets as 'precious' so that
# make won't delete them after they have been created.
.PRECIOUS : $(gentab_programs)
.PRECIOUS : $(gentab_targets)
# Clean the intermediate gentab programs and targets
# marked as 'precious.'
clean-gentab :
$(RM) $(gentab_programs)
$(RM) $(gentab_targets)
$(RM) $(gentab_objects)
#
# genlib : additional auto-generated sources
#
genlib_programs := genlib/qtype.s.gen
genlib_objects := @GENLIBS@
genlib_sources := $(patsubst %.o,%.s,$(genlib_objects))
# qtype.s.gen
#
# Program to generate assembly code which defines
# the precision (intbits, fracbits) in the native
# target assembly language, and then includes the
# architecture-specific assembly routines for
# certain functions (e.g. q32_mul).
$(genlib_programs) : % : %.c
$(CC) $(CFLAGS) $< -o $@
# TODO : summarize the assembly routines below
# PowerPC assembly
genlib/$(qtype).ppc.s : genlib/qtype.s.gen
./$< -a ppc -n$(qtype) -i$(qtype_intbits) -f$(qtype_fracbits) -o $@
# x86 assembly
genlib/$(qtype).x86.s : genlib/qtype.s.gen
./$< -a x86 -n$(qtype) -i$(qtype_intbits) -f$(qtype_fracbits) -o $@
# x86_64 assembly
genlib/$(qtype).x86_64.s : genlib/qtype.s.gen
./$< -a x86_64 -n$(qtype) -i$(qtype_intbits) -f$(qtype_fracbits) -o $@
# intelmac assembly
genlib/$(qtype).intelmac.s : genlib/qtype.s.gen
./$< -a intelmac -n$(qtype) -i$(qtype_intbits) -f$(qtype_fracbits) -o $@
# genlib target : add specific routine assembly files (e.g. qtype.mul.ppc.s)
# as dependencies to ensure objects are rebuilt properly
#
# example:
# genlib/q32.ppc.o : genlib/q32.ppc.s genlib/qtype.mul.ppc.s
$(genlib_objects) : genlib/$(qtype).%.o : genlib/$(qtype).%.s genlib/qtype.mul.%.s
clean-genlib:
$(RM) $(genlib_programs)
$(RM) $(genlib_sources)
$(RM) $(genlib_objects)
#
# portlib : porable sources (those not generated automatically by genlib)
#
portlib_objects := @PORTLIBS@
portlib_sources := $(patsubst %.o,%.c,$(portlib_objects))
clean-portlib:
$(RM) $(portlib_objects)
# accumulate target-specific libraries
objects += $(gentab_objects) $(genlib_objects) $(portlib_objects)
##
## TARGET : all - build shared library (default)
##
.PHONY: all
# target-specific library definition:
# libliquidfpm.dylib (darwin)
# libliquidfpm.so (linux, et al.)
SHARED_LIB = @SH_LIB@
# rebind libraries:
# ldconfig (linux, et al.)
# No need to rebind on OS X/darwin systems
REBIND = @REBIND@
all: libliquidfpm.a $(SHARED_LIB)
##
## TARGET : help - print list of targets
##
# look for all occurences of '## TARGET : ' and print rest of line to screen
help:
@echo "Targets for liquid-dsp makefile:"
@$(GREP) -E "^## TARGET : " [Mm]akefile | $(SED) 's/## TARGET : / /'
##
## TARGET : install - installs the libraries and header files in the host system
##
install:
@echo "installing..."
mkdir -p $(libdir)
install -m 644 -p $(SHARED_LIB) libliquidfpm.a $(libdir)
$(REBIND)
mkdir -p $(prefix)/include
mkdir -p $(prefix)/include/liquid
install -m 644 -p include/liquidfpm.h $(prefix)/include/liquid
@echo ""
@echo "---------------------------------------------------------"
@echo " liquid-fpm was successfully installed. "
@echo ""
@echo " On some machines (e.g. Linux) you should rebind your"
@echo " libraries by running 'ldconfig' to make the shared"
@echo " object available. You might also need to modify your"
@echo " LD_LIBRARY_PATH environment variable to include the"
@echo " directory $(exec_prefix)"
@echo ""
@echo " Please report bugs to $(BUGREPORT)"
@echo "---------------------------------------------------------"
@echo ""
##
## TARGET : uninstall - uninstalls the libraries and header files in the host system
##
uninstall:
@echo "uninstalling..."
$(RM) $(addprefix $(prefix)/include/liquid/, $(headers_install))
$(RM) $(exec_prefix)/lib/libliquidfpm.a
$(RM) $(exec_prefix)/lib/$(SHARED_LIB)
@echo "done."
# Library definition
libliquidfpm.a: $(objects)
$(AR) $(ARFLAGS) $@ $^
$(RANLIB) $@
# darwin
libliquidfpm.dylib: $(objects)
$(CC) $(LDFLAGS) -dynamiclib -install_name $@ -o $@ $^
# linux, et al
libliquidfpm.so: libliquidfpm.a
$(CC) $(LDFLAGS) -shared -Xlinker -soname=$@ -o $@ -Wl,-whole-archive $^ -Wl,-no-whole-archive
#
# Tests (mostly for debugging)
#
test: fpmtest
./fpmtest
fpmtest.o: fpmtest.c include/liquidfpm.h
fpmtest: fpmtest.o libliquidfpm.a
$(CC) $(CFLAGS) -lm $^ $(LDFLAGS) -o $@
##
## TARGET : bench - build and run all benchmarks
##
.PHONY: bench
benchmark_headers = \
bench/q32_atan2_benchmark.h \
bench/q32_sin_benchmark.h \
bench/q32_sqrt_newton_benchmark.h \
bench/q32_log2_benchmark.h \
bench/q32_log2_shiftadd_benchmark.h
benchmarkgen_prog = benchmarkgen
benchmark_prog = benchmark
benchmark_include = benchmark_include.h
BENCH_CFLAGS = $(INCLUDE_CFLAGS)
$(benchmarkgen_prog): bench/benchmarkgen.c
$(CC) -Wall -o $@ $<
$(benchmark_include): $(benchmarkgen_prog) $(benchmark_headers)
./$(benchmarkgen_prog) $(benchmark_headers) > $@
$(benchmark_prog): bench/bench.c $(benchmark_include) libliquidfpm.a
$(CC) $(BENCH_CFLAGS) -lm $< $(LDFLAGS) libliquidfpm.a -o $@
bench: $(benchmark_prog)
./$<
clean-bench:
$(RM) $(benchmarkgen_prog) $(benchmark_prog) $(benchmark_include)
##
## TARGET : check - build and run autotest scripts
##
.PHONY: autotest
autotestgen_prog = autotestgen
autotest_prog = xautotest
autotest_include = autotest_include.h
AUTOTEST_CFLAGS = $(INCLUDE_CFLAGS)
$(autotestgen_prog): autotest/autotestgen.c $(libraries) autotest/autotest.h
$(CC) -Wall -o $@ $<
$(autotest_include): $(autotestgen_prog) $(autotest_headers)
./$(autotestgen_prog) $(autotest_headers) > $@
$(autotest_prog): autotest/autotest.c $(autotest_include) libliquidfpm.a
$(CC) $(AUTOTEST_CFLAGS) -lm $< $(LDFLAGS) libliquidfpm.a -o $@
check: $(autotest_prog)
./$<
clean-autotest:
$(RM) $(autotestgen_prog) $(autotest_prog) $(autotest_include)
##
## TARGET : clean - clean build (objects, dependencies, libraries, etc.)
##
clean: clean-bench clean-autotest clean-gentab clean-genlib
$(RM) $(objects)
$(RM) $(dependencies)
$(RM) $(SHARED_LIB)
$(RM) libliquidfpm.a
$(RM) fpmtest fpmtest.o
$(RM) $(extra_clean)
##
## TARGET : distclean - removes everything except the originally distributed files
##
distclean: clean
@echo "cleaning distribution..."
$(RM) configure config.h config.h.in config.h.in~ config.log config.status
$(RM) -r autom4te.cache
$(RM) -r autom4te.cache
$(RM) aclocal.m4
$(RM) makefile