Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup mk/re.mk #58

Merged
merged 8 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 9 additions & 62 deletions mk/re.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,28 @@ ifeq ($(CC),cc)
CC := gcc
endif
LD := $(CC)
CC_LONGVER := $(shell if $(CC) -v 2>/dev/null; then \
$(CC) -v 2>&1 ;\
else \
$(CC) -V 2>&1 ; \
fi )
CC_LONGVER := $(shell $(CC) - --version|head -n 1)

# find-out the compiler's name

ifneq (,$(findstring gcc, $(CC_LONGVER)))
CC_NAME := gcc
CC_VER := $(word 1,$(CC)) $(shell $(CC) - --version|head -n 1|\
cut -d" " -f 3|\
sed -e 's/^.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/'\
-e 's/^[^0-9].*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/')
# sun sed is a little brain damaged => this complicated expression
CC_SHORTVER := $(shell echo "$(CC_LONGVER)"| \
sed -e 's/.* \([0-9]*\.[0-9]\).*/\1/g')
CC_VER := $(CC) $(CC_SHORTVER)
MKDEP := $(CC) -MM
#transform gcc version into 2.9x, 3.x or 4.x
CC_SHORTVER := $(shell echo "$(CC_VER)" | cut -d" " -f 2| \
sed -e 's/[^0-9]*-\(.*\)/\1/'| \
sed -e 's/2\.9.*/2.9x/' -e 's/3\.[0-3]\..*/3.0/' -e \
's/3\.[0-3]/3.0/' -e 's/3\.[4-9]\..*/3.4/' -e\
's/3\.[4-9]/3.4/' -e 's/4\.[0-9]\..*/4.x/' -e\
's/4\.[0-9]/4.x/' )
endif

ifeq ($(CC_NAME),)
ifneq (,$(findstring clang, $(CC_LONGVER)))
CC_NAME := clang
CC_SHORTVER := $(shell echo "$(CC_LONGVER)"|head -n 1| \
sed -e 's/.*version \([0-9]\.[0-9]\).*/\1/g' )
CC_SHORTVER := $(shell echo "$(CC_LONGVER)"| \
sed -e 's/.* \([0-9]*\.[0-9]\).*/\1/g')
CC_VER := $(CC) $(CC_SHORTVER)
MKDEP := $(CC) -MM
endif
endif

ifeq ($(CC_NAME),)
ifneq (, $(findstring Sun, $(CC_LONGVER)))
CC_NAME := suncc
CC_SHORTVER := $(shell echo "$(CC_LONGVER)"|head -n 1| \
sed -e 's/.*\([0-9]\.[0-9]\).*/\1/g' )
CC_VER := $(CC) $(CC_SHORTVER)
MKDEP := $(CC) -xM1
endif
endif

ifeq ($(CC_NAME),)
ifneq (, $(findstring Intel(R) C++ Compiler, $(CC_LONGVER)))
# very nice: gcc compatible
CC_NAME := icc
CC_FULLVER := $(shell echo "$(CC_LONGVER)"|head -n 1| \
sed -e 's/.*Version \([0-9]\.[0-9]\.[0-9]*\).*/\1/g')
CC_SHORTVER := $(shell echo "$(CC_FULLVER)" | cut -d. -f1,2 )
CC_VER := $(CC) $(CC_FULLVER)
MKDEP := $(CC) -MM
endif
endif


ifeq (,$(CC_NAME))
#not found
Expand All @@ -144,12 +109,13 @@ ifeq (,$(CC_NAME))
CC_VER := unknown
MKDEP := gcc -MM
$(warning Unknown compiler $(CC)\; supported compilers: \
gcc, clang, sun cc, intel icc )
gcc, clang)
endif


# Compiler warning flags
CFLAGS += -Wall
CFLAGS += -Wextra
CFLAGS += -Wmissing-declarations
CFLAGS += -Wmissing-prototypes
CFLAGS += -Wstrict-prototypes
Expand All @@ -159,13 +125,8 @@ CFLAGS += -Wnested-externs
CFLAGS += -Wshadow
CFLAGS += -Waggregate-return
CFLAGS += -Wcast-align


ifeq ($(CC_SHORTVER),4.x)
CFLAGS += -Wextra
CFLAGS += -Wold-style-definition
CFLAGS += -Wdeclaration-after-statement
endif

CFLAGS += -g
ifneq ($(OPT_SPEED),)
Expand All @@ -179,17 +140,11 @@ endif

ifneq ($(OPTIMIZE),)
CFLAGS += -Wuninitialized
ifneq ($(CC_SHORTVER), 2.9x)
CFLAGS += -Wno-strict-aliasing
endif
endif

# Compiler dependency flags
ifeq ($(CC_SHORTVER), 2.9x)
DFLAGS = -MD
else
DFLAGS = -MD -MF $(@:.o=.d) -MT $@
endif
DFLAGS = -MD -MF $(@:.o=.d) -MT $@


##############################################################################
Expand Down Expand Up @@ -343,16 +298,8 @@ endif

CFLAGS += -DOS=\"$(OS)\"

ifeq ($(CC_SHORTVER),2.9x)
CFLAGS += -Wno-long-long
else
CFLAGS += -std=c99
PEDANTIC := 1
endif # CC_SHORTVER

ifneq ($(PEDANTIC),)
CFLAGS += -pedantic
endif


ifeq ($(OS),)
Expand Down
22 changes: 11 additions & 11 deletions src/hash/func.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,17 +315,17 @@ static uint32_t hashlittle( const void *key, size_t length, uint32_t initval)
/* all the case statements fall through */
switch (length) {

case 12: c+=((uint32_t)k[11])<<24;
case 11: c+=((uint32_t)k[10])<<16;
case 10: c+=((uint32_t)k[9])<<8;
case 9 : c+=k[8];
case 8 : b+=((uint32_t)k[7])<<24;
case 7 : b+=((uint32_t)k[6])<<16;
case 6 : b+=((uint32_t)k[5])<<8;
case 5 : b+=k[4];
case 4 : a+=((uint32_t)k[3])<<24;
case 3 : a+=((uint32_t)k[2])<<16;
case 2 : a+=((uint32_t)k[1])<<8;
case 12: c+=((uint32_t)k[11])<<24; /* fall through */
case 11: c+=((uint32_t)k[10])<<16; /* fall through */
case 10: c+=((uint32_t)k[9])<<8; /* fall through */
case 9 : c+=k[8]; /* fall through */
case 8 : b+=((uint32_t)k[7])<<24; /* fall through */
case 7 : b+=((uint32_t)k[6])<<16; /* fall through */
case 6 : b+=((uint32_t)k[5])<<8; /* fall through */
case 5 : b+=k[4]; /* fall through */
case 4 : a+=((uint32_t)k[3])<<24; /* fall through */
case 3 : a+=((uint32_t)k[2])<<16; /* fall through */
case 2 : a+=((uint32_t)k[1])<<8; /* fall through */
case 1 : a+=k[0];
break;
case 0 : return c;
Expand Down
3 changes: 2 additions & 1 deletion src/http/request.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,9 @@ static int send_req(struct http_reqconn *conn, const struct pl *auth)
conn->body ? strlen(conn->body) : 0,
auth ? "with" : "without");

if (auth)
if (auth) {
DEBUG_INFO("auth=|%r|\n", auth);
}

#if (DEBUG_LEVEL >= 7)
if (conn->body) {
Expand Down
4 changes: 2 additions & 2 deletions src/main/openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,9 @@ static void sigpipe_handler(int x)

int openssl_init(void)
{
int err;
#if defined (HAVE_PTHREAD) && (OPENSSL_VERSION_NUMBER < 0x10100000L)
int err, i;
int i;

lockv = mem_zalloc(sizeof(pthread_mutex_t) * CRYPTO_num_locks(), NULL);
if (!lockv)
Expand Down Expand Up @@ -150,7 +151,6 @@ int openssl_init(void)
#endif

#if OPENSSL_VERSION_NUMBER >= 0x10100000L
int err;
err = OPENSSL_init_ssl(OPENSSL_INIT_SSL_DEFAULT, NULL);
if (!err)
return !err;
Expand Down
4 changes: 2 additions & 2 deletions src/rtmp/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -938,13 +938,13 @@ int rtmp_accept(struct rtmp_conn **connp, struct tcp_sock *ts,
if (err)
goto out;

#ifdef USE_TLS
if (tls) {
#ifdef USE_TLS
err = tls_start_tcp(&conn->sc, tls, conn->tc, 0);
if (err)
goto out;
}
#endif
}

out:
if (err)
Expand Down
2 changes: 2 additions & 0 deletions src/sip/transp.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ static struct sip_conn *ws_conn_find(struct sip *sip, const struct sa *paddr,
enum sip_transp tp)
{
struct le *le;
(void) tp;

le = list_head(hash_list(sip->ht_conn, sa_hash(paddr, SA_ALL)));

Expand Down Expand Up @@ -768,6 +769,7 @@ static void websock_recv_handler(const struct websock_hdr *hdr,
struct sip_msg *msg;
size_t start;
int err;
(void) hdr;

#if 0
re_printf(
Expand Down