From 451134322d4bf8ba97b7da32d6237c72dc919eb6 Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 17 Apr 2021 13:57:33 +0000 Subject: [PATCH] Add changes to Makefile Add -fPIC to linker flags (additional to compiler flags). This is sometimes necessary as chronologicaldot reported in the forum: http://irrlicht.sourceforge.net/forum/viewtopic.php?f=2&t=52708 Also gcc manual says this about the -shared flag: "For predictable results, you must also specify the same set of options used for compilation (-fpic, -fPIC, or model suboptions) when you specify this linker option." Add TODO for this about sharedlib_osx as I can't test that. Add documentation when "make clean" is needed. So far we only have a single set of .o files written in the same folder. So this has to be called basically on all changes. Use CPPFLAGS instead of CFLAGS, CXXFLAGS in a few places for options which should be used for all files. Add CFLAGS and CXXFLAGS for dependency files (not 100% certain about those, just seems to make more sense to me) git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@6207 dfc29bdd-3216-0410-991c-e03cc46cb475 --- source/Irrlicht/Makefile | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 535280d7..4a870dce 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -11,6 +11,10 @@ VERSION_RELEASE = 0 # This will compile Irrlicht, create a static lib (libIrrlicht.a), and copy it # into the subdirectory lib/Linux. That's all. # +# If you switch any settings (like debug/release/static/shared) then first run: +# +# make clean +# # If you want Irrlicht to be compiled as shared lib (libIrrlicht.so.versionnumber), then run: # # make sharedlib @@ -74,17 +78,18 @@ CPPFLAGS += $(CXXINCS) -DIRRLICHT_EXPORTS=1 CXXFLAGS += -Wall -pipe -fno-exceptions -fno-rtti #CXXFLAGS += -std=gnu++11 -U__STRICT_ANSI__ ifndef NDEBUG -CXXFLAGS += -g -D_DEBUG +CPPFLAGS += -g -D_DEBUG else -CXXFLAGS += -O3 +CPPFLAGS += -O3 endif ifdef PROFILE -CXXFLAGS += -pg +CPPFLAGS += -pg endif -CFLAGS := -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES -DPNG_ARM_NEON_OPT=0 +CFLAGS := -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES -DPNG_ARM_NEON_OPT=0 -sharedlib sharedlib_osx: CXXFLAGS += -fPIC -sharedlib sharedlib_osx: CFLAGS += -fPIC +sharedlib sharedlib_osx: CPPFLAGS += -fPIC +# TODO: also necessary on sharedlib_osx? +sharedlib: LDFLAGS += -fPIC #multilib handling ifeq ($(HOSTTYPE), x86_64) @@ -173,11 +178,11 @@ TAGS: # Create dependency files for automatic recompilation %.d:%.cpp - $(CXX) $(CPPFLAGS) -MM -MF $@ $< + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -MM -MF $@ $< # Create dependency files for automatic recompilation %.d:%.c - $(CC) $(CPPFLAGS) -MM -MF $@ $< + $(CC) $(CPPFLAGS) $(CFLAGS) -MM -MF $@ $< # Create object files from objective-c code %.o:%.mm