From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms13.migadu.com with LMTPS id e09COJX7CWfpCAEAe85BDQ:P1 (envelope-from ) for ; Sat, 12 Oct 2024 04:31:18 +0000 Received: from aspmx1.migadu.com ([2001:41d0:403:4876::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2.migadu.com with LMTPS id e09COJX7CWfpCAEAe85BDQ (envelope-from ) for ; Sat, 12 Oct 2024 06:31:18 +0200 X-Envelope-To: larch@yhetil.org Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="h3Wdk/Dt"; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=dPejxGo7; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Seal: i=1; s=key1; d=yhetil.org; t=1728707477; a=rsa-sha256; cv=none; b=owgi6yIP1lZcFb7ARbAQ4tPJeYDECSTXiv7X0ZHwEMMRMLdXzmNyULemAsq+T+GOL8U2JY xGoPz9BzRIX2YI7MhO8rSMC8sCTYVyHtkLakUXihLjrIekWOb91Eqowli4/RCUC+rGDgdy OWGt9sKmh3faPUf8MOLBj6FN1yM2WJG98pko60hSMzzBc9hjBgwz4GM/9Ab23p1mzMShEo XkAIVGdR+OiD7cl1fwLxYRWBjAIIiVx0A3Ab2abxaUZkaB7IccOKrJ0BhZN4n+4+eYd7EH 7wuIqncklBWbyublSmzfxpCXSCoIujZze9Nhvy49guANSJAantx2wOHbaPyr2A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=debbugs.gnu.org header.s=debbugs-gnu-org header.b="h3Wdk/Dt"; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b=dPejxGo7; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of "guix-patches-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="guix-patches-bounces+larch=yhetil.org@gnu.org" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1728707477; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=/9pypzNzbpwb3GNr2L8R0KDQFHN074U3IRr+vxSMyzo=; b=IJ3G0xfwwkCgw+J3zv4jELpYHwLbvq+/2TY89X+wZ3zdekju8s8D5tcOLBWuEbIVB4nMxS 0kUUf7IMBVsoWnWbEzJopSlDxcvwP+Xb8pCO5smdpEE9xwBSpe+vOYlGlUqAKeWdP9AGVI hL3zNsuJNvEoT3GMds+WxHb/MdWQprPwk5DCXn0Q24DRs7y+wlCJ5JKs/jDHCb6zW/NMOm a50tdc83DyI2JuzNLZqCNgHht1zWv+aD/coHgtoaI4EAB0XwMbCcr2qD9SDrYwXppj4SFu KaeC0CN1Pa/l1Nz/qi4XG+R4Hv3rjVd0E4X5ishx6IAuXXn+GF0B07YbOQIimA== Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 60C88839CF for ; Sat, 12 Oct 2024 06:31:16 +0200 (CEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1szTmQ-00070h-TN; Sat, 12 Oct 2024 00:31:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1szTmG-0006zY-W9 for guix-patches@gnu.org; Sat, 12 Oct 2024 00:30:59 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1szTmE-0001fI-R5 for guix-patches@gnu.org; Sat, 12 Oct 2024 00:30:51 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=/9pypzNzbpwb3GNr2L8R0KDQFHN074U3IRr+vxSMyzo=; b=h3Wdk/DtK6Rjuq/qoJl2e8reNnPoebKbDOLY6VhoPX44a/LSg49f2M3i/iI//1t7yRgeJ41bII3Iin/skWDEO8UG79hFUhOE6Qmc2AQu+vrAHazuAWxjI+m0mxY5HKIXqXJekL+CLV5Aww4lyll1ibAHf38txf8tubr1Z5QpF0dFSZPBeUZqEVuFUMD2BAxqOb16zxfkgXJBk4MfrvRRnnmNLSIluGrUctbd7ylJdIivTH/0XlbkGT6SQVoSQksHNrKoJdU6xLJJhSysP7tO+kRWD0hSHlDlQuF79xcPbFIkwEWGL0UiFckqR85Vs/H07Yg5VG+PISPc6Qvs5vYRXw==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1szTmQ-00017R-8j; Sat, 12 Oct 2024 00:31:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#73754] [PATCH 4/5] gnu: sameboy: Install shared library. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: maxim.cournoyer@gmail.com, adam.faiz@disroot.org, liliana.prikler@gmail.com, iyzsong@envs.net, guix-patches@gnu.org Resent-Date: Sat, 12 Oct 2024 04:31:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 73754 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 73754@debbugs.gnu.org Cc: Maxim Cournoyer , Maxim Cournoyer , Adam Faiz , Liliana Marie Prikler , =?UTF-8?Q?=E5=AE=8B=E6=96=87=E6=AD=A6?= X-Debbugs-Original-Xcc: Maxim Cournoyer , Adam Faiz , Liliana Marie Prikler , =?UTF-8?Q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Received: via spool by 73754-submit@debbugs.gnu.org id=B73754.17287074063634 (code B ref 73754); Sat, 12 Oct 2024 04:31:02 +0000 Received: (at 73754) by debbugs.gnu.org; 12 Oct 2024 04:30:06 +0000 Received: from localhost ([127.0.0.1]:35996 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szTlS-0000vy-UN for submit@debbugs.gnu.org; Sat, 12 Oct 2024 00:30:06 -0400 Received: from mail-pl1-f172.google.com ([209.85.214.172]:59805) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1szTlP-0000uu-Hv for 73754@debbugs.gnu.org; Sat, 12 Oct 2024 00:30:01 -0400 Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-208cf673b8dso28897535ad.3 for <73754@debbugs.gnu.org>; Fri, 11 Oct 2024 21:29:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728707319; x=1729312119; darn=debbugs.gnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=/9pypzNzbpwb3GNr2L8R0KDQFHN074U3IRr+vxSMyzo=; b=dPejxGo7m5FwCTDHxB+X5gyVvHJFKCRkDpFFH7Js37IOEVDQKyoUv9xA9ALEgf18ru MVh61TnU2JS91nvPNOziiOaLbX+HPh+X6J/pNc8lIAlhETC/Gfb/okl1nkeeIIkHTeYe Pu//qAD9ntAzw4tcz1JTnunE7dqZc94rLWt2s1HLXphvY9cCHzlML2RolEq3GP0zmxZI p5Ued/jcu37OTTAqU+cAin6rsJ+aMaNuj85enXSYrQz6akb/rpinbeKyl0NsQkH0RT1m U38m1lu2+593wY8ie4X45ktC1H3AuZ2365l7SMA5RkW8UlNgHckVLmS1aJhAHZfGg2vb 1NoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728707319; x=1729312119; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/9pypzNzbpwb3GNr2L8R0KDQFHN074U3IRr+vxSMyzo=; b=gbyBcqEatpdLzjLMrMatpw12ggqLqIiXbq1RiEwEqEPmGjqkSvafEUERCB+pXk+mg1 vJRIeX8jW/qTS5c9W4PvP/44KyTIe8SxGez9LBaaWaYG1bsRAOdZx0/h0GD+uH7hZ3qx rDY74s0rJXC5kFf7CIJsYd513fihWn4KqHYGZnZdoLNGQeIalMdpRxHgSJRT+QCRnzXt Dm5Fk5w/by1wc6g/Bpxftf1wzIztHfn2Ily1ZhNw+6W/aZ0bRMDVBEpP6JpfTnR23Xo9 bkqeOJakxJdOi5NBssCzJH6e+oenNz62EyKZRvpHJf3tY48s9qT4uOVcQ0T3h6HGqv9r dXHA== X-Gm-Message-State: AOJu0YxIp4aYRg4B96XiZRzUG7TfNf5Q5gFWYyo63WJ8Pe9asGK/ahN6 5m3pWCuxZtTLyqHMzc+nCHrnzcH5+Yd7eXyRLLaCcGqgJltNmUa7hCpQcQ== X-Google-Smtp-Source: AGHT+IGRY7kUYE0FovoDX4XDoFaEB4Nnb/Ty44wwl7A8HPoujLMARigcsMb1J+bUhQvpjJWIcHcUTQ== X-Received: by 2002:a17:902:f542:b0:20b:8bd0:7395 with SMTP id d9443c01a7336-20ca16c8c08mr57691335ad.46.1728707319045; Fri, 11 Oct 2024 21:28:39 -0700 (PDT) Received: from localhost.localdomain ([2405:6586:be0:0:c8ff:1707:9b9:af89]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-20c8c36e814sm30913145ad.307.2024.10.11.21.28.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2024 21:28:38 -0700 (PDT) From: Maxim Cournoyer Date: Sat, 12 Oct 2024 13:28:13 +0900 Message-ID: <25b9dd5fed046089943709a16ba7aae93b7fd911.1728684335.git.maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+larch=yhetil.org@gnu.org Sender: guix-patches-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: 0.97 X-Spam-Score: 0.97 X-Migadu-Queue-Id: 60C88839CF X-Migadu-Scanner: mx10.migadu.com X-TUID: 8xTiP2nOzSje * gnu/packages/patches/sameboy-shared-lib.patch: New file. * gnu/local.mk (dist_patch_DATA): Register it. * gnu/packages/emulators.scm (sameboy) [source]: Apply it. [arguments] : Replace DATA_DIR with PREFIX. Add LIBRARY=shared and FREEDESKTOP=1. : Delete install phase override. [native-inputs]: Add cppp and libtool. Change-Id: Ieef8434ada5a4e7ba3d726efc9710a9c2c973040 --- gnu/local.mk | 1 + gnu/packages/emulators.scm | 23 +- gnu/packages/patches/sameboy-shared-lib.patch | 317 ++++++++++++++++++ 3 files changed, 328 insertions(+), 13 deletions(-) create mode 100644 gnu/packages/patches/sameboy-shared-lib.patch diff --git a/gnu/local.mk b/gnu/local.mk index e08ecc744c..544cf36f04 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -2130,6 +2130,7 @@ dist_patch_DATA = \ %D%/packages/patches/s7-flint-3.patch \ %D%/packages/patches/sajson-for-gemmi-numbers-as-strings.patch \ %D%/packages/patches/sajson-build-with-gcc10.patch \ + %D%/packages/patches/sameboy-shared-lib.patch \ %D%/packages/patches/sbc-fix-build-non-x86.patch \ %D%/packages/patches/sbcl-aserve-add-HTML-5-elements.patch \ %D%/packages/patches/sbcl-aserve-fix-rfe12668.patch \ diff --git a/gnu/packages/emulators.scm b/gnu/packages/emulators.scm index b7dff958b7..3df1b94506 100644 --- a/gnu/packages/emulators.scm +++ b/gnu/packages/emulators.scm @@ -60,6 +60,7 @@ (define-module (gnu packages emulators) #:use-module (gnu packages bash) #:use-module (gnu packages bison) #:use-module (gnu packages boost) + #:use-module (gnu packages c) #:use-module (gnu packages cdrom) #:use-module (gnu packages check) #:use-module (gnu packages cmake) @@ -811,27 +812,23 @@ (define-public sameboy (commit (string-append "v" version)))) (file-name (git-file-name name version)) (sha256 - (base32 "1lab1x156ghfcjcy31rv731wi2b5h56z35n02h4i5pj8wjcf2jr9")))) + (base32 "1lab1x156ghfcjcy31rv731wi2b5h56z35n02h4i5pj8wjcf2jr9")) + (patches (search-patches "sameboy-shared-lib.patch")))) (build-system gnu-build-system) (arguments (list #:tests? #f ; There are no tests #:make-flags #~(list #$(string-append "CC=" (cc-for-target)) - "NATIVE_CC=gcc" "CONF=release" - (string-append "DATA_DIR=" #$output - "/share/sameboy/")) + "FREEDESKTOP=1" ;for install target + "LIBRARY=shared" + "NATIVE_CC=gcc" + "CONF=release" + (string-append "PREFIX=" #$output)) #:phases #~(modify-phases %standard-phases - (delete 'configure) - (replace 'install - (lambda _ - (with-directory-excursion "build/bin/SDL" - (install-file "sameboy" (string-append #$output "/bin")) - (delete-file "sameboy") - (copy-recursively - "." (string-append #$output "/share/sameboy/")))))))) + (delete 'configure)))) + (native-inputs (list cppp libtool pkg-config rgbds)) (inputs (list sdl2)) - (native-inputs (list rgbds pkg-config)) (home-page "https://sameboy.github.io/") (synopsis "Accurate Game Boy, Game Boy Color and Super Game Boy emulator") (description "SameBoy is a user friendly Game Boy, Game Boy Color diff --git a/gnu/packages/patches/sameboy-shared-lib.patch b/gnu/packages/patches/sameboy-shared-lib.patch new file mode 100644 index 0000000000..a18d4dec76 --- /dev/null +++ b/gnu/packages/patches/sameboy-shared-lib.patch @@ -0,0 +1,317 @@ +Upstream-status: https://github.com/LIJI32/SameBoy/pull/662 + +diff --git a/Makefile b/Makefile +index a1bce3e..cea556e 100644 +--- a/Makefile ++++ b/Makefile +@@ -1,6 +1,14 @@ + # Make hacks + .INTERMEDIATE: + ++# Library versioning, following libtool's 'version-info' scheme (see: ++# info '(libtool) Libtool versioning' or ++# https://www.gnu.org/software/libtool/manual/html_node/Libtool-versioning.html). ++LT_CURRENT := 0 ++LT_REVISION := 0 ++LT_AGE := 0 ++LT_VERSION_INFO := $(LT_CURRENT):$(LT_REVISION):$(LT_AGE) ++ + # Set target, configuration, version and destination folders + + PLATFORM := $(shell uname -s) +@@ -33,11 +41,47 @@ else + DEFAULT := sdl + endif + ++ifneq ($(LIBRARY),) ++DEFAULT += lib ++endif ++ ++# Select whether libtool should build/link for static vs shared ++# libraries, or both. ++ifneq ($(LIBRARY),) ++ifeq ($(LIBRARY), shared) ++LT_MODE_ARG := -shared ++else ifeq ($(LIBRARY), static) ++LT_MODE_ARG := -static ++else ++# Build both static and shared libraries. ++LT_MODE_ARG := ++endif ++endif ++ + NULL := /dev/null + ifeq ($(PLATFORM),windows32) + NULL := NUL + endif + ++# Strip a given prefix from a string. ++# arg1: The prefix to strip. ++# arg2: The text containing the prefix. ++# Return $text with $prefix stripped, else nothing. ++define strip_prefix = ++$(let stripped,$(subst $(1),,$(2)),$\ ++ $(shell test "$(1)$(stripped)" = "$(2)" && echo $(stripped))) ++endef ++ ++# Simplify a path for use with pkg-config, by replacing $prefix with '${prefix}' ++# arg1: prefix, e.g. an installation prefix, such as /usr/local. ++# arg2: pkgdir, e.g. a path such as $datadir, $bindir, etc. ++# arg3: pkg-config variable name, e.g. 'prefix' or 'exec_prefix'. ++# Defaults to 'prefix'. ++define simplify_pkgconf_dir = ++$(let stripped,$(call strip_prefix,$(1),$(2)),$\ ++ $(if stripped,$${$(or $(3),prefix)}$(stripped),$(2))) ++endef ++ + ifneq ($(shell which xdg-open 2> $(NULL))$(FREEDESKTOP),) + # Running on an FreeDesktop environment, configure for (optional) installation + DESTDIR ?= +@@ -46,6 +90,22 @@ DATA_DIR ?= $(PREFIX)/share/sameboy/ + FREEDESKTOP ?= true + endif + ++# Autoconf-style conventionally named variables. ++prefix ?= $(PREFIX) ++exec_prefix ?= $(prefix) ++includedir ?= $(prefix)/include ++bindir ?= $(exec_prefix)/bin ++libdir ?= $(exec_prefix)/lib ++datadir ?= $(prefix)/share ++ ++# Prettified variants for use in the pkg-config file. ++override PKGCONF_EXEC_PREFIX = \ ++ $(call simplify_pkgconf_dir,$(prefix),$(exec_prefix)) ++override PKGCONF_INCLUDEDIR = \ ++ $(call simplify_pkgconf_dir,$(prefix),$(includedir)) ++override PKGCONF_LIBDIR = \ ++ $(call simplify_pkgconf_dir,$(exec_prefix),$(libdir),exec_prefix) ++ + default: $(DEFAULT) + + ifeq ($(MAKECMDGOALS),) +@@ -101,6 +161,9 @@ BIN := build/bin + OBJ := build/obj + INC := build/include/sameboy + LIBDIR := build/lib ++PKGCONF_DIR := $(LIBDIR)/pkgconfig ++LIBTOOL_LIBRARY := $(LIBDIR)/libsameboy.la ++PKGCONF_FILE := $(PKGCONF_DIR)/sameboy.pc + + BOOTROMS_DIR ?= $(BIN)/BootROMs + +@@ -125,6 +188,26 @@ PKG_CONFIG := pkg-config + endif + endif + ++# Libtool makes it easy to correctly build shared libraries with ++# version info on both MacOS and GNU/Linux; require it if building ++# libraries. ++ifneq ($(LIBRARY),) ++ifneq (, $(shell command -v libtool 2> $(NULL))) ++LIBTOOL := libtool ++LIBTOOL_CC := $(LIBTOOL) --tag=CC --mode=compile $(CC) -c ++LIBTOOL_LD := $(LIBTOOL) --tag=CC --mode=link $(CC) \ ++ -version-info $(LT_VERSION_INFO) $(LT_MODE_ARG) ++else ++$(error "please install libtool") ++endif ++else ++# Not building libraries. ++LIBTOOL := ++LIBTOOL_CC := $(CC) ++LIBTOOL_LD := ++endif ++ ++ + ifeq ($(PLATFORM),windows32) + # To force use of the Unix version instead of the Windows version + MKDIR := $(shell which mkdir) +@@ -276,11 +359,6 @@ LDFLAGS += -Wl,/NODEFAULTLIB:libcmt.lib + endif + endif + +-LIBFLAGS := -nostdlib -Wl,-r +-ifneq ($(PLATFORM),Darwin) +-LIBFLAGS += -no-pie +-endif +- + ifeq ($(CONF),debug) + CFLAGS += -g + else ifeq ($(CONF), release) +@@ -336,11 +414,14 @@ tester: $(TESTER_TARGET) $(BIN)/tester/dmg_boot.bin $(BIN)/tester/cgb_boot.bin $ + _ios: $(BIN)/SameBoy-iOS.app $(OBJ)/installer + ios-ipa: $(BIN)/SameBoy-iOS.ipa + ios-deb: $(BIN)/SameBoy-iOS.deb ++ ++# Libraries. + ifeq ($(PLATFORM),windows32) + lib: lib-unsupported +-else +-lib: $(LIBDIR)/libsameboy.o $(LIBDIR)/libsameboy.a ++else ifneq ($(LIBRARY),) ++lib: $(LIBTOOL_LIBRARY) $(PKGCONF_FILE) + endif ++ + all: sdl tester libretro lib + ifeq ($(PLATFORM),Darwin) + all: cocoa ios-ipa ios-deb +@@ -361,6 +442,10 @@ CORE_SOURCES += $(shell ls Windows/*.c) + endif + + CORE_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(CORE_SOURCES)) ++# Libtool PIC objects are created along the .o variants, when building ++# a shared library. ++CORE_LOBJECTS := $(patsubst %,$(OBJ)/%.lo,$(CORE_SOURCES)) ++$(CORE_LOBJECTS): $(CORE_OBJECTS) + PUBLIC_HEADERS := $(patsubst Core/%,$(INC)/%,$(CORE_HEADERS)) + COCOA_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(COCOA_SOURCES)) + IOS_OBJECTS := $(patsubst %,$(OBJ)/%.o,$(IOS_SOURCES)) +@@ -404,30 +489,30 @@ $(OBJ)/%.dep: % + + $(OBJ)/Core/%.c.o: Core/%.c + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FAT_FLAGS) -DGB_INTERNAL -c $< -o $@ ++ $(LIBTOOL_CC) $(CFLAGS) $(FAT_FLAGS) -DGB_INTERNAL -c $< -o $@ + + $(OBJ)/SDL/%.c.o: SDL/%.c + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -c $< -o $@ ++ $(LIBTOOL_CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -c $< -o $@ + + $(OBJ)/OpenDialog/%.c.o: OpenDialog/%.c + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -c $< -o $@ ++ $(LIBTOOL_CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(SDL_CFLAGS) $(GL_CFLAGS) -c $< -o $@ + + + $(OBJ)/%.c.o: %.c + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) -c $< -o $@ ++ $(LIBTOOL_CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) -c $< -o $@ + + # HexFiend requires more flags + $(OBJ)/HexFiend/%.m.o: HexFiend/%.m + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@ -fno-objc-arc -include HexFiend/HexFiend_2_Framework_Prefix.pch ++ $(LIBTOOL_CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@ -fno-objc-arc -include HexFiend/HexFiend_2_Framework_Prefix.pch + + $(OBJ)/%.m.o: %.m + -@$(MKDIR) -p $(dir $@) +- $(CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@ +- ++ $(LIBTOOL_CC) $(CFLAGS) $(FRONTEND_CFLAGS) $(FAT_FLAGS) $(OCFLAGS) -c $< -o $@ ++ + # iOS Port + + $(BIN)/SameBoy-iOS.app: $(BIN)/SameBoy-iOS.app/SameBoy \ +@@ -653,15 +738,28 @@ libretro: + # Does not install mimetype icons because FreeDesktop is cursed abomination with no right to exist. + # If you somehow find a reasonable way to make associate an icon with an extension in this dumpster + # fire of a desktop environment, open an issue or a pull request ++# Install for Linux, and other FreeDesktop platforms. ++install_headers = install -Dm 644 -t $(DESTDIR)$(includedir)/sameboy $(INC)/* ++install_pkgconf_file = install -Dm 644 -t $(DESTDIR)$(libdir)/pkgconfig $(PKGCONF_FILE) ++ + ifneq ($(FREEDESKTOP),) + ICON_NAMES := apps/sameboy mimetypes/x-gameboy-rom mimetypes/x-gameboy-color-rom + ICON_SIZES := 16x16 32x32 64x64 128x128 256x256 512x512 + ICONS := $(foreach name,$(ICON_NAMES), $(foreach size,$(ICON_SIZES),$(DESTDIR)$(PREFIX)/share/icons/hicolor/$(size)/$(name).png)) ++ifneq ($(LIBRARY),) ++install: lib pkgconf ++endif ++ + install: sdl $(DESTDIR)$(PREFIX)/share/mime/packages/sameboy.xml $(ICONS) FreeDesktop/sameboy.desktop + -@$(MKDIR) -p $(dir $(DESTDIR)$(PREFIX)) + mkdir -p $(DESTDIR)$(DATA_DIR)/ $(DESTDIR)$(PREFIX)/bin/ + cp -rf $(BIN)/SDL/* $(DESTDIR)$(DATA_DIR)/ + mv $(DESTDIR)$(DATA_DIR)/sameboy $(DESTDIR)$(PREFIX)/bin/sameboy ++ifneq ($(LIBRARY),) ++ $(install_headers) ++ $(install_pkgconf_file) ++ $(LIBTOOL) --mode=install install -D $(LIBTOOL_LIBRARY) $(libdir)/libsameboy.la ++endif + ifeq ($(DESTDIR),) + -update-mime-database -n $(PREFIX)/share/mime + -xdg-desktop-menu install --novendor --mode system FreeDesktop/sameboy.desktop +@@ -727,20 +825,23 @@ $(OBJ)/control.tar.gz: iOS/deb-postinst iOS/deb-prerm iOS/deb-control + $(OBJ)/debian-binary: + -@$(MKDIR) -p $(dir $@) + echo 2.0 > $@ +- +-$(LIBDIR)/libsameboy.o: $(CORE_OBJECTS) ++ ++# Link library objects with libtool. ++$(LIBTOOL_LIBRARY): $(CORE_LOBJECTS) + -@$(MKDIR) -p $(dir $@) +- @# This is a somewhat simple hack to force Clang and GCC to build a native object file out of one or many LTO objects +- echo "static const char __attribute__((used)) x=0;"| $(CC) $(filter-out -flto,$(CFLAGS)) -c -x c - -o $(OBJ)/lto_hack.o +- @# And this is a somewhat complicated hack to invoke the correct LTO-enabled LD command in a mostly cross-platform nature +- $(CC) $(FAT_FLAGS) $(CFLAGS) $(LIBFLAGS) $^ $(OBJ)/lto_hack.o -o $@ +- -@rm $(OBJ)/lto_hack.o +- +-$(LIBDIR)/libsameboy.a: $(LIBDIR)/libsameboy.o ++ $(LIBTOOL_LD) -rpath $(libdir) $^ -o $@ ++ ++$(PKGCONF_FILE): sameboy.pc.in + -@$(MKDIR) -p $(dir $@) + -@rm -f $@ +- ar -crs $@ $^ +- ++ sed -e 's,@prefix@,$(prefix),' \ ++ -e 's/@version@/$(VERSION)/' \ ++ -e 's,@exec_prefix@,$(PKGCONF_EXEC_PREFIX),' \ ++ -e 's,@includedir@,$(PKGCONF_INCLUDEDIR),' \ ++ -e 's,@libdir@,$(PKGCONF_LIBDIR),' $< > $@ ++ ++pkgconf: $(PKGCONF_FILE) ++ + $(INC)/%.h: Core/%.h + -@$(MKDIR) -p $(dir $@) + -@# CPPP doesn't like multibyte characters, so we replace the single quote character before processing so it doesn't complain +@@ -754,4 +855,4 @@ lib-unsupported: + clean: + rm -rf build + +-.PHONY: libretro tester cocoa ios _ios ios-ipa ios-deb liblib-unsupported bootroms ++.PHONY: libretro tester cocoa ios _ios ios-ipa ios-deb lib lib-unsupported bootroms pkgconf +diff --git a/README.md b/README.md +index 9c5f8da..e23f2ca 100644 +--- a/README.md ++++ b/README.md +@@ -53,12 +53,18 @@ On Windows, SameBoy also requires: + To compile, simply run `make`. The targets are: + * `cocoa` (Default for macOS) + * `sdl` (Default for everything else) +- * `lib` (Creates libsameboy.o and libsameboy.a for statically linking SameBoy, as well as a headers directory with corresponding headers; currently not supported on Windows due to linker limitations) ++ * `lib` (Creates libsameboy.o, libsameboy.a and libsameboy.so for linking SameBoy, as well as a headers directory with corresponding headers; currently not supported on Windows due to linker limitations) + * `ios` (Plain iOS .app bundle), `ios-ipa` (iOS IPA archive for side-loading), `ios-deb` (iOS deb package for jailbroken devices) + * `libretro` + * `bootroms` + * `tester` + ++For convenience, when installing the static and shared libraries is ++desired, you can specify the LIBRARY=1 make variable to have the ++libraries built as part of the default target, as well as installed, ++along the headers. Alternatively, `LIBRARY=shared` will install just ++the shared library, while `LIBRARY=static` only the static one. ++ + You may also specify `CONF=debug` (default), `CONF=release`, `CONF=native_release` or `CONF=fat_release` to control optimization, symbols and multi-architectures. `native_release` is faster than `release`, but is optimized to the host's CPU and therefore is not portable. `fat_release` is exclusive to macOS and builds x86-64 and ARM64 fat binaries; this requires using a recent enough `clang` and macOS SDK using `xcode-select`, or setting them explicitly with `CC=` and `SYSROOT=`, respectively. All other configurations will build to your host architecture, except for the iOS targets. You may set `BOOTROMS_DIR=...` to a directory containing precompiled boot ROM files, otherwise the build system will compile and use SameBoy's own boot ROMs. + + The SDL port will look for resource files with a path relative to executable and inside the directory specified by the `DATA_DIR` variable. If you are packaging SameBoy, you may wish to override this by setting the `DATA_DIR` variable during compilation to the target path of the directory containing all files (apart from the executable, that's not necessary) from the `build/bin/SDL` directory in the source tree. Make sure the variable ends with a `/` character. On FreeDesktop environments, `DATA_DIR` will default to `/usr/local/share/sameboy/`. `PREFIX` and `DESTDIR` follow their standard usage and default to an empty string an `/usr/local`, respectively +diff --git a/sameboy.pc.in b/sameboy.pc.in +new file mode 100644 +index 0000000..dc0ca0b +--- /dev/null ++++ b/sameboy.pc.in +@@ -0,0 +1,10 @@ ++prefix=@prefix@ ++exec_prefix=@exec_prefix@ ++includedir=@includedir@ ++libdir=@libdir@ ++ ++Name: sameboy ++Description: The SameBoy library ++Version: @version@ ++Cflags: -I${includedir}/sameboy ++Libs: -L${libdir} -lsameboy -- 2.46.0