Skip to content

Commit

Permalink
make it easier to compile projects that explicitly link with -lpthread
Browse files Browse the repository at this point in the history
  • Loading branch information
john-tornblom committed May 18, 2024
1 parent e7b4f73 commit 7f044d4
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ MAKE ?= make
DESTDIR ?= /opt/ps5-payload-sdk

TOPTARGETS := all clean install
SUBDIRS := crt sce_stubs libc libm include host
SUBDIRS := crt sce_stubs libc libm libpthread include host

$(TOPTARGETS): $(SUBDIRS)

Expand Down
43 changes: 43 additions & 0 deletions libpthread/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Copyright (C) 2024 John Törnblom
#
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; see the file COPYING. If not see
# <http://www.gnu.org/licenses/>.

DESTDIR ?= /opt/ps5-payload-sdk

ARS := llvm-ar-18 llvm-ar-17 llvm-ar-16 llvm-ar-15 llvm-ar
ARS := $(foreach AR,$(ARS),$(if $(shell command -v $(AR) 2> /dev/null),$(AR)))
AR := $(firstword $(ARS))
ifndef AR
$(error No suitable archiver found)
endif

# libpthread is provided by libkernel, which is always linked with.
# Create an empty archive to make it easier to compile projects that
# explicitly link with -lpthread

ARCHIVE := libpthread.a

all: $(ARCHIVE)

$(ARCHIVE):
$(AR) rcs $@

clean:
rm -f *.a *.o

install: $(ARCHIVE)
install -d $(DESTDIR)/target/lib
install $^ $(DESTDIR)/target/lib

0 comments on commit 7f044d4

Please sign in to comment.