Skip to content

Commit

Permalink
Makefile: added install target + fixed dist-bin target.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkMatterCore committed Mar 1, 2021
1 parent adae94c commit 90d329b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 19 deletions.
38 changes: 27 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
.PHONY: clean all release release-dir debug debug-dir lib-dir example

#---------------------------------------------------------------------------------
LIB_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
LIB_HASH := $(shell git rev-parse --short HEAD)
LIB_REV := $(LIB_BRANCH)-$(LIB_HASH)
LIB_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
LIB_HASH := $(shell git rev-parse --short HEAD)
LIB_REV := $(LIB_BRANCH)-$(LIB_HASH)

ifneq (, $(strip $(shell git status --porcelain 2>/dev/null)))
LIB_REV := $(LIB_REV)-dirty
LIB_REV := $(LIB_REV)-dirty
endif

$(eval LIB_VERSION_MAJOR = $(shell grep 'define LIBUSBHSFS_VERSION_MAJOR\b' include/usbhsfs.h | tr -s [:blank:] | cut -d' ' -f3))
Expand All @@ -112,9 +112,13 @@ $(eval LIB_VERSION_MICRO = $(shell grep 'define LIBUSBHSFS_VERSION_MICRO\b' incl
$(eval LIB_VERSION = $(LIB_VERSION_MAJOR).$(LIB_VERSION_MINOR).$(LIB_VERSION_MICRO)-$(LIB_REV))

ifeq (${BUILD_TYPE},ISC)
LIB_LICENSE := ISC
LIB_LICENSE := ISC
else
LIB_LICENSE := GPLv2
LIB_LICENSE := GPLv2
ifeq ($(MAKECMDGOALS),install)
lib/lib$(TARGET).a: fs-libs
lib/lib$(TARGET)d.a: fs-libs
endif
endif

all: release debug
Expand All @@ -132,18 +136,25 @@ debug-dir:
lib-dir:
@mkdir -p lib

example:
example: all
@$(MAKE) BUILD_TYPE=${BUILD_TYPE} --no-print-directory -C example

lib/lib$(TARGET).a : release-dir lib-dir $(SOURCES) $(INCLUDES)
fs-libs:
@echo Installing ntfs-3g
@$(MAKE) -C libntfs-3g

@echo Installing lwext4
@$(MAKE) -C liblwext4

lib/lib$(TARGET).a: release-dir lib-dir $(SOURCES) $(INCLUDES)
@echo release
@$(MAKE) BUILD=release OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DNDEBUG=1 -O2" \
DEPSDIR=$(CURDIR)/release \
--no-print-directory -C release \
-f $(CURDIR)/Makefile

lib/lib$(TARGET)d.a : debug-dir lib-dir $(SOURCES) $(INCLUDES)
lib/lib$(TARGET)d.a: debug-dir lib-dir $(SOURCES) $(INCLUDES)
@echo debug
@$(MAKE) BUILD=debug OUTPUT=$(CURDIR)/$@ \
BUILD_CFLAGS="-DDEBUG=1 -Og" \
Expand All @@ -161,13 +172,18 @@ clean:
@rm -fr release debug lib *.bz2
@$(MAKE) --no-print-directory -C example clean

dist-src: clean
@tar --exclude=*~ -cjf lib$(TARGET)_$(LIB_VERSION)-src.tar.bz2 --exclude='libntfs-3g/*.tgz' --exclude='libntfs-3g/*.tar.*' --exclude='libntfs-3g/pkg' --exclude='libntfs-3g/src' \
dist-src:
@tar --exclude=*~ -cjf lib$(TARGET)_$(LIB_VERSION)-src.tar.bz2 \
--exclude='example/build' --exclude='example/*.elf' --exclude='example/*.nacp' --exclude='example/*.nro' \
--exclude='libntfs-3g/*.tgz' --exclude='libntfs-3g/*.tar.*' --exclude='libntfs-3g/pkg' --exclude='libntfs-3g/src' \
--exclude='liblwext4/*.zip' --exclude='liblwext4/*.tar.*' --exclude='liblwext4/pkg' --exclude='liblwext4/src' \
example include libntfs-3g liblwext4 source LICENSE_ISC.md LICENSE_GPLv2.md Makefile README.md

dist: dist-src dist-bin

install: dist-bin
@bzip2 -cd lib$(TARGET)_$(LIB_VERSION)_$(LIB_LICENSE).tar.bz2 | tar -xf - -C $(PORTLIBS) --exclude='*.md' --exclude='*.nro'

#---------------------------------------------------------------------------------
else

Expand Down
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,20 +86,16 @@ Dual licensing is provided for this project depending on the way it is built:
* NTFS via NTFS-3G, which is licensed under the [GPLv2+ license](https://sourceforge.net/p/ntfs-3g/ntfs-3g/ci/edge/tree/COPYING).
* EXT filesystems via lwext4, which is licensed under the [GPLv2 license](https://github.com/gkostka/lwext4/blob/master/LICENSE).

How to build
How to install
--------------

This section assumes you've already installed devkitA64, libnx and devkitPro pacman. If not, please follow the steps from the [devkitPro wiki](https://devkitpro.org/wiki/Getting_Started).

* **ISC licensed build**:
1. Run `make BUILD_TYPE=ISC [all/release/debug]` on the root directory from the project.
* **ISC licensed build**: run `make BUILD_TYPE=ISC install` on the root directory from the project.

* **GPLv2+ licensed build**: go to the last step if you have already installed both NTFS-3G and lwext4. Please note that if you're running a Unix-like OS such as a Linux distro or MacOS, you may need to use `dkp-makepkg` instead of `makepkg` in the following steps. Windows users may need to install `patch` and `cmake` packages beforehand.
1. Enter the `/libntfs-3g` directory from this project and run `makepkg -i --noconfirm`. This will build NTFS-3G for AArch64 and install it to the `portlibs` directory from devkitPro.
2. Enter the `/liblwext4` directory from this project and run `makepkg -i --noconfirm`. This will build lwext4 for AArch64 and install it to the `portlibs` directory from devkitPro.
3. Go back to the root directory from the project and run `make BUILD_TYPE=GPL [all/release/debug]`.
* **GPLv2+ licensed build**: run `make BUILD_TYPE=GPL install` on the root directory from the project.

Regardless of the build type you choose, a `lib` directory will be generated, which will hold the static library build for the target that was provided to the `make` command.
Regardless of the build type you choose, libusbhsfs will be installed to the `portlibs` directory from devkitPro, and it'll be ready to use by any homebrew application. If you choose to install the GPLv2+ licensed build, both NTFS-3G and lwext4 will be installed to the `portlibs` directory as well.

How to use
--------------
Expand Down
12 changes: 12 additions & 0 deletions liblwext4/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ifeq ($(OS),Windows_NT)
MAKEPKG := makepkg
all: deps
else
MAKEPKG := dkp-makepkg
endif

all:
@$(MAKEPKG) -i -s --needed --noconfirm > /dev/null

deps:
@pacman -S --needed --noconfirm patch cmake > /dev/null
12 changes: 12 additions & 0 deletions libntfs-3g/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
ifeq ($(OS),Windows_NT)
MAKEPKG := makepkg
all: deps
else
MAKEPKG := dkp-makepkg
endif

all:
@$(MAKEPKG) -i -s --needed --noconfirm > /dev/null

deps:
@pacman -S --needed --noconfirm patch > /dev/null

0 comments on commit 90d329b

Please sign in to comment.