From c87c5463f8bcb6190cef6ac6a22f59a9975b95d0 Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Tue, 20 Dec 2022 05:40:27 +0200 Subject: [PATCH] mingw build --- Makefile | 43 ++++++++++++++++++++++++++++++++++++++++--- libs/jpeglib/Makefile | 32 +++++++++++++++++++++++--------- libs/lib3ds/Makefile | 20 +++++++++++++++----- libs/libpng/Makefile | 20 +++++++++++++++----- libs/ogg/Makefile | 14 +++++++++++--- libs/vorbis/Makefile | 20 +++++++++++++++----- libs/zlib/Makefile | 17 +++++++++++++---- 7 files changed, 132 insertions(+), 34 deletions(-) create mode 100644 libs/w32/.keepdir diff --git a/Makefile b/Makefile index 159a119..105f352 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,6 @@ bin = sumhack-thelab include src/parts/Makefile-part include src/sdlvf/Makefile-part - obj = $(src:.cpp=.o) $(csrc:.c=.o) opt = -O1 @@ -12,12 +11,34 @@ opt = -g incdir = -Isrc/3dengfx/src -Ilibs -Ilibs/png -Ilibs/jpeglib -Ilibs/ogg -Ilibs/vorbis CXXFLAGS = -ansi -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags` CFLAGS = -std=c89 -pedantic -Wall $(opt) $(incdir) -MMD `sdl-config --cflags` -libs = -Llibs src/3dengfx/lib3dengfx.a `sdl-config --libs` -lGL -lvorbis -logg \ - -ljpeg -lpng -lz -l3ds +libs = $(libdir) $(libsys) src/3dengfx/lib3dengfx.a `sdl-config --libs` $(libgl) \ + -lvorbis -logg -ljpeg -lpng -lz -l3ds $(libc) + +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = $(src:.cpp=.w32.o) $(csrc:.c=.w32.o) + bin = sumhack-thelab.exe + libdir = -Llibs/w32 + libgl = -lopengl32 + libsys = -lmingw32 -lgdi32 -mconsole + libc = -lm + +else + libdir = -Llibs + libgl = -lGL + libc = -lm +endif + $(bin): $(obj) 3dengfx libs $(CXX) -o $@ $(obj) $(libs) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + +%.w32.o: %.cpp + $(CXX) -o $@ $(CXXFLAGS) -c $< + .PHONY: 3dengfx 3dengfx: $(MAKE) -C src/3dengfx @@ -46,3 +67,19 @@ libs: .PHONY: clean-libs clean-libs: $(MAKE) -C libs clean + +.PHONY: cross +cross: + $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw + +.PHONY: cross-libs +cross-libs: + $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw -C libs + +.PHONY: cross-clean +cross-clean: + $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw clean + +.PHONY: cross-clean-libs +cross-clean-libs: + $(MAKE) CC=i686-w64-mingw32-gcc CXX=i686-w64-mingw32-g++ sys=mingw -C libs clean diff --git a/libs/jpeglib/Makefile b/libs/jpeglib/Makefile index 435cd7e..8a16d2c 100644 --- a/libs/jpeglib/Makefile +++ b/libs/jpeglib/Makefile @@ -1,18 +1,32 @@ -obj = jcapimin.o jcapistd.o jccoefct.o jccolor.o jcdctmgr.o jchuff.o jcinit.o \ - jcmainct.o jcmarker.o jcmaster.o jcomapi.o jcparam.o jcphuff.o jcprepct.o \ - jcsample.o jctrans.o jdapimin.o jdapistd.o jdatadst.o jdatasrc.o \ - jdcoefct.o jdcolor.o jddctmgr.o jdhuff.o jdinput.o jdmainct.o jdmarker.o \ - jdmaster.o jdmerge.o jdphuff.o jdpostct.o jdsample.o jdtrans.o jerror.o \ - jfdctflt.o jfdctfst.o jfdctint.o jidctflt.o jidctfst.o jidctint.o \ - jidctred.o jmemmgr.o jmemnobs.o jquant1.o jquant2.o jutils.o - -liba = ../libjpeg.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = jcapimin.w32.o jcapistd.w32.o jccoefct.w32.o jccolor.w32.o jcdctmgr.w32.o jchuff.w32.o jcinit.w32.o \ + jcmainct.w32.o jcmarker.w32.o jcmaster.w32.o jcomapi.w32.o jcparam.w32.o jcphuff.w32.o jcprepct.w32.o \ + jcsample.w32.o jctrans.w32.o jdapimin.w32.o jdapistd.w32.o jdatadst.w32.o jdatasrc.w32.o \ + jdcoefct.w32.o jdcolor.w32.o jddctmgr.w32.o jdhuff.w32.o jdinput.w32.o jdmainct.w32.o jdmarker.w32.o \ + jdmaster.w32.o jdmerge.w32.o jdphuff.w32.o jdpostct.w32.o jdsample.w32.o jdtrans.w32.o jerror.w32.o \ + jfdctflt.w32.o jfdctfst.w32.o jfdctint.w32.o jidctflt.w32.o jidctfst.w32.o jidctint.w32.o \ + jidctred.w32.o jmemmgr.w32.o jmemnobs.w32.o jquant1.w32.o jquant2.w32.o jutils.w32.o + liba = ../w32/libjpeg.a +else + obj = jcapimin.o jcapistd.o jccoefct.o jccolor.o jcdctmgr.o jchuff.o jcinit.o \ + jcmainct.o jcmarker.o jcmaster.o jcomapi.o jcparam.o jcphuff.o jcprepct.o \ + jcsample.o jctrans.o jdapimin.o jdapistd.o jdatadst.o jdatasrc.o \ + jdcoefct.o jdcolor.o jddctmgr.o jdhuff.o jdinput.o jdmainct.o jdmarker.o \ + jdmaster.o jdmerge.o jdphuff.o jdpostct.o jdsample.o jdtrans.o jerror.o \ + jfdctflt.o jfdctfst.o jfdctint.o jidctflt.o jidctfst.o jidctint.o \ + jidctred.o jmemmgr.o jmemnobs.o jquant1.o jquant2.o jutils.o + liba = ../libjpeg.a +endif CFLAGS = -O3 $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) diff --git a/libs/lib3ds/Makefile b/libs/lib3ds/Makefile index bd715c6..1486ed0 100644 --- a/libs/lib3ds/Makefile +++ b/libs/lib3ds/Makefile @@ -1,14 +1,24 @@ -obj = atmosphere.o background.o camera.o chunk.o ease.o file.o float.o io.o \ - light.o material.o matrix.o mesh.o node.o quat.o shadow.o tcb.o tracks.o \ - vector.o viewport.o - -liba = ../lib3ds.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = atmosphere.w32.o background.w32.o camera.w32.o chunk.w32.o ease.w32.o file.w32.o float.w32.o io.w32.o \ + light.w32.o material.w32.o matrix.w32.o mesh.w32.o node.w32.o quat.w32.o shadow.w32.o tcb.w32.o tracks.w32.o \ + vector.w32.o viewport.w32.o + liba = ../w32/lib3ds.a +else + obj = atmosphere.o background.o camera.o chunk.o ease.o file.o float.o io.o \ + light.o material.o matrix.o mesh.o node.o quat.o shadow.o tcb.o tracks.o \ + vector.o viewport.o + liba = ../lib3ds.a +endif CFLAGS = -O3 -I.. $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) diff --git a/libs/libpng/Makefile b/libs/libpng/Makefile index d47c466..7332be7 100644 --- a/libs/libpng/Makefile +++ b/libs/libpng/Makefile @@ -1,14 +1,24 @@ -obj = pngerror.o pngget.o pngmem.o png.o pngpread.o pngread.o pngrio.o \ - pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o \ - pngwutil.o - -liba = ../libpng.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = pngerror.w32.o pngget.w32.o pngmem.w32.o png.w32.o pngpread.w32.o pngread.w32.o pngrio.w32.o \ + pngrtran.w32.o pngrutil.w32.o pngset.w32.o pngtrans.w32.o pngwio.w32.o pngwrite.w32.o pngwtran.w32.o \ + pngwutil.w32.o + liba = ../w32/libpng.a +else + obj = pngerror.o pngget.o pngmem.o png.o pngpread.o pngread.o pngrio.o \ + pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o \ + pngwutil.o + liba = ../libpng.a +endif CFLAGS = -O3 -I../zlib $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) diff --git a/libs/ogg/Makefile b/libs/ogg/Makefile index ef18894..f76c07d 100644 --- a/libs/ogg/Makefile +++ b/libs/ogg/Makefile @@ -1,12 +1,20 @@ -obj = bitwise.o framing.o - -liba = ../libogg.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = bitwise.w32.o framing.w32.o + liba = ../w32/libogg.a +else + obj = bitwise.o framing.o + liba = ../libogg.a +endif CFLAGS = -O3 -I.. $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) diff --git a/libs/vorbis/Makefile b/libs/vorbis/Makefile index b47d697..0a95b03 100644 --- a/libs/vorbis/Makefile +++ b/libs/vorbis/Makefile @@ -1,14 +1,24 @@ -obj = analysis.o bitrate.o block.o codebook.o envelope.o floor0.o floor1.o \ - info.o lookup.o lpc.o lsp.o mapping0.o mdct.o psy.o registry.o res0.o \ - sharedbook.o smallft.o synthesis.o vorbisenc.o vorbisfile.o window.o - -liba = ../libvorbis.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = analysis.w32.o bitrate.w32.o block.w32.o codebook.w32.o envelope.w32.o floor0.w32.o floor1.w32.o \ + info.w32.o lookup.w32.o lpc.w32.o lsp.w32.o mapping0.w32.o mdct.w32.o psy.w32.o registry.w32.o res0.w32.o \ + sharedbook.w32.o smallft.w32.o synthesis.w32.o vorbisenc.w32.o vorbisfile.w32.o window.w32.o + liba = ../w32/libvorbis.a +else + obj = analysis.o bitrate.o block.o codebook.o envelope.o floor0.o floor1.o \ + info.o lookup.o lpc.o lsp.o mapping0.o mdct.o psy.o registry.o res0.o \ + sharedbook.o smallft.o synthesis.o vorbisenc.o vorbisfile.o window.o + liba = ../libvorbis.a +endif CFLAGS = -O3 -I. -I.. $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) diff --git a/libs/w32/.keepdir b/libs/w32/.keepdir new file mode 100644 index 0000000..e69de29 diff --git a/libs/zlib/Makefile b/libs/zlib/Makefile index 34da428..9cdfbb9 100644 --- a/libs/zlib/Makefile +++ b/libs/zlib/Makefile @@ -1,13 +1,22 @@ -obj = adler32.o compress.o crc32.o deflate.o gzio.o infback.o inffast.o \ - inflate.o inftrees.o trees.o uncompr.o zutil.o - -liba = ../libz.a +sys ?= $(shell uname -s | sed 's/MINGW.*/mingw/') +ifeq ($(sys), mingw) + obj = adler32.w32.o compress.w32.o crc32.w32.o deflate.w32.o gzio.w32.o infback.w32.o inffast.w32.o \ + inflate.w32.o inftrees.w32.o trees.w32.o uncompr.w32.o zutil.w32.o + liba = ../w32/libz.a +else + obj = adler32.o compress.o crc32.o deflate.o gzio.o infback.o inffast.o \ + inflate.o inftrees.o trees.o uncompr.o zutil.o + liba = ../libz.a +endif CFLAGS = -O3 $(liba): $(obj) $(AR) rcs $@ $(obj) +%.w32.o: %.c + $(CC) -o $@ $(CFLAGS) -c $< + .PHONY: clean clean: rm -f $(obj) $(liba) -- 1.7.10.4