Skip to content

Commit 19fbc35

Browse files
committed
Add support for "make install"
1 parent df54ac5 commit 19fbc35

File tree

6 files changed

+34
-9
lines changed

6 files changed

+34
-9
lines changed

Makefile

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ include $(N64_INST)/include/n64.mk
1717
src := $(SOURCE_DIR)/t3d.c $(SOURCE_DIR)/t3dmath.c $(SOURCE_DIR)/t3dmodel.c \
1818
$(SOURCE_DIR)/t3ddebug.c $(SOURCE_DIR)/t3dskeleton.c $(SOURCE_DIR)/t3danim.c \
1919
$(SOURCE_DIR)/rsp/rsp_tiny3d.S
20+
inc := $(SOURCE_DIR)/t3d.h $(SOURCE_DIR)/t3dmath.h $(SOURCE_DIR)/t3dmodel.h \
21+
$(SOURCE_DIR)/t3ddebug.h $(SOURCE_DIR)/t3dskeleton.h $(SOURCE_DIR)/t3danim.h
2022

2123
# N64_CFLAGS += -std=gnu2x -DNDEBUG
2224
N64_CFLAGS += -std=gnu2x -Os -Isrc \
@@ -28,13 +30,13 @@ OBJ = $(BUILD_DIR)/t3dmath.o $(BUILD_DIR)/t3d.o \
2830
$(BUILD_DIR)/t3dmodel.o $(BUILD_DIR)/t3ddebug.o $(BUILD_DIR)/t3dskeleton.o $(BUILD_DIR)/t3danim.o \
2931
$(BUILD_DIR)/rsp/rsp_tiny3d.o $(BUILD_DIR)/rsp/rsp_tiny3d_clipping.o
3032

31-
all: $(BUILD_DIR)/t3d.a
33+
all: $(BUILD_DIR)/libt3d.a
3234

3335
# Static Library
34-
$(BUILD_DIR)/t3d.a: $(OBJ)
36+
$(BUILD_DIR)/libt3d.a: $(OBJ)
3537
@mkdir -p $(dir $@)
3638
@echo " [LD_LIB] $<"
37-
$(N64_LD) -r -o $(BUILD_DIR)/t3d.a $^
39+
$(N64_LD) -r -o $(BUILD_DIR)/libt3d.a $^
3840

3941
$(BUILD_DIR)/rsp/rsp_tiny3d.o: $(SOURCE_DIR)/rsp/rspq_triangle.inc
4042
$(BUILD_DIR)/rsp/rsp_tiny3d_clipping.o: $(SOURCE_DIR)/rsp/rspq_triangle.inc
@@ -68,6 +70,14 @@ $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.c
6870
@echo " [CC_LIB] $<"
6971
$(N64_CC) -c $(CFLAGS) $(N64_CFLAGS) -o $@ $<
7072

73+
install: all
74+
mkdir -p $(N64_INST)/mips64-elf/include/t3d
75+
install -cv -m 0644 t3d-inst.mk $(N64_INST)/include/t3d.mk
76+
for file in $(inc); do \
77+
install -Cv -m 0644 $$file $(N64_INST)/mips64-elf/include/t3d; \
78+
done
79+
install -Cv -m 0644 $(BUILD_DIR)/libt3d.a $(N64_INST)/mips64-elf/lib
80+
7181
clean:
7282
rm -rf $(BUILD_DIR)
7383
rm -f $(SOURCE_DIR)/rsp/rsp_tiny3d.h

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,16 @@ Checkout the playlist showcasing the example projects in this repo:<br>
3838
Checkout this repository and build it first (see the Build section), no prebuilts are provided.<br>
3939
To use Tiny3D in your project, add the following line in your Makefile:
4040
```make
41-
include $(T3D_INST)/t3d.mk
41+
include $(N64_INST)/include/t3d.mk
4242
```
43-
Where `T3D_INST` points to the path of this repository.<br>
44-
Internally this will handle adding the correct include path and linking Tiny3D itself into you project.<br>
43+
Internally this will handle the required configuration to link Tiny3D itself into you project.<br>
44+
45+
If you prefer to keep a local copy of Tiny3D in your project, then just do so (eg: a submodule)
46+
and include t3d.mk from there:
47+
```make
48+
include path/to/t3d.mk
49+
```
50+
This will make sure that that specific copy of Tiny3D is used instead.
4551

4652
In general, it's easier to simply take one of the included example projects as a starting point.<br>
4753
These can be found in the `examples` directory, where each of them goes into details about different features.<br>

build.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,12 @@ fi
3030
# Build Tiny3D
3131
echo "Building Tiny3D..."
3232
make -j4
33+
make install || sudo -E make install
3334

3435
# Tools
3536
echo "Building tools..."
3637
make -C tools/gltf_importer -j4
38+
make -C tools/gltf_importer install || sudo -E make -C tools/gltf_importer install
3739

3840
# Build Examples
3941
echo "Building examples..."

t3d-inst.mk

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
N64_LDFLAGS += -lt3d
2+
T3D_GLTF_TO_3D = $(N64_INST)/bin/gltf_to_t3d

t3d.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
N64_LDFLAGS := $(T3D_INST)/build/t3d.a $(N64_LDFLAGS)
2-
N64_C_AND_CXX_FLAGS += -I$(T3D_INST)/src
1+
T3D_DIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
32

4-
T3D_GLTF_TO_3D = $(T3D_INST)/tools/gltf_importer/gltf_to_t3d
3+
N64_LDFLAGS := $(T3D_DIR)/build/libt3d.a $(N64_LDFLAGS)
4+
N64_C_AND_CXX_FLAGS += -I$(T3D_DIR)/src
5+
6+
T3D_GLTF_TO_3D := $(T3D_DIR)/tools/gltf_importer/gltf_to_t3d

tools/gltf_importer/Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,8 @@ $(OBJDIR)/%.o: $(SRCDIR)/%.cpp
2727
gltf_to_t3d: $(OBJ)
2828
$(CXX) $(CXXFLAGS) -o $@ $^ $ $(LINKFLAGS)
2929

30+
install:
31+
install -Cv -m 0755 gltf_to_t3d $(N64_INST)/bin/
32+
3033
clean:
3134
rm -rf ./build ./gltf_to_t3d

0 commit comments

Comments
 (0)