shithub: pokecrystal

Download patch

ref: 175cc6536a0667ac1913d03f1041f924a7368dd1
parent: dbaec2053429e04f21613c3c0964e213008bfdb9
parent: 121e9317507abb5ae08c144c0cd2b968d9882449
author: yenatch <[email protected]>
date: Sat Jun 24 17:03:09 EDT 2017

Merge pull request #365 from Ben10do/tools-makefile-integration

Improvements to the tools and their Makefile

--- a/INSTALL.md
+++ b/INSTALL.md
@@ -17,7 +17,6 @@
 
 git clone https://github.com/pret/pokecrystal
 cd pokecrystal
-make tools
 ```
 
 To build **pokecrystal.gbc**:
@@ -42,7 +41,6 @@
 
 git clone https://github.com/pret/pokecrystal
 cd pokecrystal
-make tools
 ```
 
 To build **pokecrystal.gbc**:
@@ -67,7 +65,6 @@
 
 git clone https://github.com/pret/pokecrystal
 cd pokecrystal
-make tools CC=gcc
 ```
 
 To build **pokecrystal.gbc**:
--- a/Makefile
+++ b/Makefile
@@ -36,8 +36,16 @@
 crystal: pokecrystal.gbc
 crystal11: pokecrystal11.gbc
 
+# Ensure that the tools are built when making the ROM
+ifneq ($(MAKECMDGOALS),clean)
+ifneq ($(MAKECMDGOALS),tools)
+Makefile: tools
+endif
+endif
+
 clean:
 	rm -f $(roms) $(crystal_obj) $(crystal11_obj) $(roms:.gbc=.map) $(roms:.gbc=.sym)
+	make clean -C tools/
 
 compare: $(roms)
 	@$(SHA1) -c roms.sha1
--- /dev/null
+++ b/tools/.gitignore
@@ -1,0 +1,8 @@
+gfx
+lzcomp
+md5
+palette
+png_dimensions
+pokemon_animation
+pokemon_animation_graphics
+scan_includes
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -1,8 +1,8 @@
-.PHONY: all
+.PHONY: all clean
 
 CFLAGS := -std=c99
 
-all: \
+tools := \
 	lzcomp \
 	png_dimensions \
 	scan_includes \
@@ -11,7 +11,11 @@
 	pokemon_animation_graphics \
 	gfx \
 	md5
+all: $(tools)
 	@:
+
+clean:
+	rm -f $(tools)
 
 %: %.c
 	$(CC) $(CFLAGS) -o $@ $<
--- a/tools/lzcomp.c
+++ b/tools/lzcomp.c
@@ -177,11 +177,11 @@
   struct command simple = {.command = 7};
   struct command flipped = simple, backwards = simple;
   short count, offset;
-  if (count = scan_forwards(data + position, length - position, data, position, &offset))
+  if ((count = scan_forwards(data + position, length - position, data, position, &offset)))
     simple = (struct command) {.command = 4, .count = count, .value = offset};
-  if (count = scan_forwards(data + position, length - position, bitflipped, position, &offset))
+  if ((count = scan_forwards(data + position, length - position, bitflipped, position, &offset)))
     flipped = (struct command) {.command = 5, .count = count, .value = offset};
-  if (count = scan_backwards(data, length - position, position, &offset))
+  if ((count = scan_backwards(data, length - position, position, &offset)))
     backwards = (struct command) {.command = 6, .count = count, .value = offset};
   struct command command;
   switch (flags / 24) {