mkxp-z/linux/Makefile

353 lines
11 KiB
Makefile
Raw Normal View History

ARCH ?= $(shell uname -m)
ARCH_OPENSSL ?= $(ARCH)
ARCH_CFLAGS ?=
ARCH_CONFIGURE ?= $(shell gcc -dumpmachine)
2021-02-18 07:42:27 -05:00
SDL_FLAGS := ${SDL_FLAGS}
SDL2_IMAGE_FLAGS := ${SDL2_IMAGE_FLAGS}
SDL2_TTF_FLAGS := ${SDL2_TTF_FLAGS}
OPENAL_FLAGS := -DALSOFT_CPUEXT_NEON=no ${OPENAL_FLAGS}
OPENSSL_FLAGS := linux-$(ARCH_OPENSSL) ${OPENSSL_FLAGS}
2021-02-18 07:42:27 -05:00
RUBY_FLAGS := ${RUBY_FLAGS}
BUILD_PREFIX := ${PWD}/build-$(ARCH)
LIBDIR := $(BUILD_PREFIX)/lib
INCLUDEDIR := $(BUILD_PREFIX)/include
DOWNLOADS := ${PWD}/downloads/$(ARCH)
NPROC := $(shell nproc)
CFLAGS := -I$(INCLUDEDIR) -flax-vector-conversions -O3 $(ARCH_CFLAGS)
2021-02-18 07:42:27 -05:00
LDFLAGS := -L$(LIBDIR)
CC ?= gcc
2021-02-18 07:42:27 -05:00
PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig
GIT := git
CLONE := $(GIT) clone -q
GITHUB := https://github.com
CONFIGURE_ENV := \
PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \
CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
CONFIGURE_ARGS := --prefix="$(BUILD_PREFIX)" --host="$(ARCH_CONFIGURE)"
2021-02-18 07:42:27 -05:00
ifdef ARCH_CMAKE_TOOLCHAIN
ARCH_CMAKE_ARGS := -DCMAKE_TOOLCHAIN_FILE="${PWD}/$(ARCH_CMAKE_TOOLCHAIN)"
endif
2021-02-18 07:42:27 -05:00
CMAKE_ARGS := \
-DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \
2022-07-18 00:04:28 -04:00
-DCMAKE_PREFIX_PATH="$(BUILD_PREFIX)" \
2022-07-18 21:26:47 -04:00
-DCMAKE_C_FLAGS="$(CFLAGS)" \
-DCMAKE_BUILD_TYPE=Release \
$(ARCH_CMAKE_ARGS)
2021-02-18 07:42:27 -05:00
# TODO: Check if we can disable rubygems, remove prefixes.
2021-02-18 07:42:27 -05:00
RUBY_CONFIGURE_ARGS := \
--enable-install-static-library \
--enable-shared \
--disable-install-doc \
--with-out-ext=openssl,readline,dbm,gdbm \
--with-static-linked-ext \
--disable-rubygems \
--without-gmp
CONFIGURE := $(CONFIGURE_ENV) ./configure $(CONFIGURE_ARGS)
AUTOGEN := $(CONFIGURE_ENV) ./autogen.sh $(CONFIGURE_ARGS)
CMAKE := $(CONFIGURE_ENV) cmake .. $(CMAKE_ARGS)
default: everything
# Theora
libtheora: init_dirs libvorbis libogg $(LIBDIR)/libtheora.a
$(LIBDIR)/libtheora.a: $(LIBDIR)/libogg.a $(DOWNLOADS)/theora/Makefile
cd $(DOWNLOADS)/theora; \
make -j$(NPROC); make install
$(DOWNLOADS)/theora/Makefile: $(DOWNLOADS)/theora/configure
cd $(DOWNLOADS)/theora; \
$(CONFIGURE) --with-ogg=$(BUILD_PREFIX) --enable-shared=false --enable-static=true --disable-examples
$(DOWNLOADS)/theora/configure: $(DOWNLOADS)/theora/autogen.sh
cd $(DOWNLOADS)/theora; \
./autogen.sh
$(DOWNLOADS)/theora/autogen.sh:
$(CLONE) $(GITHUB)/xiph/theora $(DOWNLOADS)/theora
2021-02-18 07:42:27 -05:00
# Vorbis
libvorbis: init_dirs libogg $(LIBDIR)/libvorbis.a
$(LIBDIR)/libvorbis.a: $(LIBDIR)/libogg.a $(DOWNLOADS)/vorbis/Makefile
cd $(DOWNLOADS)/vorbis; \
make -j$(NPROC); make install
$(DOWNLOADS)/vorbis/Makefile: $(DOWNLOADS)/vorbis/configure
cd $(DOWNLOADS)/vorbis; \
$(CONFIGURE) --with-ogg=$(BUILD_PREFIX) --enable-shared=false --enable-static=true
$(DOWNLOADS)/vorbis/configure: $(DOWNLOADS)/vorbis/autogen.sh
cd $(DOWNLOADS)/vorbis; \
./autogen.sh
$(DOWNLOADS)/vorbis/autogen.sh:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/vorbis $(DOWNLOADS)/vorbis
2021-02-18 07:42:27 -05:00
# Ogg, dependency of Vorbis
libogg: init_dirs $(LIBDIR)/libogg.a
$(LIBDIR)/libogg.a: $(DOWNLOADS)/ogg/Makefile
cd $(DOWNLOADS)/ogg; \
make -j$(NPROC); make install
$(DOWNLOADS)/ogg/Makefile: $(DOWNLOADS)/ogg/configure
cd $(DOWNLOADS)/ogg; \
$(CONFIGURE) --enable-static=true --enable-shared=false
$(DOWNLOADS)/ogg/configure: $(DOWNLOADS)/ogg/autogen.sh
cd $(DOWNLOADS)/ogg; ./autogen.sh
$(DOWNLOADS)/ogg/autogen.sh:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/ogg $(DOWNLOADS)/ogg
2021-02-18 07:42:27 -05:00
# Pixman
pixman: init_dirs libpng $(LIBDIR)/libpixman-1.a
$(LIBDIR)/libpixman-1.a: $(DOWNLOADS)/pixman/Makefile
cd $(DOWNLOADS)/pixman
make -C $(DOWNLOADS)/pixman -j$(NPROC)
make -C $(DOWNLOADS)/pixman install
$(DOWNLOADS)/pixman/Makefile: $(DOWNLOADS)/pixman/autogen.sh
cd $(DOWNLOADS)/pixman; \
2022-07-20 12:19:14 -04:00
$(AUTOGEN) --enable-static=yes --enable-shared=no
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/pixman/autogen.sh:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/pixman $(DOWNLOADS)/pixman
2021-02-18 07:42:27 -05:00
2021-06-26 14:41:50 -04:00
# iconv
iconv: init_dirs $(LIBDIR)/libiconv.a
2022-07-20 12:49:57 -04:00
$(LIBDIR)/libiconv.a: $(DOWNLOADS)/libiconv-1.16/Makefile
cd $(DOWNLOADS)/libiconv-1.16; make; make install
2021-06-26 14:41:50 -04:00
2022-07-20 12:49:57 -04:00
$(DOWNLOADS)/libiconv-1.16/Makefile: $(DOWNLOADS)/libiconv-1.16/configure
cd $(DOWNLOADS)/libiconv-1.16; \
2021-06-26 14:41:50 -04:00
$(CONFIGURE) --enable-static=true --enable-shared=false
2022-07-20 12:49:57 -04:00
$(DOWNLOADS)/libiconv-1.16/configure: $(DOWNLOADS)/libiconv-1.16.tar.gz
2021-06-26 14:41:50 -04:00
cd $(DOWNLOADS); \
2022-07-20 12:49:57 -04:00
tar -xzf libiconv-1.16.tar.gz;
2021-06-26 14:41:50 -04:00
$(DOWNLOADS)/libiconv-1.16.tar.gz:
wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.16.tar.gz -P $(DOWNLOADS)
2021-06-26 13:56:42 -04:00
# uchardet
uchardet: init_dirs $(LIBDIR)/libuchardet.a
$(LIBDIR)/libuchardet.a: $(DOWNLOADS)/uchardet/cmakebuild/Makefile
cd $(DOWNLOADS)/uchardet/cmakebuild; \
make -j$(NPROC); make install
$(DOWNLOADS)/uchardet/cmakebuild/Makefile: $(DOWNLOADS)/uchardet/CMakeLists.txt
cd $(DOWNLOADS)/uchardet; \
mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DBUILD_SHARED_LIBS=no
$(DOWNLOADS)/uchardet/CMakeLists.txt:
$(CLONE) $(GITHUB)/mkxp-z/uchardet $(DOWNLOADS)/uchardet
2021-06-26 13:56:42 -04:00
2021-02-18 07:42:27 -05:00
# PhysFS
physfs: init_dirs $(LIBDIR)/libphysfs.a
$(LIBDIR)/libphysfs.a: $(DOWNLOADS)/physfs/cmakebuild/Makefile
cd $(DOWNLOADS)/physfs/cmakebuild; \
make -j$(NPROC); make install
$(DOWNLOADS)/physfs/cmakebuild/Makefile: $(DOWNLOADS)/physfs/CMakeLists.txt
cd $(DOWNLOADS)/physfs; \
mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DPHYSFS_BUILD_STATIC=true -DPHYSFS_BUILD_SHARED=false
$(DOWNLOADS)/physfs/CMakeLists.txt:
2023-05-08 02:44:45 -04:00
$(CLONE) $(GITHUB)/mkxp-z/physfs -b release-3.2.0 $(DOWNLOADS)/physfs
2021-02-18 07:42:27 -05:00
# libpng
libpng: init_dirs $(LIBDIR)/libpng.a
$(LIBDIR)/libpng.a: $(DOWNLOADS)/libpng/Makefile
cd $(DOWNLOADS)/libpng; \
make -j$(NPROC); make install
$(DOWNLOADS)/libpng/Makefile: $(DOWNLOADS)/libpng/configure
cd $(DOWNLOADS)/libpng; \
$(CONFIGURE) \
--enable-shared=no --enable-static=yes
$(DOWNLOADS)/libpng/configure:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/libpng $(DOWNLOADS)/libpng
2021-02-18 07:42:27 -05:00
# SDL2
sdl2: init_dirs $(LIBDIR)/libSDL2.a
$(LIBDIR)/libSDL2.a: $(DOWNLOADS)/sdl2/cmakebuild/Makefile
cd $(DOWNLOADS)/sdl2/cmakebuild; \
make -j$(NPROC); make install
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/sdl2/cmakebuild/Makefile: $(DOWNLOADS)/sdl2/CMakeLists.txt
2021-02-18 07:42:27 -05:00
cd $(DOWNLOADS)/sdl2; \
mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DBUILD_SHARED_LIBS=no
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/sdl2/CMakeLists.txt:
2023-06-26 14:45:15 +00:00
$(CLONE) $(GITHUB)/mkxp-z/SDL $(DOWNLOADS)/sdl2 -b mkxp-z-2.28.1
2021-02-18 07:42:27 -05:00
# SDL_image
sdl2image: init_dirs sdl2 $(LIBDIR)/libSDL2_image.a
2021-02-18 07:42:27 -05:00
$(LIBDIR)/libSDL2_image.a: $(DOWNLOADS)/sdl2_image/cmakebuild/Makefile
cd $(DOWNLOADS)/sdl2_image/cmakebuild; \
2021-02-18 07:42:27 -05:00
make -j$(NPROC); make install
$(DOWNLOADS)/sdl2_image/cmakebuild/Makefile: $(DOWNLOADS)/sdl2_image/CMakeLists.txt
cd $(DOWNLOADS)/sdl2_image; mkdir -p cmakebuild; cd cmakebuild; \
$(CMAKE) \
-DBUILD_SHARED_LIBS=no \
-DSDL2IMAGE_JPG_SAVE=yes \
-DSDL2IMAGE_PNG_SAVE=yes \
-DSDL2IMAGE_PNG_SHARED=no \
-DSDL2IMAGE_JPG_SHARED=no \
-DSDL2IMAGE_JXL=yes \
-DSDL2IMAGE_JXL_SHARED=no \
-DSDL2IMAGE_VENDORED=yes
$(DOWNLOADS)/sdl2_image/CMakeLists.txt:
$(CLONE) $(GITHUB)/mkxp-z/SDL_image $(DOWNLOADS)/sdl2_image -b mkxp-z; \
2022-07-18 21:26:47 -04:00
cd $(DOWNLOADS)/sdl2_image; \
./external/download.sh
2021-02-18 07:42:27 -05:00
# SDL_sound
2021-06-26 02:06:23 -04:00
sdlsound: init_dirs sdl2 libogg libvorbis $(LIBDIR)/libSDL2_sound.a
2021-02-18 07:42:27 -05:00
2021-06-26 02:06:23 -04:00
$(LIBDIR)/libSDL2_sound.a: $(DOWNLOADS)/sdl_sound/cmakebuild/Makefile
cd $(DOWNLOADS)/sdl_sound/cmakebuild; \
2021-02-18 07:42:27 -05:00
make -j$(NPROC); make install
2021-06-26 02:06:23 -04:00
$(DOWNLOADS)/sdl_sound/cmakebuild/Makefile: $(DOWNLOADS)/sdl_sound/CMakeLists.txt
cd $(DOWNLOADS)/sdl_sound; mkdir -p cmakebuild; cd cmakebuild; \
$(CMAKE) \
-DSDLSOUND_BUILD_SHARED=false \
2022-04-02 19:58:49 -04:00
-DSDLSOUND_BUILD_TEST=false
2021-06-17 18:14:47 -04:00
2021-06-26 02:06:23 -04:00
$(DOWNLOADS)/sdl_sound/CMakeLists.txt:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/SDL_sound $(DOWNLOADS)/sdl_sound -b git
2021-02-18 07:42:27 -05:00
# SDL2 (ttf)
sdl2ttf: init_dirs sdl2 freetype $(LIBDIR)/libSDL2_ttf.a
$(LIBDIR)/libSDL2_ttf.a: $(DOWNLOADS)/sdl2_ttf/cmakebuild/Makefile
cd $(DOWNLOADS)/sdl2_ttf/cmakebuild; \
2021-02-18 07:42:27 -05:00
make -j$(NPROC); make install
$(DOWNLOADS)/sdl2_ttf/cmakebuild/Makefile: $(DOWNLOADS)/sdl2_ttf/CMakeLists.txt
cd $(DOWNLOADS)/sdl2_ttf; mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DBUILD_SHARED_LIBS=no
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/sdl2_ttf/CMakeLists.txt:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/sdl_ttf $(DOWNLOADS)/sdl2_ttf
2021-02-18 07:42:27 -05:00
# Freetype (dependency of SDL2_ttf)
freetype: init_dirs $(LIBDIR)/libfreetype.a
$(LIBDIR)/libfreetype.a: $(DOWNLOADS)/freetype/Makefile
cd $(DOWNLOADS)/freetype; \
make -j$(NPROC); make install
$(DOWNLOADS)/freetype/Makefile: $(DOWNLOADS)/freetype/configure
cd $(DOWNLOADS)/freetype; \
$(CONFIGURE) --enable-static=true --enable-shared=false
$(DOWNLOADS)/freetype/configure: $(DOWNLOADS)/freetype/autogen.sh
cd $(DOWNLOADS)/freetype; ./autogen.sh
$(DOWNLOADS)/freetype/autogen.sh:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/freetype2 $(DOWNLOADS)/freetype
2021-02-18 07:42:27 -05:00
# OpenAL
openal: init_dirs libogg $(LIBDIR)/libopenal.a
2021-02-21 22:23:31 -05:00
$(LIBDIR)/libopenal.a: $(DOWNLOADS)/openal/cmakebuild/Makefile
2021-02-18 07:42:27 -05:00
cd $(DOWNLOADS)/openal/cmakebuild; \
make -j$(NPROC); make install
$(DOWNLOADS)/openal/cmakebuild/Makefile: $(DOWNLOADS)/openal/CMakeLists.txt
cd $(DOWNLOADS)/openal; mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DLIBTYPE=STATIC -DALSOFT_EXAMPLES=no -DALSOFT_UTILS=no $(OPENAL_FLAGS)
$(DOWNLOADS)/openal/CMakeLists.txt:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/openal-soft $(DOWNLOADS)/openal
2021-02-18 07:42:27 -05:00
# FluidSynth
fluidsynth: init_dirs $(LIBDIR)/libfluidsynth.a
$(LIBDIR)/libfluidsynth.a: $(DOWNLOADS)/fluidsynth/cmakebuild/Makefile
cd $(DOWNLOADS)/fluidsynth/cmakebuild; \
make -j$(NPROC); make install
$(DOWNLOADS)/fluidsynth/cmakebuild/Makefile: $(DOWNLOADS)/fluidsynth/CMakeLists.txt
cd $(DOWNLOADS)/fluidsynth; mkdir cmakebuild; cd cmakebuild; \
$(CMAKE) -DBUILD_SHARED_LIBS=no -Denable-sdl2=no -Denable-readline=no
$(DOWNLOADS)/fluidsynth/CMakeLists.txt:
2022-08-22 15:45:10 -04:00
$(CLONE) $(GITHUB)/mkxp-z/fluidsynth-sans-glib $(DOWNLOADS)/fluidsynth
2021-02-18 07:42:27 -05:00
# OpenSSL
openssl: init_dirs $(LIBDIR)/libssl.a
$(LIBDIR)/libssl.a: $(DOWNLOADS)/openssl/Makefile
cd $(DOWNLOADS)/openssl; \
make -j$(NPROC); make install_sw
$(DOWNLOADS)/openssl/Makefile: $(DOWNLOADS)/openssl/Configure
cd $(DOWNLOADS)/openssl; \
./Configure $(OPENSSL_FLAGS) \
no-shared \
--prefix="$(BUILD_PREFIX)" \
--openssldir="$(BUILD_PREFIX)"
$(DOWNLOADS)/openssl/Configure:
$(CLONE) $(GITHUB)/openssl/openssl $(DOWNLOADS)/openssl --single-branch --branch openssl-3.0.12 --depth 1
2021-02-18 07:42:27 -05:00
# Standard ruby
ruby: init_dirs openssl $(LIBDIR)/libruby.so.3.1
2021-02-18 07:42:27 -05:00
$(LIBDIR)/libruby.so.3.1: $(DOWNLOADS)/ruby/Makefile
2021-02-18 07:42:27 -05:00
cd $(DOWNLOADS)/ruby; \
make -j$(NPROC); make install DESTDIR="$(BUILD_PREFIX)"
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/ruby/Makefile: $(DOWNLOADS)/ruby/configure
cd $(DOWNLOADS)/ruby; \
2023-05-04 20:27:05 -04:00
export $(CONFIGURE_ENV); \
export CFLAGS="-flto $$CFLAGS"; \
export LDFLAGS="-flto $$LDFLAGS"; \
2023-05-04 20:27:05 -04:00
./configure $(CONFIGURE_ARGS) $(RUBY_CONFIGURE_ARGS) $(RUBY_FLAGS)
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/ruby/configure: $(DOWNLOADS)/ruby/configure.ac
cd $(DOWNLOADS)/ruby; autoreconf -i
2021-02-18 07:42:27 -05:00
$(DOWNLOADS)/ruby/configure.ac:
2022-12-13 04:42:21 -05:00
$(CLONE) $(GITHUB)/mkxp-z/ruby $(DOWNLOADS)/ruby --single-branch --branch mkxp-z-3.1.3 --depth 1;
2021-02-18 07:42:27 -05:00
# ====
init_dirs:
@mkdir -p $(LIBDIR) $(INCLUDEDIR)
powerwash: clean-downloads
clean-downloads:
-rm -rf downloads
deps-core: libtheora libvorbis pixman libpng physfs sdl2 sdl2image sdlsound sdl2ttf openal openssl fluidsynth uchardet iconv
2022-07-22 12:28:43 -04:00
everything: deps-core ruby