diff --git a/.gitignore b/.gitignore index 16b94dd..7721c3d 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ cmake/ *.elf *.rpx *.exe +build-pc-win/ diff --git a/Dockerfile.pc-win b/Dockerfile.pc-win new file mode 100644 index 0000000..38c3430 --- /dev/null +++ b/Dockerfile.pc-win @@ -0,0 +1,22 @@ +FROM dockcross/windows-shared-x64:latest + +RUN apt-get update && apt-get install -y gnupg +#Use http://mirror.mxe.cc/ +#First add the repository and install the static gcc compiler. This ensures that everything basic is setup. +RUN echo "deb http://pkg.mxe.cc/repos/apt xenial main" > \ + /etc/apt/sources.list.d/mxeapt.list && \ + apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 86B72ED9 && \ + apt-get update && \ + apt-get install -y mxe-i686-w64-mingw32.static-gcc \ + nsis \ + zip \ + libtool + +RUN apt-get update && wget -O - http://mirror.mxe.cc/repos/apt/dists/stretch/main/binary-amd64/Packages | grep Package | grep shared | grep sdl2 | awk '{print $2}' | xargs apt-get install -y + +ENV MINGW64_PREFIX=/usr/src/mxe/usr/bin/x86_64-w64-mingw32.shared- +ENV CONFIG_PREFIX=/usr/lib/mxe/usr/bin/x86_64-w64-mingw32.shared- +ENV EXTRA_CFLAGS=-I/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/include +ENV EXTRA_LDFLAGS=-L/usr/lib/mxe/usr/x86_64-w64-mingw32.shared/lib + +WORKDIR /project \ No newline at end of file diff --git a/Makefile.pc-win b/Makefile.pc-win index fdf9810..3062acc 100644 --- a/Makefile.pc-win +++ b/Makefile.pc-win @@ -2,13 +2,21 @@ .SUFFIXES: #------------------------------------------------------------------------------- -ifeq ($(strip $(DEVKITPRO)),) -$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=/devkitpro") +ifeq ($(strip $(MINGW64_PREFIX)),) + $(error "Please set MINGW64_PREFIX in your environment. export MINGW64_PREFIX=/mingw64/bin/") +endif + + +CXX := $(MINGW64_PREFIX)g++ +C := $(MINGW64_PREFIX)gcc +PREFIX := $(MINGW64_PREFIX) + +ifeq ($(strip $(CONFIG_PREFIX)),) + PKG-CONFIG := $(PREFIX)pkg-config +else + PKG-CONFIG := $(CONFIG_PREFIX)pkg-config endif -CXX := $(DEVKITPRO)/msys2/mingw64/bin/g++ -C := $(DEVKITPRO)/msys2/mingw64/bin/gcc -PREFIX := $(DEVKITPRO)/msys2/mingw64/bin/ #------------------------------------------------------------------------------- # TARGET is the name of the output @@ -18,34 +26,42 @@ PREFIX := $(DEVKITPRO)/msys2/mingw64/bin/ # INCLUDES is a list of directories containing header files #------------------------------------------------------------------------------- TARGET := SDL2_Playground -BUILD := build +BUILD := build-pc-win SOURCES := src \ src/gui DATA := data INCLUDES := source - #------------------------------------------------------------------------------- # options for code generation #------------------------------------------------------------------------------- -+CFLAGS := -g -Wall -O2 -ffunction-sections `$(PREFIX)pkg-config --cflags SDL2_mixer SDL2_ttf SDL2_image` \ +CFLAGS := -g -Wall -O2 -ffunction-sections `$(PKG-CONFIG) --cflags SDL2_mixer SDL2_ttf SDL2_image` \ $(MACHDEP) CFLAGS += $(INCLUDE) -CXXFLAGS := $(CFLAGS) -std=c++20 + +ifeq ($(strip $(EXTRA_CFLAGS)),) +else + CFLAGS += $(EXTRA_CFLAGS) +endif + +CXXFLAGS := $(CFLAGS) -std=c++17 ASFLAGS := -g $(ARCH) LDFLAGS = -g $(ARCH) -LIBS := `$(PREFIX)pkg-config --libs SDL2_mixer SDL2_ttf SDL2_image` - +LIBS := `$(PKG-CONFIG) --libs SDL2_mixer SDL2_ttf SDL2_image` + ifeq ($(strip $(EXTRA_LDFLAGS)),) +else + LDFLAGS += $(EXTRA_LDFLAGS) +endif #------------------------------------------------------------------------------- # list of directories containing libraries, this must be the top level # containing include and lib #------------------------------------------------------------------------------- -LIBDIRS := $(PORTLIBS) +LIBDIRS := #------------------------------------------------------------------------------- # no real need to edit anything past this point unless you need to add additional @@ -104,7 +120,7 @@ $(BUILD): #------------------------------------------------------------------------------- clean: @echo clean ... - @rm -fr $(BUILD) $(TARGET).rpx $(TARGET).elf + @rm -fr $(BUILD) $(TARGET).exe #------------------------------------------------------------------------------- else @@ -126,12 +142,8 @@ $(OUTPUT).exe: @$(CXX) $(LDFLAGS) $(OFILES) $(LIBPATHS) $(LIBS) -o $@ $(ERROR_FILTER) %.o: %.cpp - @echo "$(notdir $<)" - @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER) - -clean: - rm -f $(OBJS) $(OBJ_NAME) $(MINIZIP_O) - + @echo "$(notdir $<)" + @$(CXX) -MMD -MP -MF $(DEPSDIR)/$*.d $(CXXFLAGS) -c $< -o $@ $(ERROR_FILTER) -include $(DEPENDS) diff --git a/README.md b/README.md index 7558eef..958ebc5 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,13 @@ pacman -S git mingw-w64-x86_64-toolchain mingw64/mingw-w64-x86_64-SDL2 mingw64/m make -f .\Makefile.pc-win ``` +## Windows with docker + +``` +docker build . -f .\Dockerfile.pc-win -t sdl2_playground-builder-pc-win +docker run -it --rm -v ${PWD}:/project sdl2_playground-builder-pc-win make -f .\Makefile.pc-win -j16 +``` + ## Wii U And these from [dkp-libs](https://devkitpro.org/wiki/devkitPro_pacman):