Subject: Re: [PATCH v2 07/12] fsmonitor: prepare to share code between Mac OS and Linux

From: Junio C Hamano <[email-masked]>
Date: Fri, 14 Oct 2022 16:46:17 -0700

"Eric DeCosta via GitGitGadget" <[email-masked]> writes:

>  ifdef FSMONITOR_DAEMON_BACKEND
>  	COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
> +	ifdef FSMONITOR_DAEMON_COMMON
> +		COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_COMMON).o
> +	else
> +		COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o
> +	endif
>  	COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
>  	COMPAT_OBJS += compat/fsmonitor/fsm-health-$(FSMONITOR_DAEMON_BACKEND).o
> -	COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o
>  endif
>  
>  ifdef FSMONITOR_OS_SETTINGS
>  	COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
> +	ifdef FSMONITOR_DAEMON_COMMON
> +		COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_DAEMON_COMMON).o
> +	endif
>  	COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
>  	COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
>  endif

Ugly.  

One overrides backend with common, while the other one doesn't.
That asymmetry alone should stop us and wonder if there is something
fishy in the approach that can be improved.  It makes it look like
the word "common" means something quite different between the -ipc
and the -settings world.

I suspect that in both, you should not expose "unix" to this part of
the Makefile.  Linux and macOS occasionally being similar in some
places does not have to be exposed here.  INstead you can use
backend "linux" and "macos", whose C sources may include from a
separate C source file whose name may contain "unix".  That would
allow you to get rid of FSMONITOR_DAEMON_COMMON in a cleaner way.