Files
cdba/Makefile
Dmitry Baryshkov 2bbe855662 Makefile: adapt for libftdi vs libftdi1 differences
Use the cflags and libs from pkg-config. This allows us to adapt to the
distro differences. Also, make sure to autodetect if the distro provides
libftdi or libftdi1, preferring the latter one.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
2023-09-21 15:03:40 +03:00

52 lines
1.8 KiB
Makefile

CLIENT := cdba
SERVER := cdba-server
.PHONY: all
all: $(CLIENT) $(SERVER)
CFLAGS := -Wall -g -O2
# Wextra without few warnings
CFLAGS := $(CFLAGS) -Wextra -Wno-unused-parameter -Wno-unused-result -Wno-missing-field-initializers -Wno-sign-compare
# Few clang version still have warnings so fail only on GCC
GCC_CFLAGS := -Werror
GCC_CFLAGS += -Wformat-signedness -Wnull-dereference -Wduplicated-cond -Wduplicated-branches -Wvla-larger-than=1
GCC_CFLAGS += -Walloc-zero -Wstringop-truncation -Wdouble-promotion -Wshadow -Wunsafe-loop-optimizations
GCC_CFLAGS += -Wpointer-arith -Wcast-align -Wwrite-strings -Wlogical-op -Wstrict-overflow=4 -Wundef -Wjump-misses-init
CLANG_CFLAGS := -Wnull-dereference -Wdouble-promotion -Wshadow -Wpointer-arith -Wwrite-strings -Wstrict-overflow=4 -Wundef
# TODO:
# GCC_CFLAGS += -Wcast-qual
# CLANG_CFLAGS += -Wcast-qual -Wcast-align
ifeq ($(CC),cc)
CFLAGS += $(GCC_CFLAGS)
else ifeq ($(CC),clang)
CFLAGS += $(CLANG_CFLAGS)
else
$(info No compiler flags for: $(CC))
endif
LIBFTDI := $(shell pkg-config --exists libftdi1 && echo libftdi1 || echo libftdi)
CPPFLAGS := $(shell pkg-config --cflags yaml-0.1 $(LIBFTDI) libudev)
LDFLAGS := $(shell pkg-config --libs yaml-0.1 $(LIBFTDI) libudev)
CLIENT_SRCS := cdba.c circ_buf.c
CLIENT_OBJS := $(CLIENT_SRCS:.c=.o)
SERVER_SRCS := cdba-server.c cdb_assist.c circ_buf.c conmux.c device.c device_parser.c fastboot.c alpaca.c ftdi-gpio.c console.c qcomlt_dbg.c
SERVER_OBJS := $(SERVER_SRCS:.c=.o)
$(CLIENT): $(CLIENT_OBJS)
$(CC) $(LDFLAGS) -o $@ $^
$(SERVER): $(SERVER_OBJS)
$(CC) -o $@ $^ $(LDFLAGS)
clean:
rm -f $(CLIENT) $(CLIENT_OBJS) $(SERVER) $(SERVER_OBJS)
install: $(CLIENT) $(SERVER)
install -D -m 755 $(CLIENT) $(DESTDIR)$(prefix)/bin/$(CLIENT)
install -D -m 755 $(SERVER) $(DESTDIR)$(prefix)/bin/$(SERVER)