Repository: redis/redis

Issue:
Exclude port.h, sys/event.h
 I faced with build issue during building Redis with ICC:
```
$ icc --version
icc (ICC) 2021.5.0 20211109
Copyright (C) 1985-2021 Intel Corporation.  All rights reserved.
$ CC=icc CXX=icpc make
cd src && make all
make[1]: Entering directory '/home/mmarkova/Work/redis_icc/src'
    CC Makefile.dep
Makefile.dep:11: *** target pattern contains no '%'.  Stop.
make[1]: Leaving directory '/home/mmarkova/Work/redis_icc/src'
make: *** [Makefile:6: all] Error 2
```
Fail reason which I've found - files "port.h" and "sys/event.h" are absent on my system. I am using Ubuntu 20.4. 
So, to fix this particular issue is enough to add check for used compiler before these files including. 

However, issue and possible fix can be wider. I've found that w/o these 2 "includes" GCC and Clang also build Redis successfully. Basically looks like these includes are ignored by GCC and Clang too on Ubuntu, but build process is not fail due to difference in processing. 
As alternative way I see:
1) Excluding these files on Ubuntu (if they are required on other platforms)
2) Excluding there files at all (if they are not really needed)

Could you please revise necessity of these 2 includes in for redis build?
#include <port.h>
#include <sys/event.h>



Discussion:
The files you modified aren't even compiled (unused) on Ubuntu. The problem seems to be with the dependency calculation. 
@yossigo please take a look
If the problem is dependencies (because it uses `*.c`), I think a better approach would be to apply something like this:

```diff
diff --git a/src/Makefile b/src/Makefile
index 2a0d74d82..278b6afb1 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -323,6 +323,7 @@ REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX)
 REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o
 REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX)
 REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX)
+ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ)))
 
 all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME)
        @echo ""
@@ -330,7 +331,7 @@ all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCH
        @echo ""
 
 Makefile.dep:
-       -$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true
+       -$(REDIS_CC) -MM $(ALL_SOURCES) > Makefile.dep 2> /dev/null || true
 
 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
 -include Makefile.dep
```

@MarkovaMaria Can you confirm that this address the issue on your side?
By the way, @oranagra do you happen to remember why we even have `Makefile.dep` after introducing the `*.d` dependency handling improvement?
@yossigo i have no clue.. not my domain.
> If the problem is dependencies (because it uses `*.c`), I think a better approach would be to apply something like this:
> 
> ```diff
> diff --git a/src/Makefile b/src/Makefile
> index 2a0d74d82..278b6afb1 100644
> --- a/src/Makefile
> +++ b/src/Makefile
> @@ -323,6 +323,7 @@ REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX)
>  REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o
>  REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX)
>  REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX)
> +ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ)))
>  
>  all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME)
>         @echo ""
> @@ -330,7 +331,7 @@ all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCH
>         @echo ""
>  
>  Makefile.dep:
> -       -$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true
> +       -$(REDIS_CC) -MM $(ALL_SOURCES) > Makefile.dep 2> /dev/null || true
>  
>  ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
>  -include Makefile.dep
> ```
> 
> @MarkovaMaria Can you confirm that this address the issue on your side? By the way, @oranagra do you happen to remember why we even have `Makefile.dep` after introducing the `*.d` dependency handling improvement?

Yes, this change address the issue. Build is successful with ICC then. 

Patch:
diff --git a/src/Makefile b/src/Makefile
index 2a0d74d8270..278b6afb18d 100644
--- a/src/Makefile
+++ b/src/Makefile
@@ -323,6 +323,7 @@ REDIS_BENCHMARK_NAME=redis-benchmark$(PROG_SUFFIX)
 REDIS_BENCHMARK_OBJ=ae.o anet.o redis-benchmark.o adlist.o dict.o zmalloc.o redisassert.o release.o crcspeed.o crc64.o siphash.o crc16.o monotonic.o cli_common.o mt19937-64.o
 REDIS_CHECK_RDB_NAME=redis-check-rdb$(PROG_SUFFIX)
 REDIS_CHECK_AOF_NAME=redis-check-aof$(PROG_SUFFIX)
+ALL_SOURCES=$(sort $(patsubst %.o,%.c,$(REDIS_SERVER_OBJ) $(REDIS_CLI_OBJ) $(REDIS_BENCHMARK_OBJ)))
 
 all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCHMARK_NAME) $(REDIS_CHECK_RDB_NAME) $(REDIS_CHECK_AOF_NAME)
 	@echo ""
@@ -330,7 +331,7 @@ all: $(REDIS_SERVER_NAME) $(REDIS_SENTINEL_NAME) $(REDIS_CLI_NAME) $(REDIS_BENCH
 	@echo ""
 
 Makefile.dep:
-	-$(REDIS_CC) -MM *.c > Makefile.dep 2> /dev/null || true
+	-$(REDIS_CC) -MM $(ALL_SOURCES) > Makefile.dep 2> /dev/null || true
 
 ifeq (0, $(words $(findstring $(MAKECMDGOALS), $(NODEPS))))
 -include Makefile.dep