blob: fbcffca56b7e84be40c9c308b3b9f1772c86e47a [file] [log] [blame]
David Carliere9cff612022-01-21 20:46:40 +00001# DEVICEATLAS_SRC : DeviceAtlas API source root path
2
3
4OS := $(shell uname -s)
5OBJS := dadwsch.o
6CFLAGS := -g -O2
7LDFLAGS :=
8
9CURL_CONFIG := curl-config
10CURLDIR := $(shell $(CURL_CONFIG) --prefix 2>/dev/null || echo /usr/local)
11CURL_INC := $(CURLDIR)/include
12CURL_LIB := $(CURLDIR)/lib
13CURL_LDFLAGS := $(shell $(CURL_CONFIG) --libs 2>/dev/null || echo -L /usr/local/lib -lcurl)
14
15PCRE2_CONFIG := pcre2-config
16PCRE2DIR := $(shell $(PCRE2_CONFIG) --prefix 2>/dev/null || echo /usr/local)
17PCRE2_INC := $(PCRE2DIR)/include
18PCRE2_LIB := $(PCRE2DIR)/lib
19PCRE2_LDFLAGS := $(shell $(PCRE2_CONFIG) --libs8 2>/dev/null || echo /usr/local)
20
21ifeq ($(DEVICEATLAS_SRC),)
22dadwsch: dadwsch.c
23 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
24
25LDFLAGS += -lda
26else
27DEVICEATLAS_INC = $(DEVICEATLAS_SRC)
28DEVICEATLAS_LIB = $(DEVICEATLAS_SRC)
29CFLAGS += -DDA_REGEX_HDR=\"dac_pcre2.c\" -DDA_REGEX_TAG=2
30CFLAGS += -DMOBI_CURL -DMOBI_CURLSSET -DMOBI_GZ -DMOBI_ZIP
31CFLAGS += -I$(DEVICEATLAS_INC) -I$(CURL_INC) -I$(PCRE2DIR)
32LDFLAGS += $(CURL_LDFLAGS) $(PCRE2_LDFLAGS) -lz -lzip -lpthread
33
34dadwsch: dadwsch.c $(DEVICEATLAS_SRC)/dac.c $(DEVICEATLAS_SRC)/dasch.c $(DEVICEATLAS_SRC)/dadwarc.c $(DEVICEATLAS_SRC)/dadwcom.c $(DEVICEATLAS_SRC)/dadwcurl.c $(DEVICEATLAS_SRC)/json.c $(DEVICEATLAS_SRC)/Os/daunix.c
35 $(CC) $(CFLAGS) -o $@ $^ $(LDFLAGS)
36endif
37
38ifeq ($(OS), Linux)
39LDFLAGS += -lrt
40endif
41ifeq ($(OS), SunOS)
42LDFLAGS += -lrt
43endif
44
45clean:
46 rm -f *.o
47 rm -f $(DEVICEATLAS_LIB)*.o
48 rm -f dadwsch