* [PATCH] Makefile: Fix build on MSYS2 and Cygwin
@ 2017-04-28 9:12 Carles Cufi
[not found] ` <20170428091255.9543-1-carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
0 siblings, 1 reply; 4+ messages in thread
From: Carles Cufi @ 2017-04-28 9:12 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
From: Carles Cufi <carles.cufi-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org>
The host compiler on MSYS2 and Cygwin does not allow the -fPIC option,
issuing a warning that is treated as an error and stops the build.
Detect whether we're running under MSYS2 or Cygwin and avoid adding
-fPIC to prevent the error from happening.
Signed-off-by: Carles Cufi <carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Makefile | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index beca4a0..62fb9b8 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ CONFIG_LOCALVERSION =
CPPFLAGS = -I libfdt -I .
WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
+CFLAGS = -g -Os -Werror $(WARNINGS)
BISON = bison
LEX = flex
@@ -33,7 +33,12 @@ LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
- sed -e 's/\(cygwin\).*/cygwin/')
+ sed -e 's/\(cygwin\|msys\).*/\1/')
+
+ifneq ($(HOSTOS),$(filter $(HOSTOS),msys cygwin))
+CFLAGS += -fPIC
+LDFLAGS += -fPIC
+endif
ifeq ($(HOSTOS),darwin)
SHAREDLIB_EXT=dylib
@@ -330,7 +335,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
$(LIBFDT_lib):
@$(VECHO) LD $@
- $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
+ $(CC) $(LDFLAGS) $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
%.lex.c: %.l
@$(VECHO) LEX $@
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Makefile: Fix build on MSYS2 and Cygwin
@ 2017-04-28 15:13 Cufi, Carles
0 siblings, 0 replies; 4+ messages in thread
From: Cufi, Carles @ 2017-04-28 15:13 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
The host compiler on MSYS2 and Cygwin does not allow the -fPIC option,
issuing a warning that is treated as an error and stops the build.
Detect whether we're running under MSYS2 or Cygwin and avoid adding
-fPIC to prevent the error from happening.
Signed-off-by: Carles Cufi <carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
Makefile | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index beca4a0..62fb9b8 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ CONFIG_LOCALVERSION =
CPPFLAGS = -I libfdt -I .
WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
+CFLAGS = -g -Os -Werror $(WARNINGS)
BISON = bison
LEX = flex
@@ -33,7 +33,12 @@ LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
- sed -e 's/\(cygwin\).*/cygwin/')
+ sed -e 's/\(cygwin\|msys\).*/\1/')
+
+ifneq ($(HOSTOS),$(filter $(HOSTOS),msys cygwin))
+CFLAGS += -fPIC
+LDFLAGS += -fPIC
+endif
ifeq ($(HOSTOS),darwin)
SHAREDLIB_EXT=dylib
@@ -330,7 +335,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
$(LIBFDT_lib):
@$(VECHO) LD $@
- $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
+ $(CC) $(LDFLAGS) $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
%.lex.c: %.l
@$(VECHO) LEX $@
--
2.9.3
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH] Makefile: Fix build on MSYS2 and Cygwin
@ 2017-04-28 17:26 Andy Gross
0 siblings, 0 replies; 4+ messages in thread
From: Andy Gross @ 2017-04-28 17:26 UTC (permalink / raw)
To: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
Cc: david-xT8FGy+AXnRB3Ne2BGzF6laj5H9X9Tb+, jdl-CYoMK+44s/E,
Carles Cuf
From: Carles Cuf <carles.cufi-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org>
The host compiler on MSYS2 and Cygwin does not allow the -fPIC option,
issuing a warning that is treated as an error and stops the build.
Detect whether we're running under MSYS2 or Cygwin and avoid adding
-fPIC to prevent the error from happening.
Signed-off-by: Carles Cufi <carles.cufi-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org>
---
Makefile | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index beca4a0..62fb9b8 100644
--- a/Makefile
+++ b/Makefile
@@ -18,7 +18,7 @@ CONFIG_LOCALVERSION =
CPPFLAGS = -I libfdt -I .
WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
-Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
-CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
+CFLAGS = -g -Os -Werror $(WARNINGS)
BISON = bison
LEX = flex
@@ -33,7 +33,12 @@ LIBDIR = $(PREFIX)/lib
INCLUDEDIR = $(PREFIX)/include
HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
- sed -e 's/\(cygwin\).*/cygwin/')
+ sed -e 's/\(cygwin\|msys\).*/\1/')
+
+ifneq ($(HOSTOS),$(filter $(HOSTOS),msys cygwin))
+CFLAGS += -fPIC
+LDFLAGS += -fPIC
+endif
ifeq ($(HOSTOS),darwin)
SHAREDLIB_EXT=dylib
@@ -330,7 +335,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
$(LIBFDT_lib):
@$(VECHO) LD $@
- $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
+ $(CC) $(LDFLAGS) $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
%.lex.c: %.l
@$(VECHO) LEX $@
--
1.9.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] Makefile: Fix build on MSYS2 and Cygwin
[not found] ` <20170428091255.9543-1-carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2017-05-10 3:32 ` David Gibson
0 siblings, 0 replies; 4+ messages in thread
From: David Gibson @ 2017-05-10 3:32 UTC (permalink / raw)
To: Carles Cufi; +Cc: devicetree-compiler-u79uwXL29TY76Z2rM5mHXA
[-- Attachment #1: Type: text/plain, Size: 2408 bytes --]
On Fri, Apr 28, 2017 at 11:12:55AM +0200, Carles Cufi wrote:
> From: Carles Cufi <carles.cufi-hR+23Fw+YnFSHonuZl5R5Q@public.gmane.org>
>
> The host compiler on MSYS2 and Cygwin does not allow the -fPIC option,
> issuing a warning that is treated as an error and stops the build.
> Detect whether we're running under MSYS2 or Cygwin and avoid adding
> -fPIC to prevent the error from happening.
>
> Signed-off-by: Carles Cufi <carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Sorry I didn't reply to this sooner.
I approve the goal of fixing compile, but I'm not entirely happy with
the way it's done here. Rather than altering CFLAGS and LDFLAGS on
the fly for everything else, I'd prefer to add a new intermediate
variable SHAREDLIB_CFLAGS or similar which is set according to HOSTOS<
then included into the standard CFLAGS. We already have a
SHAREDLIB_LINK_OPTIONS flag that can do this for the link time flags.
> ---
> Makefile | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index beca4a0..62fb9b8 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -18,7 +18,7 @@ CONFIG_LOCALVERSION =
> CPPFLAGS = -I libfdt -I .
> WARNINGS = -Wall -Wpointer-arith -Wcast-qual -Wnested-externs \
> -Wstrict-prototypes -Wmissing-prototypes -Wredundant-decls -Wshadow
> -CFLAGS = -g -Os -fPIC -Werror $(WARNINGS)
> +CFLAGS = -g -Os -Werror $(WARNINGS)
>
> BISON = bison
> LEX = flex
> @@ -33,7 +33,12 @@ LIBDIR = $(PREFIX)/lib
> INCLUDEDIR = $(PREFIX)/include
>
> HOSTOS := $(shell uname -s | tr '[:upper:]' '[:lower:]' | \
> - sed -e 's/\(cygwin\).*/cygwin/')
> + sed -e 's/\(cygwin\|msys\).*/\1/')
> +
> +ifneq ($(HOSTOS),$(filter $(HOSTOS),msys cygwin))
> +CFLAGS += -fPIC
> +LDFLAGS += -fPIC
> +endif
>
> ifeq ($(HOSTOS),darwin)
> SHAREDLIB_EXT=dylib
> @@ -330,7 +335,7 @@ clean: libfdt_clean pylibfdt_clean tests_clean
>
> $(LIBFDT_lib):
> @$(VECHO) LD $@
> - $(CC) $(LDFLAGS) -fPIC $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
> + $(CC) $(LDFLAGS) $(SHAREDLIB_LINK_OPTIONS)$(LIBFDT_soname) -o $(LIBFDT_lib) $^
>
> %.lex.c: %.l
> @$(VECHO) LEX $@
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2017-05-10 3:32 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-28 9:12 [PATCH] Makefile: Fix build on MSYS2 and Cygwin Carles Cufi
[not found] ` <20170428091255.9543-1-carles.cufi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-05-10 3:32 ` David Gibson
-- strict thread matches above, loose matches on Subject: below --
2017-04-28 15:13 Cufi, Carles
2017-04-28 17:26 Andy Gross
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).