Skip to content
This repository has been archived by the owner on Nov 6, 2022. It is now read-only.

Added support for compiling on MinGW platform #294

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

claudix
Copy link

@claudix claudix commented Mar 23, 2016

Added rules to compile on MinGW platforms (Microsoft Windows environments):

  • Use 'gcc' as compiler.
  • Generate DLL file when compiling the library.
  • Disable -fPIC when compiling the library (on MinGW platforms all code is already position independent and setting this flag issues an error).

Added rules to compile on MinGW platforms (Microsoft Windows environments):
- Use 'gcc' as compiler.
- Generate DLL file when compiling the library.
- Disable -fPIC when compiling the library (on MinGW platforms all code is already position independent and setting this flag issues an error).
@indutny
Copy link
Member

indutny commented Apr 19, 2016

Sorry for a long delay.

@jasnell @mscdex any of you guys have an access to Windows to give it a try? Thanks!

@wildart
Copy link

wildart commented Jun 28, 2016

@claudix Can this PR include cygwin platform as well?

I made the following patch

@@ -18,18 +18,30 @@
 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
 # IN THE SOFTWARE.

+VERSION = 2.7.0
 PLATFORM ?= $(shell sh -c 'uname -s | tr "[A-Z]" "[a-z]"')
+ifeq ($(findstring cygwin,$(PLATFORM)), cygwin)
+PLATFORM = cygwin
+endif
+ifeq ($(findstring mingw,$(PLATFORM)), mingw)
+PLATFORM = mingw
+endif
+
 HELPER ?=
 BINEXT ?=
 ifeq (darwin,$(PLATFORM))
-SONAME ?= libhttp_parser.2.7.0.dylib
+SONAME ?= libhttp_parser.$(VERSION).dylib
 SOEXT ?= dylib
 else ifeq (wine,$(PLATFORM))
 CC = winegcc
 BINEXT = .exe.so
 HELPER = wine
+else ifneq (,$(filter $(PLATFORM),mingw cygwin))
+CC = gcc
+SONAME ?= libhttp_parser.$(VERSION).dll
+SOEXT  ?= dll
 else
-SONAME ?= libhttp_parser.so.2.7.0
+SONAME ?= libhttp_parser.so.$(VERSION)
 SOEXT ?= so
 endif

@@ -50,7 +62,12 @@
 CFLAGS_DEBUG = $(CFLAGS) -O0 -g $(CFLAGS_DEBUG_EXTRA)
 CFLAGS_FAST = $(CFLAGS) -O3 $(CFLAGS_FAST_EXTRA)
 CFLAGS_BENCH = $(CFLAGS_FAST) -Wno-unused-parameter
+
+ifneq (,$(filter $(PLATFORM),mingw cygwin))
+CFLAGS_LIB = $(CFLAGS_FAST)
+else
 CFLAGS_LIB = $(CFLAGS_FAST) -fPIC
+endif

 LDFLAGS_LIB = $(LDFLAGS) -shared

@@ -141,7 +158,7 @@
    rm -f *.o *.a tags test test_fast test_g \
        http_parser.tar libhttp_parser.so.* \
        url_parser url_parser_g parsertrace parsertrace_g \
-       *.exe *.exe.so
+       *.exe *.exe.so *.dll

 contrib/url_parser.c:  http_parser.h
 contrib/parsertrace.c: http_parser.h

and tested it on CYGWIN_NT-6.1 8308-HSQ0KM1 2.5.2(0.297/5/3) 2016-06-23 14:27 i686 Cygwin

@claudix
Copy link
Author

claudix commented Jul 7, 2016

@wildart I'd like to. However I recommend you opening your own PR because, as you can notice, my PR has been waiting for 4 months and is still waiting to be merged.... No hope to finally see it merged. BTW, good idea to create the VERSION variable... Repeating the version string throughout the file is error prone and time wasting!

@wildart
Copy link

wildart commented Jul 7, 2016

It would be nice to include windows related changes into this patch: #321.

BTW, hardcoding gcc compiler is not a good idea. what is wrong with CC variable?

wildart referenced this pull request in JuliaLang/julia Jul 7, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants