diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 46 |
1 files changed, 24 insertions, 22 deletions
@@ -2,28 +2,30 @@ | |||
2 | .SUFFIXES: | 2 | .SUFFIXES: |
3 | 3 | ||
4 | # Path to the development kit (devkitARM) and the GBA library. | 4 | # Path to the development kit (devkitARM) and the GBA library. |
5 | DEVKITPRO := /opt/devkitpro | 5 | DEVKITPRO := /opt/devkitpro |
6 | DEVKITARM := /opt/devkitpro/devkitARM | 6 | DEVKITBIN := $(DEVKITPRO)/devkitARM/bin |
7 | DEVKITBIN := $(DEVKITARM)/bin | 7 | DEVKITTOOLS := $(DEVKITPRO)/tools/bin |
8 | LIBGBA_DIR := $(DEVKITPRO)/libgba | 8 | LIBGBA_DIR := $(DEVKITPRO)/libgba |
9 | LIBGBA_SRC := /opt/devkitpro/libgba/include/ | 9 | LIBGBA_SRC := $(DEVKITPRO)/libgba/include/ |
10 | LIBGBA := $(LIBGBA_DIR)/lib/libgba.a | 10 | LIBGBA := $(LIBGBA_DIR)/lib/libgba.a |
11 | LIBGBA += $(LIBGBA_DIR)/lib/libfat.a | 11 | LIBGBA += $(LIBGBA_DIR)/lib/libfat.a |
12 | LIBGBA += $(LIBGBA_DIR)/lib/libmm.a | 12 | LIBGBA += $(LIBGBA_DIR)/lib/libmm.a |
13 | 13 | ||
14 | # Source code location and files to watch for changes. | 14 | # Source code location and files to watch for changes. |
15 | SRC_DIR := src | 15 | SRC_DIR := src |
16 | SRC_MAIN := $(SRC_DIR)/main.c | 16 | BUILD_DIR := build |
17 | ROM := $(SRC_DIR)/uxn/roms/boot.c | 17 | SRC_MAIN := $(SRC_DIR)/main.c |
18 | ROM_SRC := $(SRC_DIR)/uxn/roms/dvd.rom | 18 | ROM := $(BUILD_DIR)/rom.c |
19 | ASM_FILES := $(wildcard $(SRC_DIR)/*.s) | 19 | ROM_SRC := $(SRC_DIR)/uxn/roms/dvd.rom |
20 | WATCH_SRC := $(wildcard $(SRC_DIR)/*.c) | 20 | ASM_FILES := $(wildcard $(SRC_DIR)/*.s) |
21 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.h) | 21 | WATCH_SRC := $(shell find $(SRC_DIRS) -name *.c -or -name *.s -or -name *.h) |
22 | WATCH_SRC += $(wildcard $(SRC_DIR)/*.s) | 22 | INC_DIRS := $(shell find $(SRC_DIR) -type d) |
23 | INC_DIRS += $(BUILD_DIR) | ||
24 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) | ||
25 | INC_FLAGS += -I$(LIBGBA_SRC) | ||
23 | 26 | ||
24 | # Output library names and executables. | 27 | # Output library names and executables. |
25 | TARGET := uxngba | 28 | TARGET := uxngba |
26 | BUILD_DIR := build | ||
27 | ELF := $(BUILD_DIR)/$(TARGET).elf | 29 | ELF := $(BUILD_DIR)/$(TARGET).elf |
28 | BIN := $(BUILD_DIR)/$(TARGET).gba | 30 | BIN := $(BUILD_DIR)/$(TARGET).gba |
29 | 31 | ||
@@ -32,9 +34,10 @@ CC := $(DEVKITBIN)/arm-none-eabi-gcc | |||
32 | OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy | 34 | OBJCOPY := $(DEVKITBIN)/arm-none-eabi-objcopy |
33 | ARCH := -mthumb -mthumb-interwork | 35 | ARCH := -mthumb -mthumb-interwork |
34 | SPECS := -specs=gba.specs | 36 | SPECS := -specs=gba.specs |
35 | CFLAGS := -Wall -Wextra -pedantic -fno-strict-aliasing -Wno-incompatible-pointer-types | 37 | CFLAGS := -Wall -Wextra -pedantic -Wno-incompatible-pointer-types |
38 | CFLAGS += -fno-strict-aliasing | ||
36 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) | 39 | CFLAGS += -mcpu=arm7tdmi -mtune=arm7tdmi $(ARCH) |
37 | CFLAGS += -I$(LIBGBA_SRC) | 40 | CFLAGS += $(INC_FLAGS) |
38 | LDFLAGS := $(ARCH) $(SPECS) | 41 | LDFLAGS := $(ARCH) $(SPECS) |
39 | LDLIBS := $(LIBGBA) | 42 | LDLIBS := $(LIBGBA) |
40 | RELEASE_CFLAGS := -DNDEBUG -O2 | 43 | RELEASE_CFLAGS := -DNDEBUG -O2 |
@@ -55,13 +58,12 @@ endif | |||
55 | main: tools $(BUILD_DIR) $(ROM) $(BIN) | 58 | main: tools $(BUILD_DIR) $(ROM) $(BIN) |
56 | 59 | ||
57 | $(ROM): | 60 | $(ROM): |
58 | ./tools/bin2carr/build/bin2carr -n uxn_rom -e u16 -o $(ROM) \ | 61 | ./tools/bin2carr/build/bin2carr -n uxn_rom -e u16 -o $(ROM) $(ROM_SRC) |
59 | $(ROM_SRC) | ||
60 | 62 | ||
61 | # Strip and fix header to create final .gba file. | 63 | # Strip and fix header to create final .gba file. |
62 | $(BIN): $(ELF) | 64 | $(BIN): $(ELF) |
63 | $(OBJCOPY) -v -O binary $(ELF) $(BIN) | 65 | $(OBJCOPY) -v -O binary $(ELF) $(BIN) |
64 | gbafix $(BIN) | 66 | $(DEVKITTOOLS)/gbafix $(BIN) |
65 | 67 | ||
66 | # Link files. | 68 | # Link files. |
67 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) | 69 | $(ELF): $(SRC_MAIN) $(WATCH_SRC) |