1# ################################################################
2# Copyright (c) 2015-2020, Facebook, Inc.
3# All rights reserved.
4#
5# This source code is licensed under both the BSD-style license (found in the
6# LICENSE file in the root directory of this source tree) and the GPLv2 (found
7# in the COPYING file in the root directory of this source tree).
8# You may select, at your option, one of the above-listed licenses.
9# ################################################################
10
11CFLAGS ?= -O3
12
13CURL_CFLAGS := $(shell curl-config --cflags)
14CURL_LDFLAGS := $(shell curl-config --libs) -pthread
15
16PROGDIR := ../../programs
17LIBDIR := ../../lib
18ZSTD_CPPFLAGS := -I$(PROGDIR) -I$(LIBDIR) -I$(LIBDIR)/common
19
20REGRESSION_CFLAGS = $(CFLAGS) $(CURL_CFLAGS)
21REGRESSION_CPPFLAGS = $(CPPFLAGS) $(ZSTD_CPPFLAGS)
22REGRESSION_LDFLAGS = $(LDFLAGS) $(CURL_LDFLAGS)
23
24all: test
25
26xxhash.o: $(LIBDIR)/common/xxhash.c $(LIBDIR)/common/xxhash.h
27	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
28
29util.o: $(PROGDIR)/util.c $(PROGDIR)/util.h
30	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
31
32data.o: data.c data.h $(PROGDIR)/util.h $(LIBDIR)/common/xxhash.h
33	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
34
35config.o: config.c config.h levels.h
36	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
37
38method.h: data.h config.h result.h
39
40method.o: method.c method.h
41	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
42
43result.o: result.c result.h
44	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
45
46test.o: test.c data.h config.h method.h
47	$(CC) $(REGRESSION_CFLAGS) $(REGRESSION_CPPFLAGS) $< -c -o $@
48
49libzstd.a:
50	$(MAKE) -C $(LIBDIR) libzstd.a-mt
51	cp $(LIBDIR)/libzstd.a .
52
53test: test.o data.o config.o util.o method.o result.o xxhash.o libzstd.a
54	$(CC) $^ $(REGRESSION_LDFLAGS) -o $@
55
56.PHONY: clean
57clean:
58	$(MAKE) -C $(LIBDIR) clean
59	$(RM) *.o *.a test
60