Add pkg-config support

This commit is contained in:
Ash 2018-11-03 13:08:23 +11:00
parent a91e76ff39
commit b2a22a2036
2 changed files with 36 additions and 11 deletions

View File

@ -2,12 +2,14 @@
.SUFFIXES: .SUFFIXES:
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPPC)),) ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC) $(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif endif
ifeq ($(strip $(DEVKITPRO)),) ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO") $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif endif
GITTAG ?= $(shell git describe --tags)
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH) export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
@ -32,6 +34,7 @@ include $(DEVKITPPC)/base_rules
BUILD ?= release BUILD ?= release
SOURCES := source SOURCES := source
INCLUDES := include INCLUDES := include
PKGCONFS := pkgconf
DATA := DATA :=
LIB := lib LIB := lib
@ -44,6 +47,7 @@ CXXFLAGS = $(CFLAGS)
ASFLAGS := -g ASFLAGS := -g
export WIIUBIN := $(LIB)/libdynamiclibs.a export WIIUBIN := $(LIB)/libdynamiclibs.a
export PKGCONF := dynamic_libs.pc
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# any extra libraries we wish to link with the project # any extra libraries we wish to link with the project
@ -69,7 +73,8 @@ export TOPDIR ?= $(CURDIR)/..
export DEPSDIR := $(CURDIR)/$(BUILD) export DEPSDIR := $(CURDIR)/$(BUILD)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \ export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir)) $(foreach dir,$(DATA),$(CURDIR)/$(dir)) \
$(foreach dir,$(PKGCONFS),$(CURDIR)/$(dir))
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c))) CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp))) CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
@ -89,7 +94,7 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib) $(PORTLIBS)/lib
.PHONY: $(BUILD) clean .PHONY: $(BUILD) clean all install
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(BUILD): $(BUILD):
@ -99,14 +104,18 @@ $(BUILD):
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
clean: clean:
@echo clean ... @echo clean ...
@rm -fr debug release $(LIB) include @rm -fr debug release $(LIB) include $(PKGCONF)
all: $(WIIUBIN) all: $(BUILD)
install: install: $(BUILD)
@mkdir -p $(PORTLIBS)/lib
@cp $(BUILD)/lib/libdynamiclibs.a $(PORTLIBS)/lib @cp $(BUILD)/lib/libdynamiclibs.a $(PORTLIBS)/lib
@mkdir -p $(PORTLIBS)/include/dynamic_libs @mkdir -p $(PORTLIBS)/include/dynamic_libs
@cp source/*.h $(PORTLIBS)/include/dynamic_libs @cp source/*.h $(PORTLIBS)/include/dynamic_libs
@mkdir -p $(PORTLIBS)/lib/pkgconfig
@cp $(BUILD)/$(PKGCONF) $(PORTLIBS)/lib/pkgconfig
@echo Installed!
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
else else
@ -116,7 +125,13 @@ DEPENDS := $(OFILES:.o=.d)
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
# main targets # main targets
#--------------------------------------------------------------------------------- #---------------------------------------------------------------------------------
$(WIIUBIN) : $(OFILES) $(LIB) all: $(WIIUBIN) $(PKGCONF)
%.pc: %.pc.in
@sed "s;@PREFIX@;$(PORTLIBS);g" $< > $@
@sed "s;@VERSION@;$(GITTAG);g" $< > $@
$(WIIUBIN): $(OFILES) $(LIB)
@rm -f "$(WIIUBIN)" @rm -f "$(WIIUBIN)"
@$(AR) rcs "$(WIIUBIN)" $(OFILES) @$(AR) rcs "$(WIIUBIN)" $(OFILES)
@echo built ... $(notdir $@) @echo built ... $(notdir $@)
@ -129,4 +144,3 @@ $(LIB):
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------
endif endif
#--------------------------------------------------------------------------------------- #---------------------------------------------------------------------------------------

View File

@ -0,0 +1,11 @@
dynamic_libs.pc:
prefix=@PREFIX@
includedir=${prefix}/include
libdir=${prefix}/lib
Name: dynamic_libs
Description: Dynamic libs for WiiU homebrew
Version: @VERSION@
Cflags: -I${includedir}/dynamic_libs
Libs: -L${libdir} -ldynamiclibs