Clean up makefile so build lib doesnt build test
This commit is contained in:
@@ -4,7 +4,7 @@ CC := cc
|
|||||||
CFLAGS := -g -Wall -fPIC
|
CFLAGS := -g -Wall -fPIC
|
||||||
LDFLAGS := -lm -shared
|
LDFLAGS := -lm -shared
|
||||||
|
|
||||||
SRC_DIRS := src src/engine src/game src/mario src/tools test
|
SRC_DIRS := src src/engine src/game src/mario src/tools
|
||||||
BUILD_DIR := build
|
BUILD_DIR := build
|
||||||
DIST_DIR := dist
|
DIST_DIR := dist
|
||||||
ALL_DIRS := $(addprefix $(BUILD_DIR)/,$(SRC_DIRS))
|
ALL_DIRS := $(addprefix $(BUILD_DIR)/,$(SRC_DIRS))
|
||||||
@@ -20,21 +20,18 @@ IMPORTED := $(C_IMPORTED) $(H_IMPORTED)
|
|||||||
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(C_IMPORTED)
|
C_FILES := $(foreach dir,$(SRC_DIRS),$(wildcard $(dir)/*.c)) $(C_IMPORTED)
|
||||||
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
O_FILES := $(foreach file,$(C_FILES),$(BUILD_DIR)/$(file:.c=.o))
|
||||||
DEP_FILES := $(O_FILES:.o=.d)
|
DEP_FILES := $(O_FILES:.o=.d)
|
||||||
TEST_OBJS := build/test/context.o build/test/level.o build/test/main.o
|
|
||||||
|
|
||||||
DUMMY != mkdir -p src/mario
|
TEST_SRCS := test/main.c test/context.c test/level.c
|
||||||
DUMMY != mkdir -p $(ALL_DIRS)
|
TEST_OBJS := $(foreach file,$(TEST_SRCS),$(BUILD_DIR)/$(file:.c=.o))
|
||||||
DUMMY != mkdir -p $(DIST_DIR)/include
|
|
||||||
|
|
||||||
|
DUMMY != mkdir -p $(ALL_DIRS) build/test src/mario $(DIST_DIR)/include
|
||||||
|
|
||||||
|
|
||||||
$(filter-out src/mario/geo.inc.c,$(IMPORTED)): src/mario/geo.inc.c
|
$(filter-out src/mario/geo.inc.c,$(IMPORTED)): src/mario/geo.inc.c
|
||||||
src/mario/geo.inc.c: ./import-mario-geo.py
|
src/mario/geo.inc.c: ./import-mario-geo.py
|
||||||
./import-mario-geo.py
|
./import-mario-geo.py
|
||||||
|
|
||||||
test/level.c test/level.h: ./import-test-collision.py
|
|
||||||
./import-test-collision.py
|
|
||||||
|
|
||||||
test/main.c: test/level.h
|
|
||||||
|
|
||||||
$(BUILD_DIR)/%.o: %.c $(IMPORTED)
|
$(BUILD_DIR)/%.o: %.c $(IMPORTED)
|
||||||
@$(CC) $(CFLAGS) -MM -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
@$(CC) $(CFLAGS) -MM -MP -MT $@ -MF $(BUILD_DIR)/$*.d $<
|
||||||
$(CC) -c $(CFLAGS) -o $@ $<
|
$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
@@ -45,17 +42,28 @@ $(LIB_FILE): $(O_FILES)
|
|||||||
$(LIB_H_FILE): src/libsm64.h
|
$(LIB_H_FILE): src/libsm64.h
|
||||||
cp -f $< $@
|
cp -f $< $@
|
||||||
|
|
||||||
|
|
||||||
|
test/level.c test/level.h: ./import-test-collision.py
|
||||||
|
./import-test-collision.py
|
||||||
|
|
||||||
|
test/main.c: test/level.h
|
||||||
|
|
||||||
|
$(BUILD_DIR)/test/%.o: test/%.c
|
||||||
|
@$(CC) $(CFLAGS) -MM -MP -MT $@ -MF $(BUILD_DIR)/test/$*.d $<
|
||||||
|
$(CC) -c $(CFLAGS) -o $@ $<
|
||||||
|
|
||||||
$(TEST_FILE): $(LIB_FILE) $(TEST_OBJS)
|
$(TEST_FILE): $(LIB_FILE) $(TEST_OBJS)
|
||||||
$(CC) -o $@ $(TEST_OBJS) $(LIB_FILE) -lGLEW -lGL -lSDL2 -lSDL2main -lm
|
$(CC) -o $@ $(TEST_OBJS) $(LIB_FILE) -lGLEW -lGL -lSDL2 -lSDL2main -lm
|
||||||
|
|
||||||
lib: $(LIB_FILE)
|
|
||||||
|
|
||||||
test: $(TEST_FILE)
|
lib: $(LIB_FILE) $(LIB_H_FILE)
|
||||||
|
|
||||||
|
test: $(TEST_FILE) $(LIB_H_FILE)
|
||||||
|
|
||||||
run: test
|
run: test
|
||||||
./$(TEST_FILE)
|
./$(TEST_FILE)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(BUILD_DIR) $(DIST_DIR) src/mario test/level.?
|
rm -rf $(BUILD_DIR) $(DIST_DIR) src/mario test/level.? $(TEST_FILE)
|
||||||
|
|
||||||
-include $(DEP_FILES)
|
-include $(DEP_FILES)
|
||||||
@@ -1,14 +1,17 @@
|
|||||||
# libsm64 - Super Mario 64 as a library
|
# libsm64 - Super Mario 64 as a library
|
||||||
|
|
||||||
|
The purpose of this project is to provide a clean interface to the movement and rendering
|
||||||
|
code which was reversed from SM64 by the [SM64 decompilation project](https://github.com/n64decomp/sm64),
|
||||||
|
so that Mario can be dropped in to existing game engines or other systems with minimal effort.
|
||||||
|
This project produces a shared library file containing mostly code from the decompilation project,
|
||||||
|
and loads an official SM64 ROM at runtime to get Mario's texture and animation data, so any project
|
||||||
|
which makes use of this library must ask the user to provide a ROM for asset extraction.
|
||||||
|
|
||||||
## Building
|
## Building
|
||||||
|
|
||||||
### Linux
|
Currently only linux is supported. Window support coming soon. Requires python3 to build the library,
|
||||||
|
and SDL2 + GLEW for the test program.
|
||||||
|
|
||||||
1. Clone this repo and cd in to it
|
- `make lib`: Build the `dist` directory, containing the shared object and public-facing header.
|
||||||
2. `./configure`
|
- `make test`: (Default) Builds the library `dist` directory as well as the test program.
|
||||||
3. `make`
|
- `make run`: Build and run the SDL+OpenGL test program.
|
||||||
4. Now do something interesting with `libsm64.so`, it's not much use on its own.
|
|
||||||
|
|
||||||
### Windows
|
|
||||||
|
|
||||||
TODO
|
|
||||||
@@ -383,6 +383,13 @@ int main( void )
|
|||||||
size_t romSize;
|
size_t romSize;
|
||||||
|
|
||||||
uint8_t *rom = utils_read_file_alloc( "baserom.us.z64", &romSize );
|
uint8_t *rom = utils_read_file_alloc( "baserom.us.z64", &romSize );
|
||||||
|
|
||||||
|
if( rom == NULL )
|
||||||
|
{
|
||||||
|
printf("\nFailed to read ROM file \"baserom.us.z64\"\n\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t *texture = malloc( 4 * SM64_TEXTURE_WIDTH * SM64_TEXTURE_HEIGHT );
|
uint8_t *texture = malloc( 4 * SM64_TEXTURE_WIDTH * SM64_TEXTURE_HEIGHT );
|
||||||
|
|
||||||
sm64_global_init( rom, texture, NULL );
|
sm64_global_init( rom, texture, NULL );
|
||||||
|
|||||||
Reference in New Issue
Block a user