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