Skip to content

Commit

Permalink
Make libsameboy installable, including pkg-config support. Closes LIJ…
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Dec 11, 2024
1 parent c96b77f commit b020b5f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
18 changes: 16 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ ifeq ($(PLATFORM),windows32)
NULL := NUL
endif

PREFIX ?= /usr/local
ifneq ($(shell which xdg-open 2> $(NULL))$(FREEDESKTOP),)
# Running on an FreeDesktop environment, configure for (optional) installation
DESTDIR ?=
PREFIX ?= /usr/local
DATA_DIR ?= $(PREFIX)/share/sameboy/
FREEDESKTOP ?= true
endif
Expand Down Expand Up @@ -114,6 +114,8 @@ BIN := build/bin
OBJ := build/obj
INC := build/include/sameboy
LIBDIR := build/lib
PKGCONF_DIR := $(LIBDIR)/pkgconfig
PKGCONF_FILE := $(PKGCONF_DIR)/sameboy.pc

BOOTROMS_DIR ?= $(BIN)/BootROMs

Expand Down Expand Up @@ -837,7 +839,19 @@ ifeq ($(CONF), release)
$(CODESIGN)$@
endif


$(PKGCONF_FILE): sameboy.pc.in
-@$(MKDIR) -p $(dir $@)
-@rm -f $@
sed -e 's,@prefix@,$(PREFIX),' \
-e 's/@version@/$(VERSION)/' $< > $@

lib-install: lib $(PKGCONF_FILE)
install -d $(DESTDIR)$(PREFIX)/lib/pkgconfig
install -d $(DESTDIR)$(PREFIX)/include/sameboy
install -m 644 $(LIBDIR)/libsameboy.a $(LIBDIR)/libsameboy.$(DL_EXT) $(DESTDIR)$(PREFIX)/lib/
install -m 644 $(INC)/* $(DESTDIR)$(PREFIX)/include/sameboy/
install -m 644 $(PKGCONF_FILE) $(DESTDIR)$(PREFIX)/lib/pkgconfig

# Windows dll

# To avoid Windows' sort.exe
Expand Down
11 changes: 11 additions & 0 deletions sameboy.pc.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
prefix=@prefix@
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${prefix}/lib

Name: sameboy
Description: SameBoy's emulation core as a library
Version: @version@
Cflags: -I${includedir}
Libs: -L${libdir} -lsameboy
Libs.private: -lm -lc

0 comments on commit b020b5f

Please sign in to comment.