From b4d88cebda7051cf0b5fdc883ed26f8e75d21c5e Mon Sep 17 00:00:00 2001 From: Rodolphe Fouquet Date: Sun, 28 Apr 2024 02:14:01 +0100 Subject: [PATCH] fix mac support --- configure | 4 ++++ flake.nix | 27 +++++++++++++++++---------- src/Makefile | 4 ++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/configure b/configure index 3ad1a8915a..1d7bd9cbdc 100755 --- a/configure +++ b/configure @@ -92,6 +92,7 @@ libgpac_extralibs="" static_build="no" static_bin="no" static_modules="no" +libgpac_static="yes" lm_lib="" has_directx="no" win32="no" @@ -674,6 +675,8 @@ for opt do echo "$opt deprecated, use --static-build instead" static_build="yes"; ;; + --disable-static) libgpac_static="no"; + ;; --enable-fixed-point) use_fixed_point="yes" ;; --strip) INSTFLAGS="-s $INSTFLAGS" @@ -3001,6 +3004,7 @@ echo "DEBUGBUILD=$debuginfo" >> config.mak echo "GPROFBUILD=$gprof_build" >> config.mak echo "STATIC_BINARY=$static_bin" >> config.mak echo "STATIC_BUILD=$static_build" >> config.mak +echo "LIBGPAC_STATIC=$libgpac_static" >> config.mak echo "CONFIG_IPV6=$has_ipv6" >> config.mak if test "$has_ipv6" = "yes" ; then diff --git a/flake.nix b/flake.nix index caa7d9b560..4bcd69ca5e 100644 --- a/flake.nix +++ b/flake.nix @@ -8,7 +8,6 @@ flake-utils.lib.eachDefaultSystem (system: let name = "gpac"; - src = self; pkgs = nixpkgs.legacyPackages.${system}; buildInputs = with pkgs; [ zlib @@ -24,37 +23,45 @@ ffmpeg xvidcore openssl - alsa-lib SDL2 ] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [ darwin.CarbonHeaders + darwin.apple_sdk.frameworks.Carbon ] ++ pkgs.lib.optionals pkgs.stdenv.isLinux [ mesa mesa-demos + alsa-lib pulseaudio jack2 xorg.libX11 xorg.libXv xorg.xorgproto ]; - nativeBuildInputs = with pkgs; [ git pkg-config ]; + nativeBuildInputs = with pkgs; [ + git + pkg-config + ]; in with pkgs; { packages.default = stdenv.mkDerivation { - inherit buildInputs name src nativeBuildInputs; + inherit buildInputs name nativeBuildInputs; + src = self; + meta = with nixpkgs.lib; { + homepage = "https://gpac.io"; + description = + "For Video Streaming and Next-Gen Multimedia Transcoding, Packaging and Delivery."; + platforms = platforms.darwin ++ platforms.linux; + mainProgram = "gpac"; + #TODO support Nix uses glibtool instead of Apple libtool, we do not support it + darwinConfigureFlags = [ "--disable-static" ]; + }; }; devShells.default = mkShell { inherit buildInputs nativeBuildInputs; }; - meta = with nixpkgs.lib; { - homepage = "https://gpac.io"; - description = - "For Video Streaming and Next-Gen Multimedia Transcoding, Packaging and Delivery."; - platforms = platforms.all; - }; } ); diff --git a/src/Makefile b/src/Makefile index 0f38e88f46..012b78f096 100644 --- a/src/Makefile +++ b/src/Makefile @@ -374,16 +374,20 @@ crypto/g_crypt_openssl.o: crypto/g_crypt_openssl.c ifeq ($(CONFIG_DARWIN),yes) +ifeq ($(LIBGPAC_STATIC),yes) $(LIBTOOL) -s -o ../bin/gcc/libgpac_static.a $(OBJS) $(RANLIB) ../bin/gcc/libgpac_static.a +endif ifneq ($(STATIC_BUILD),yes) $(CC) $(SHFLAGS) $(LD_SONAME) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) endif else +ifeq ($(LIBGPAC_STATIC),yes) $(AR) cr ../bin/gcc/libgpac_static.a $(OBJS) $(RANLIB) ../bin/gcc/libgpac_static.a +endif ifneq ($(STATIC_BUILD),yes) $(CC) $(SHFLAGS) $(LD_SONAME) -o $@ $(OBJS) $(ALL_LIBS) $(LDFLAGS) mv $@ $@.$(VERSION_SONAME)