Cherry-pick extra toolchain Makefile options
This commit is contained in:
24
Makefile
24
Makefile
@@ -11,6 +11,28 @@ ifdef DEBUG
|
|||||||
else
|
else
|
||||||
CFLAGS_EXTRA=-O2
|
CFLAGS_EXTRA=-O2
|
||||||
endif
|
endif
|
||||||
|
CFLAGS_EXTRA += -fPIC --std=gnu99
|
||||||
|
LDFLAGS_EXTRA += -Wl,--relax,--gc-sections
|
||||||
|
|
||||||
|
TOOLCHAIN := $(shell $(CC) --version|awk '/Debian/ {print "debian";exit;}')
|
||||||
|
#
|
||||||
|
# This bit adds extra flags depending of the distro, and the
|
||||||
|
# architecture. To make sure debian packages have the right
|
||||||
|
# set of 'native' flags on them
|
||||||
|
#
|
||||||
|
ifeq ($(TOOLCHAIN),debian)
|
||||||
|
DEBARCH := $(shell dpkg-architecture -qDEB_BUILD_ARCH)
|
||||||
|
ifeq ($(DEBARCH),$(filter $(DEBARCH),amd64 i386))
|
||||||
|
CFLAGS_EXTRA += -march=native
|
||||||
|
endif
|
||||||
|
ifeq ($(DEBARCH),armhf)
|
||||||
|
CFLAGS_EXTRA += -march=armv7-a -mtune=cortex-a8 -mfpu=neon
|
||||||
|
endif
|
||||||
|
LDFLAGS_EXTRA += -L$(LIB) -Wl,-rpath,${shell readlink -f ${LIB}}
|
||||||
|
else
|
||||||
|
LDFLAGS_EXTRA += -L$(LIB) -Wl,-rpath-link,$(LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
|
|
||||||
# The -Wunreachable-code warning is only implemented in clang, but it
|
# The -Wunreachable-code warning is only implemented in clang, but it
|
||||||
# doesn't break anything for gcc to see it.
|
# doesn't break anything for gcc to see it.
|
||||||
@@ -23,6 +45,7 @@ WARNINGS=-Wall \
|
|||||||
CCFLAGS=-D_GNU_SOURCE=1 $(WARNINGS) $(CFLAGS_EXTRA) $(CFLAGS)
|
CCFLAGS=-D_GNU_SOURCE=1 $(WARNINGS) $(CFLAGS_EXTRA) $(CFLAGS)
|
||||||
LLDFLAGS=-lrt -lev $(LDFLAGS_EXTRA) $(LDFLAGS)
|
LLDFLAGS=-lrt -lev $(LDFLAGS_EXTRA) $(LDFLAGS)
|
||||||
|
|
||||||
|
|
||||||
CC?=gcc
|
CC?=gcc
|
||||||
|
|
||||||
LIBS=-lpthread
|
LIBS=-lpthread
|
||||||
@@ -31,6 +54,7 @@ COMPILE=$(CC) $(INC) -c $(CCFLAGS)
|
|||||||
SAVEDEP=$(CC) $(INC) -MM $(CCFLAGS)
|
SAVEDEP=$(CC) $(INC) -MM $(CCFLAGS)
|
||||||
LINK=$(CC) $(LLDFLAGS) -Isrc $(LIBS)
|
LINK=$(CC) $(LLDFLAGS) -Isrc $(LIBS)
|
||||||
|
|
||||||
|
LIB=build/
|
||||||
|
|
||||||
EXISTING_OBJS := $(wildcard build/*.o)
|
EXISTING_OBJS := $(wildcard build/*.o)
|
||||||
-include $(EXISTING_OBJS:.o=.d)
|
-include $(EXISTING_OBJS:.o=.d)
|
||||||
|
Reference in New Issue
Block a user