AqualinkD/Makefile

430 lines
11 KiB
Makefile
Raw Normal View History

2023-06-20 00:15:45 +00:00
#
# Options
#
2023-06-23 20:16:30 +00:00
# make // standard build aqualinkd and serial_logger
# make debug // Compule standard aqualinkd binary just with debugging
2023-06-20 00:15:45 +00:00
# make aqdebug // Compile with extra aqualink debug information like timings
# make slog // Serial logger
# make <other> // not documenting
2023-06-20 00:15:45 +00:00
#
# Valid flags for AQ_FLAGS
AQ_RS16 = true
AQ_PDA = true
AQ_ONETOUCH = true
AQ_IAQTOUCH = true
2024-03-30 16:51:31 +00:00
AQ_MANAGER =true
AQ_RS_EXTRA_OPTS = false
2023-06-20 00:15:45 +00:00
#AQ_MEMCMP = true // Not implimented correctly yet.
# Turn off threadded net services
AQ_NO_THREAD_NETSERVICE = false
# define the C compiler to use
CC = gcc
#LIBS := -lpthread -lm
2023-06-23 20:16:30 +00:00
#LIBS := -l pthread -l m
2023-06-20 00:15:45 +00:00
#LIBS := -l pthread -l m -static # Take out -static, just for dev
2023-06-23 20:16:30 +00:00
LIBS := -lpthread -lm
2023-06-20 00:15:45 +00:00
# Standard compile flags
GCCFLAGS = -Wall -O3
#GCCFLAGS = -O3
#GCCFLAGS = -Wall -O3 -Wextra
#GCCFLAGS = -Wl,--gc-sections,--print-gc-sections
#GCCFLAGS = -Wall -O3 -ffunction-sections -fdata-sections
# Standard debug flags
DGCCFLAGS = -Wall -O0 -g
# Aqualink Debug flags
#DBGFLAGS = -g -O0 -Wall -fsanitize=address -D AQ_DEBUG -D AQ_TM_DEBUG
DBGFLAGS = -g -O0 -Wall -D AQ_DEBUG -D AQ_TM_DEBUG
# Mongoose flags
#MGFLAGS = -D MG_DISABLE_MD5 -D MG_DISABLE_HTTP_DIGEST_AUTH -D MG_DISABLE_MD5 -D MG_DISABLE_JSON_RPC
# Mongoose 6.18 flags
MGFLAGS = -D MG_ENABLE_HTTP_SSI=0 -D MG_ENABLE_DIRECTORY_LISTING=0 -D MG_ENABLE_HTTP_CGI=0
#MGFLAGS =
2023-06-20 00:15:45 +00:00
# Detect OS and set some specifics
ifeq ($(OS),Windows_NT)
# Windows Make.
MKDIR = mkdir
FixPath = $(subst /,\,$1)
2023-06-20 00:15:45 +00:00
else
UNAME_S := $(shell uname -s)
# Linux
ifeq ($(UNAME_S),Linux)
MKDIR = mkdir -p
FixPath = $1
2023-06-20 00:15:45 +00:00
# Get some system information
PI_OS_VERSION = $(shell cat /etc/os-release | grep VERSION= | cut -d\" -f2)
$(info OS: $(PI_OS_VERSION) )
GLIBC_VERSION = $(shell ldd --version | grep ldd)
$(info GLIBC build with: $(GLIBC_VERSION) )
$(info GLIBC Prefered : 2.24-11+deb9u1 2.24 )
endif
# OSX
ifeq ($(UNAME_S),Darwin)
endif
endif
# Main source files
SRCS = aqualinkd.c utils.c config.c aq_serial.c aq_panel.c aq_programmer.c net_services.c json_messages.c rs_msg_utils.c\
devices_jandy.c packetLogger.c devices_pentair.c color_lights.c serialadapter.c aq_timer.c aq_scheduler.c web_config.c\
2024-03-30 16:51:31 +00:00
serial_logger.c mongoose.c timespec_subtract.c
2023-06-20 00:15:45 +00:00
AQ_FLAGS =
2023-06-20 00:15:45 +00:00
# Add source and flags depending on protocols to support.
ifeq ($(AQ_PDA), true)
SRCS := $(SRCS) pda.c pda_menu.c pda_aq_programmer.c
AQ_FLAGS := $(AQ_FLAGS) -D AQ_PDA
endif
ifeq ($(AQ_ONETOUCH), true)
SRCS := $(SRCS) onetouch.c onetouch_aq_programmer.c
AQ_FLAGS := $(AQ_FLAGS) -D AQ_ONETOUCH
endif
ifeq ($(AQ_IAQTOUCH), true)
SRCS := $(SRCS) iaqtouch.c iaqtouch_aq_programmer.c
AQ_FLAGS := $(AQ_FLAGS) -D AQ_IAQTOUCH
endif
ifeq ($(AQ_RS16), true)
AQ_FLAGS := $(AQ_FLAGS) -D AQ_RS16
endif
ifeq ($(AQ_MEMCMP), true)
AQ_FLAGS := $(AQ_FLAGS) -D AQ_MEMCMP
endif
2023-06-23 20:16:30 +00:00
ifeq ($(AQ_MANAGER), true)
AQ_FLAGS := $(AQ_FLAGS) -D AQ_MANAGER
LIBS := $(LIBS) -lsystemd
# aq_manager requires threads, so make sure that's turned on.
ifeq ($(AQ_NO_THREAD_NETSERVICE), true)
# Show error
$(warning AQ_MANAGER requires threads, ignoring AQ_NO_THREAD_NETSERVICE)
endif
else
# No need for serial_logger without aq_manager
SRCS := $(filter-out serial_logger.c, $(SRCS))
# no threadded net service only valid without aq manager.
ifeq ($(AQ_NO_THREAD_NETSERVICE), true)
AQ_FLAGS := $(AQ_FLAGS) -D AQ_NO_THREAD_NETSERVICE
endif
2023-06-20 00:15:45 +00:00
endif
# Put all flags together.
CFLAGS = $(GCCFLAGS) $(AQ_FLAGS) $(MGFLAGS)
DFLAGS = $(DGCCFLAGS) $(AQ_FLAGS) $(MGFLAGS)
DBG_CFLAGS = $(DBGFLAGS) $(AQ_FLAGS) $(MGFLAGS)
# Other sources.
DBG_SRC = $(SRCS) debug_timer.c
2024-03-30 16:51:31 +00:00
SL_SRC = serial_logger.c aq_serial.c utils.c packetLogger.c rs_msg_utils.c timespec_subtract.c
2023-06-20 00:15:45 +00:00
# Build durectories
OBJ_DIR := ./build
DBG_OBJ_DIR := $(OBJ_DIR)/debug
SL_OBJ_DIR := $(OBJ_DIR)/slog
# Object files
OBJ_FILES := $(patsubst %.c,$(OBJ_DIR)/%.o,$(SRCS))
DBG_OBJ_FILES := $(patsubst %.c,$(DBG_OBJ_DIR)/%.o,$(DBG_SRC))
SL_OBJ_FILES := $(patsubst %.c,$(SL_OBJ_DIR)/%.o,$(SL_SRC))
# define the executable file
MAIN = ./release/aqualinkd
SLOG = ./release/serial_logger
DEBG = ./release/aqualinkd-debug
#LOGR = ./release/log_reader
#PLAY = ./release/aqualinkd-player
# Rules to pass to make.
all: $(MAIN) $(SLOG)
$(info $(MAIN) has been compiled)
$(info $(SLOG) has been compiled)
slog: $(SLOG)
$(info $(SLOG) has been compiled)
aqdebug: $(DEBG)
$(info $(DEBG) has been compiled)
#debug, Just change compile flags and call MAIN
debug: CFLAGS = $(DFLAGS)
debug: $(MAIN) $(SLOG)
$(info $(MAIN) has been compiled (** DEBUG **))
$(info $(SLOG) has been compiled (** DEBUG **))
install: $(MAIN)
./release/install.sh
# Rules to compile
$(OBJ_DIR)/%.o: %.c | $(OBJ_DIR)
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
$(DBG_OBJ_DIR)/%.o: %.c | $(DBG_OBJ_DIR)
$(CC) $(DBG_CFLAGS) $(INCLUDES) -c -o $@ $<
$(SL_OBJ_DIR)/%.o: %.c | $(SL_OBJ_DIR)
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
# Rules to link
$(MAIN): $(OBJ_FILES)
2023-06-20 03:23:22 +00:00
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LIBS)
2023-06-20 00:15:45 +00:00
$(DEBG): $(DBG_OBJ_FILES)
2023-06-20 03:23:22 +00:00
$(CC) $(DBG_CFLAGS) $(INCLUDES) -o $@ $^ $(LIBS)
2023-06-20 00:15:45 +00:00
$(SLOG): CFLAGS := $(CFLAGS) -D SERIAL_LOGGER
$(SLOG): $(SL_OBJ_FILES)
2023-06-20 03:23:22 +00:00
$(CC) $(CFLAGS) $(INCLUDES) -o $@ $^ $(LIBS)
2023-06-20 00:15:45 +00:00
# Rules to make object directories.
$(OBJ_DIR):
$(MKDIR) $(call FixPath,$@)
2023-06-20 00:15:45 +00:00
$(SL_OBJ_DIR):
$(MKDIR) $(call FixPath,$@)
2023-06-20 00:15:45 +00:00
$(DBG_OBJ_DIR):
$(MKDIR) $(call FixPath,$@)
2023-06-20 00:15:45 +00:00
# Clean rules
.PHONY: clean
clean:
$(RM) *.o *~ $(MAIN) $(MAIN_U) $(PLAY) $(PL_EXOBJ) $(DEBG)
$(RM) $(wildcard *.o) $(wildcard *~) $(OBJ_FILES) $(DBG_OBJ_FILES) $(SL_OBJ_FILES) $(MAIN) $(MAIN_U) $(PLAY) $(PL_EXOBJ) $(LOGR) $(PLAY) $(DEBG)
define DO_NOT_USE
# OLD MAKEFILE, STILL NEED TO MOVE THE BELOW OVER TO NEW Makefile
LOGR = ./release/log_reader
PLAY = ./release/aqualinkd-player
2019-07-14 14:39:15 +00:00
#
# Options
2020-07-26 19:28:58 +00:00
#
# make // standard everything
# make debug // Give standard binary just with debugging
# make aqdebug // Compile with extra aqualink debug information like timings
# make slog // Serial logger
# make <other> // not documenting
2020-07-26 19:28:58 +00:00
#
2020-06-20 16:09:54 +00:00
# Valid flags for AQ_FLAGS
AQ_RS16 = true
AQ_PDA = true
2020-07-18 16:37:19 +00:00
AQ_ONETOUCH = true
AQ_IAQTOUCH = true
#AQ_MEMCMP = true // Not implimented correctly yet.
2020-06-20 16:09:54 +00:00
2023-06-04 21:17:48 +00:00
# Turn off threadded net services
AQ_NO_THREAD_NETSERVICE = false
2020-07-26 19:28:58 +00:00
# Get some system information
PI_OS_VERSION = $(shell cat /etc/os-release | grep VERSION= | cut -d\" -f2)
$(info OS: $(PI_OS_VERSION) )
GLIBC_VERSION = $(shell ldd --version | grep ldd)
2023-05-14 21:35:13 +00:00
$(info GLIBC build with: $(GLIBC_VERSION) )
$(info GLIBC Prefered : 2.24-11+deb9u1 2.24 )
2020-06-20 16:09:54 +00:00
2017-12-30 20:12:01 +00:00
# define the C compiler to use
CC = gcc
2019-08-25 20:57:51 +00:00
#LIBS := -lpthread -lm
LIBS := -l pthread -l m
2020-07-26 19:28:58 +00:00
#LIBS := -l pthread -l m -static # Take out -static, just for dev
2017-12-30 20:12:01 +00:00
2020-07-26 19:28:58 +00:00
# Standard compile flags
GCCFLAGS = -Wall -O3
#GCCFLAGS = -O3
2019-06-05 16:41:38 +00:00
#GCCFLAGS = -Wall -O3 -Wextra
2020-07-26 19:28:58 +00:00
#GCCFLAGS = -Wl,--gc-sections,--print-gc-sections
#GCCFLAGS = -Wall -O3 -ffunction-sections -fdata-sections
# Standard debug flags
DGCCFLAGS = -Wall -O0 -g
2018-08-25 20:13:33 +00:00
2020-07-26 19:28:58 +00:00
# Aqualink Debug flags
#DBGFLAGS = -g -O0 -Wall -fsanitize=address -D AQ_DEBUG -D AQ_TM_DEBUG
DBGFLAGS = -g -O0 -Wall -D AQ_DEBUG -D AQ_TM_DEBUG
2017-12-30 20:12:01 +00:00
2020-07-26 19:28:58 +00:00
# Mongoose flags
2023-06-20 00:15:45 +00:00
#MGFLAGS = -D MG_DISABLE_MD5 -D MG_DISABLE_HTTP_DIGEST_AUTH -D MG_DISABLE_MD5 -D MG_DISABLE_JSON_RPC
# Mongoose 6.18 flags
MGFLAGS = -D MG_ENABLE_HTTP_SSI=0 -D MG_ENABLE_DIRECTORY_LISTING=0 -D MG_ENABLE_HTTP_CGI=0
2023-06-05 01:26:39 +00:00
#MGFLAGS =
2017-12-30 20:12:01 +00:00
# define the C source files
2020-06-20 16:09:54 +00:00
#SRCS = aqualinkd.c utils.c config.c aq_serial.c init_buttons.c aq_programmer.c net_services.c json_messages.c pda.c pda_menu.c \
# pda_aq_programmer.c devices_jandy.c onetouch.c onetouch_aq_programmer.c packetLogger.c devices_pentair.c color_lights.c mongoose.c
2020-07-18 16:37:19 +00:00
SRCS = aqualinkd.c utils.c config.c aq_serial.c aq_panel.c aq_programmer.c net_services.c json_messages.c rs_msg_utils.c\
2023-06-20 00:15:45 +00:00
devices_jandy.c packetLogger.c devices_pentair.c color_lights.c serialadapter.c aq_timer.c aq_scheduler.c web_config.c\
mongoose.c
2019-06-27 22:18:44 +00:00
2020-07-26 19:28:58 +00:00
AQ_FLAGS =
# Add source and flags depending on protocols to support.
2020-06-20 16:09:54 +00:00
ifeq ($(AQ_PDA), true)
SRCS := $(SRCS) pda.c pda_menu.c pda_aq_programmer.c
2020-07-26 19:28:58 +00:00
AQ_FLAGS := $(AQ_FLAGS) -D AQ_PDA
2020-06-20 16:09:54 +00:00
endif
2020-07-18 16:37:19 +00:00
ifeq ($(AQ_ONETOUCH), true)
SRCS := $(SRCS) onetouch.c onetouch_aq_programmer.c
2020-07-26 19:28:58 +00:00
AQ_FLAGS := $(AQ_FLAGS) -D AQ_ONETOUCH
2020-07-18 16:37:19 +00:00
endif
ifeq ($(AQ_IAQTOUCH), true)
SRCS := $(SRCS) iaqtouch.c iaqtouch_aq_programmer.c
2020-07-26 19:28:58 +00:00
AQ_FLAGS := $(AQ_FLAGS) -D AQ_IAQTOUCH
2020-07-18 16:37:19 +00:00
endif
2020-06-20 16:09:54 +00:00
ifeq ($(AQ_RS16), true)
2020-07-26 19:28:58 +00:00
AQ_FLAGS := $(AQ_FLAGS) -D AQ_RS16
2020-06-20 16:09:54 +00:00
endif
2020-07-18 16:37:19 +00:00
ifeq ($(AQ_MEMCMP), true)
2020-07-26 19:28:58 +00:00
AQ_FLAGS := $(AQ_FLAGS) -D AQ_MEMCMP
2020-07-18 16:37:19 +00:00
endif
2023-06-04 21:17:48 +00:00
ifeq ($(AQ_NO_THREAD_NETSERVICE), true)
AQ_FLAGS := $(AQ_FLAGS) -D AQ_NO_THREAD_NETSERVICE
endif
2020-07-26 19:28:58 +00:00
# Put all flags together.
CFLAGS = $(GCCFLAGS) $(AQ_FLAGS) $(MGFLAGS)
DFLAGS = $(DGCCFLAGS) $(AQ_FLAGS) $(MGFLAGS)
DBG_CFLAGS = $(DBGFLAGS) $(AQ_FLAGS) $(MGFLAGS)
2017-12-30 20:12:01 +00:00
2020-07-26 19:28:58 +00:00
# Other sources.
#DBG_SRC = timespec_subtract.c debug_timer.c
DBG_SRC = debug_timer.c
2020-07-18 16:37:19 +00:00
SL_SRC = serial_logger.c aq_serial.c utils.c packetLogger.c rs_msg_utils.c
2019-10-16 22:53:09 +00:00
LR_SRC = log_reader.c aq_serial.c utils.c packetLogger.c
2019-05-31 23:08:45 +00:00
PL_EXSRC = aq_serial.c
2019-06-07 21:31:06 +00:00
PL_EXOBJ = aq_serial_player.o
2019-05-31 23:08:45 +00:00
PL_SRC := $(filter-out aq_serial.c, $(SRCS))
2018-03-15 20:03:57 +00:00
2017-12-30 20:12:01 +00:00
OBJS = $(SRCS:.c=.o)
2020-07-26 19:28:58 +00:00
DBG_OBJS = $(DBG_SRC:.c=.o)
2019-05-31 23:08:45 +00:00
2018-03-15 20:03:57 +00:00
SL_OBJS = $(SL_SRC:.c=.o)
2019-05-31 23:08:45 +00:00
LR_OBJS = $(LR_SRC:.c=.o)
PL_OBJS = $(PL_SRC:.c=.o)
2017-12-30 20:12:01 +00:00
2023-06-20 00:15:45 +00:00
2017-12-30 20:12:01 +00:00
# define the executable file
MAIN = ./release/aqualinkd
2018-03-15 20:03:57 +00:00
SLOG = ./release/serial_logger
2019-05-31 23:08:45 +00:00
LOGR = ./release/log_reader
PLAY = ./release/aqualinkd-player
2020-07-26 19:28:58 +00:00
DEBG = ./release/aqualinkd-debug
2017-12-30 20:12:01 +00:00
2023-06-20 00:15:45 +00:00
all: $(MAIN) $(SLOG)
2020-07-26 19:28:58 +00:00
$(info $(MAIN) has been compiled)
2023-06-20 00:15:45 +00:00
$(info $(SLOG) has been compiled)
2020-07-26 19:28:58 +00:00
# debug, Just change compile flags and call MAIN
debug: CFLAGS = $(DFLAGS)
debug: $(MAIN)
$(info $(MAIN) has been compiled)
2017-12-30 20:12:01 +00:00
$(MAIN): $(OBJS)
2020-07-26 19:28:58 +00:00
$(CC) $(CFLAGS) $(INCLUDES) -o $(MAIN) $(OBJS) $(LIBS)
$(info $(MAIN) has been compiled)
2017-12-30 20:12:01 +00:00
2018-03-15 20:03:57 +00:00
slog: $(SLOG)
2020-07-26 19:28:58 +00:00
$(info $(SLOG) has been compiled)
2018-03-15 20:03:57 +00:00
2020-07-26 19:28:58 +00:00
$(SLOG): CFLAGS := $(CFLAGS) -D SERIAL_LOGGER
2018-03-15 20:03:57 +00:00
$(SLOG): $(SL_OBJS)
2023-06-20 00:15:45 +00:00
# $(CC) $(CFLAGS) $(INCLUDES) -o $(SLOG) $(SL_OBJS)
$(CC) $(INCLUDES) -o $(SLOG) $(SL_OBJS)
2020-07-26 19:28:58 +00:00
2020-08-30 17:36:58 +00:00
#.PHONY: clean_slog_o
#clean_slog_o:
# $(RM) $(SL_OBJS)
#
#.PHONY: test
#test: $(SLOG)
#test: clean_slog_o
#test: $(MAIN)
2020-07-26 19:28:58 +00:00
# Shouldn't need to use any of these options unless you're developing.
aqdebug: $(DEBG)
$(info $(DEBG) has been compiled)
$(DEBG): CFLAGS = $(DBG_CFLAGS)
$(DEBG): $(OBJS) $(DBG_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(DEBG) $(OBJS) $(DBG_OBJS) $(DBGFLAGS) $(LIBS)
2018-03-15 20:03:57 +00:00
2019-05-31 23:08:45 +00:00
logr: $(LOGR)
2020-07-26 19:28:58 +00:00
$(info $(LOGR) has been compiled)
2018-09-02 21:45:24 +00:00
2019-05-31 23:08:45 +00:00
$(LOGR): $(LR_OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -o $(LOGR) $(LR_OBJS)
2018-09-02 21:45:24 +00:00
2019-05-31 23:08:45 +00:00
player: $(PLAY)
2020-07-26 19:28:58 +00:00
$(info $(PLAY) has been compiled)
2018-09-02 21:45:24 +00:00
2019-06-07 21:31:06 +00:00
$(PL_EXOBJ): $(PL_EXSRC)
$(CC) $(CFLAGS) -D PLAYBACK_MODE $(INCLUDES) -c $(PL_EXSRC) -o $(PL_EXOBJ)
2018-04-18 00:33:17 +00:00
2019-06-07 21:31:06 +00:00
$(PLAY): $(PL_OBJS) $(PL_EXOBJ)
$(CC) $(CFLAGS) $(INCLUDES) -o $(PLAY) $(PL_OBJS) $(PL_EXOBJ)
2020-08-28 19:12:38 +00:00
# Fof github publishing
2019-06-29 14:52:41 +00:00
.PHONY: git
git: clean $(MAIN) $(SLOG)
./release/git_version.sh
2017-12-30 20:12:01 +00:00
# this is a suffix replacement rule for building .o's from .c's
# it uses automatic variables $<: the name of the prerequisite of
# the rule(a .c file) and $@: the name of the target of the rule (a .o file)
# (see the gnu make manual section about automatic variables)
.c.o:
2023-06-20 00:15:45 +00:00
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
2017-12-30 20:12:01 +00:00
2019-06-29 14:52:41 +00:00
.PHONY: clean
2017-12-30 20:12:01 +00:00
clean:
2020-07-26 19:28:58 +00:00
$(RM) *.o *~ $(MAIN) $(MAIN_U) $(PLAY) $(PL_EXOBJ) $(DEBG)
$(RM) $(wildcard *.o) $(wildcard *~) $(MAIN) $(MAIN_U) $(PLAY) $(PL_EXOBJ) $(LOGR) $(PLAY) $(DEBG)
2017-12-30 20:12:01 +00:00
depend: $(SRCS)
makedepend $(INCLUDES) $^
install: $(MAIN)
./release/install.sh
2019-05-31 23:08:45 +00:00
2023-06-20 00:15:45 +00:00
endef