made library, examples and Makefile MINGW64 friendly
This commit is contained in:
@ -17,6 +17,13 @@ ifeq ($(platform),)
|
||||
override platform := mac
|
||||
override architecture := $(__uname_m)
|
||||
endif
|
||||
ifeq ($(findstring mingw,$(__uname_s)),mingw)
|
||||
override platform := windows
|
||||
override architecture := $(if $(findstring MINGW32,$(MSYSTEM)),i686,$(if $(findstring MINGW64,$(MSYSTEM)),x86_64,))
|
||||
ifeq ($(CC),cc)
|
||||
override CC := gcc
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
ifeq ($(architecture),)
|
||||
override architecture := unknown-architecture
|
||||
@ -35,17 +42,22 @@ CXXFLAGS := -O2 -g -Wall -pedantic -Werror
|
||||
|
||||
ifeq ($(platform),linux)
|
||||
override LDFLAGS := $(LDFLAGS) -ldl
|
||||
CFLAGS +=-D_XOPEN_SOURCE=500
|
||||
CFLAGS += -D_XOPEN_SOURCE=500 -fpic
|
||||
CXXFLAGS += -fpic
|
||||
endif
|
||||
ifeq ($(platform),mac)
|
||||
CFLAGS +=-D_DARWIN_C_SOURCE
|
||||
CFLAGS += -D_DARWIN_C_SOURCE
|
||||
endif
|
||||
|
||||
ifeq ($(platform),mac)
|
||||
libsuffix := .dylib
|
||||
else
|
||||
endif
|
||||
ifeq ($(platform),linux)
|
||||
libsuffix := .so
|
||||
endif
|
||||
ifeq ($(platform),windows)
|
||||
libsuffix := .dll
|
||||
endif
|
||||
|
||||
.PHONY: build-executable
|
||||
build: build-executable
|
||||
@ -53,12 +65,12 @@ build-executable: $(bindir)/executable $(bindir)/executable-cpp
|
||||
|
||||
$(bindir)/executable: $(srcdir)/whereami.c $(srcdir)/whereami.h $(exampledir)/executable.c
|
||||
mkdir -p $(@D)
|
||||
$(CC) -o $@ -I $(srcdir) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -fpic $(filter-out %.h,$^)
|
||||
$(CC) -o $@ -I $(srcdir) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(filter-out %.h,$^)
|
||||
$(if $(postbuild),$(postbuild) $@)
|
||||
|
||||
$(bindir)/executable-cpp: $(srcdir)/whereami.c $(srcdir)/whereami.h $(exampledir)/executable.c
|
||||
mkdir -p $(@D)
|
||||
$(CXX) -x c++ -o $@ -I $(srcdir) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fpic $(filter-out %.h,$^)
|
||||
$(CXX) -x c++ -o $@ -I $(srcdir) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(filter-out %.h,$^)
|
||||
$(if $(postbuild),$(postbuild) $@)
|
||||
|
||||
.PHONY: build-library
|
||||
@ -67,12 +79,12 @@ build-library: $(bindir)/library$(libsuffix) $(bindir)/library-cpp$(libsuffix)
|
||||
|
||||
$(bindir)/library$(libsuffix): $(srcdir)/whereami.c $(srcdir)/whereami.h $(exampledir)/library.c
|
||||
mkdir -p $(@D)
|
||||
$(CC) -shared -o $@ -I $(srcdir) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -fpic $(filter-out %.h,$^)
|
||||
$(CC) -shared -o $@ -I $(srcdir) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $(filter-out %.h,$^)
|
||||
$(if $(postbuild),$(postbuild) $@)
|
||||
|
||||
$(bindir)/library-cpp$(libsuffix): $(srcdir)/whereami.c $(srcdir)/whereami.h $(exampledir)/library.c
|
||||
mkdir -p $(@D)
|
||||
$(CXX) -x c++ -shared -o $@ -I $(srcdir) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -fpic $(filter-out %.h,$^)
|
||||
$(CXX) -x c++ -shared -o $@ -I $(srcdir) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) $(filter-out %.h,$^)
|
||||
$(if $(postbuild),$(postbuild) $@)
|
||||
|
||||
clean:
|
||||
|
Reference in New Issue
Block a user