From 62fe30d63d4bd6792ab1d937a328e49f76954728 Mon Sep 17 00:00:00 2001 From: Petr Baudis Date: Mon, 16 Dec 2013 14:38:00 +0100 Subject: [PATCH] Fix build in packaging systems like portage or debian MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit We now allow custom LIBS, LDFLAGS settings akin to custom CFLAGS environment settings by using SYS_* for our overridable internal flags. Pointed out by Guillaume BINET, solution proposed by Stanisław Halik. --- ANDROID.txt | 4 ++-- Makefile | 16 ++++++++-------- Makefile.lib | 6 ++++-- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/ANDROID.txt b/ANDROID.txt index 124acd2..459e6e3 100644 --- a/ANDROID.txt +++ b/ANDROID.txt @@ -4,5 +4,5 @@ make \ CC=arm-linux-androideabi-gcc \ SYS_CFLAGS='-march=armv7-a -isysroot/opt/android-ndk/platforms/android-16/arch-arm' \ - LIBS='-lc -ldl -lm' \ - LDFLAGS='-pthread -B/opt/android-ndk/platforms/android-16/arch-arm/usr/lib/' + SYS_LIBS='-lc -ldl -lm' \ + SYS_LDFLAGS='-pthread -B/opt/android-ndk/platforms/android-16/arch-arm/usr/lib/' diff --git a/Makefile b/Makefile index 03d229e..39ba633 100644 --- a/Makefile +++ b/Makefile @@ -58,17 +58,17 @@ CUSTOM_CFLAGS?=-Wall -ggdb3 -O3 -std=gnu99 -frename-registers -pthread -Wsign-co ifdef WIN SYS_CFLAGS?= - LDFLAGS?=-pthread - LIBS=-lm -lws2_32 -lregex $(CUSTOM_LIBS) + SYS_LDFLAGS?=-pthread + SYS_LIBS?=-lm -lws2_32 -lregex else ifdef MAC SYS_CFLAGS?=-DNO_THREAD_LOCAL - LDFLAGS?=-pthread -rdynamic - LIBS=-lm -ldl $(CUSTOM_LIBS) + SYS_LDFLAGS?=-pthread -rdynamic + SYS_LIBS?=-lm -ldl else SYS_CFLAGS?=-march=native - LDFLAGS?=-pthread -rdynamic - LIBS?=-lm -lrt -ldl $(CUSTOM_LIBS) + SYS_LDFLAGS?=-pthread -rdynamic + SYS_LIBS?=-lm -lrt -ldl endif endif @@ -77,13 +77,13 @@ ifdef DOUBLE endif ifeq ($(PROFILING), gprof) - LDFLAGS+=-pg + CUSTOM_LDFLAGS+=-pg CUSTOM_CFLAGS+=-pg -fno-inline else # Whee, an extra register! CUSTOM_CFLAGS+=-fomit-frame-pointer ifeq ($(PROFILING), perftools) - LIBS+=-lprofiler + SYS_LIBS+=-lprofiler endif endif diff --git a/Makefile.lib b/Makefile.lib index 9150799..38e9e84 100644 --- a/Makefile.lib +++ b/Makefile.lib @@ -33,7 +33,7 @@ quiet_cmd_archive = '[AR] $@' cmd_archive = $(AR) r $@ $^ quiet_cmd_link = '[LINK] $@' - cmd_link = $(LINK) -o $@ $^ $(LIBS) + cmd_link = $(LINK) -o $@ $^ $(LIBS) $(SYS_LIBS) # Recursive make quiet_cmd_recmake = "[MAKE $$target] $$subdir" @@ -45,8 +45,10 @@ quiet_cmd_recmake = "[MAKE $$target] $$subdir" unexport CFLAGS CFLAGS += $(CUSTOM_CFLAGS) $(XCFLAGS) $(INCLUDES) $(SYS_CFLAGS) +unexport LDFLAGS +LDFLAGS += $(CUSTOM_LDFLAGS) $(XLDFLAGS) $(SYS_LDFLAGS) COMPILE = $(CC) $(CFLAGS) -LINK = $(CC) $(LDFLAGS) $(XLDFLAGS) +LINK = $(CC) $(LDFLAGS) DEP_FILES_1 = $(foreach src,$(OBJS),.deps/$(src)) DEP_FILES = $(DEP_FILES_1:%.o=%.P) -- 2.11.4.GIT