Skip to content

Instantly share code, notes, and snippets.

@elmodaddyb
Last active May 28, 2018 16:07
Show Gist options
  • Save elmodaddyb/a7947ee61d05a5bdd137ba564fcb1898 to your computer and use it in GitHub Desktop.
Save elmodaddyb/a7947ee61d05a5bdd137ba564fcb1898 to your computer and use it in GitHub Desktop.
Homebrew's for Gerbera
class Duktape < Formula
desc "Embeddable Javascript engine with compact footprint"
homepage "http://duktape.org"
url "http://duktape.org/duktape-2.2.1.tar.xz"
sha256 "3abe2eed2553305262b892c98f550bb1a94cf4fd73b51dc5c176fe08e7ade7f2"
def install
inreplace "Makefile.sharedlibrary" do |s|
s.gsub! "-soname", "-install_name"
s.gsub! %r{\/usr\/local}, prefix
s.gsub! "libduktape.so.$(REAL_VERSION)", "libduktape.$(REAL_VERSION).so"
s.gsub! "libduktaped.so.$(REAL_VERSION)", "libduktaped.$(REAL_VERSION).so"
s.gsub! "libduktape.so.$(SONAME_VERSION)", "libduktape.$(SONAME_VERSION).so"
s.gsub! "libduktaped.so.$(SONAME_VERSION)", "libduktaped.$(SONAME_VERSION).so"
end
system "make", "-f", "Makefile.sharedlibrary"
mkdir lib
mkdir include
system "make", "-f", "Makefile.sharedlibrary", "install"
end
test do
(testpath/"test.cc").write <<~EOS
#include <stdio.h>
#include \"duktape.h\"
int main(int argc, char *argv[]) {
duk_context *ctx = duk_create_heap_default();
duk_eval_string(ctx, \"1+2\");
printf(\"1+2=%d\\n\", (int) duk_get_int(ctx, -1));
duk_destroy_heap(ctx);
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-lduktape",
testpath/"test.cc", "-o", testpath/"test"
assert_equal "1+2=3", shell_output(testpath/"test").strip, "Duktape can add number"
end
end
class Gerbera < Formula
desc "UPnP Media Server for 2018 (Based on MediaTomb)"
homepage "https://gerbera.io"
url "https://github.com/gerbera/gerbera/archive/v1.2.0.tar.gz"
sha256 "a64fe5820aced590bcdc22600596dc8a41c0baf68d7c0ec5baf7a561ade820df"
depends_on "cmake" => :build
depends_on "duktape"
depends_on "ffmpeg"
depends_on "ffmpegthumbnailer"
depends_on "libexif"
depends_on "libmagic"
depends_on "libupnp@1.8.3"
depends_on "lzlib"
depends_on "mysql"
depends_on "ossp-uuid"
depends_on "taglib"
def install
mkdir "build" do
args = std_cmake_args
args << "-DWITH_CURL=1"
args << "-DWITH_JS=1"
args << "-DWITH_TAGLIB=1"
args << "-DWITH_AVCODEC=1"
args << "-DWITH_EXIF=1"
args << "-DWITH_SYSTEMD=0"
args << "-DWITH_INOTIFY=0"
args << "-DCMAKE_FIND_FRAMEWORK=LAST"
args << "-DCMAKE_CXX_FLAGS=\"-stdlib=libstdc++\""
args << "-DCMAKE_CXX_COMPILER=/usr/bin/clang++"
args << "-DCMAKE_INSTALL_PREFIX:PATH=#{prefix}"
args << "-DWITH_FFMPEGTHUMBNAILER=1"
args << "-DWITH_MYSQL=1"
system "cmake", "..", *args
system "make", "install"
end
end
test do
assert_match /Gerbera UPnP Server/, shell_output("#{bin}/gerbera --compile-info").strip
end
end
class Libupnp < Formula
desc "The portable Universal Plug and Play (UPnP) SDK"
homepage "https://pupnp.sourceforge.io/"
url "https://downloads.sourceforge.net/project/pupnp/pupnp/libUPnP%201.8.3/libupnp-1.8.3.tar.bz2"
sha256 "9afa0b09faa9ebd9e8a6425ddbfe8d1d856544c49b1f86fde221219e569a308d"
option "with-enable-ipv6", "Enable ipv6 support"
option "with-enable-reuseaddr", "Enable reuseaddr support"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
def install
args = %W[
--prefix=#{prefix}
]
args << "--enable-ipv6" if build.with? "enable-ipv6"
args << "--enable-reuseaddr" if build.with? "enable-reuseaddr"
system "./configure", *args
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include "upnp.h"
#include <stdio.h>
#include <stdlib.h>
int
main (int argc, char* argv[])
{
int rc;
rc = UpnpInit (NULL, 0);
if ( UPNP_E_SUCCESS == rc ) {
printf ("UPnP Initializes OK");
} else {
printf ("** ERROR UpnpInit(): %d", rc);
exit (EXIT_FAILURE);
}
(void) UpnpFinish();
exit (EXIT_SUCCESS);
}
EOS
system ENV.cc, "-I#{include}/upnp", "-lupnp",
testpath/"test.c", "-o", testpath/"test"
assert_equal "UPnP Initializes OK",
shell_output(testpath/"test").strip,
"UPnP Initializes OK"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment