diff --git a/tools/Makefile b/tools/Makefile
index b6b3883..32f0278 100644
--- a/tools/Makefile
+++ b/tools/Makefile
@@ -6,7 +6,8 @@
 #                     \/            \/     \/    \/            \/
 # $Id: Makefile 18359 2008-08-28 13:37:37Z mcuelenaere $
 #
-CFLAGS := -O -g -W -Wall -Wshadow -pedantic
+CFLAGS := -O -g -W -Wall -Wshadow -U_FORTIFY_SOURCE -std=c99
+SDLCFLAGS := `sdl-config --cflags`
 LDFLAGS := -g

 .PHONY: rbspeexenc uclpack
@@ -66,14 +67,24 @@ lngdump: lngdump.c
 ipod_fw:	ipod_fw.c
 	$(SILENT)$(CC) $(CFLAGS) $+ -o $@

-database: database.c ../apps/tagcache.c ../apps/metadata.c \
+database: database.c  \
+../apps/misc.c \
+../apps/metadata/a52.c ../apps/metadata/adx.c ../apps/metadata/aiff.c \
+../apps/metadata/ape.c ../apps/metadata/asap.c ../apps/metadata/asf.c \
+../apps/metadata/flac.c ../apps/metadata/mod.c ../apps/metadata/monkeys.c \
+../apps/metadata/mp4.c ../apps/metadata/mpc.c ../apps/metadata/ogg.c \
+../apps/metadata/sid.c ../apps/metadata/spc.c ../apps/metadata/vorbis.c \
+../apps/metadata/wave.c ../apps/metadata/wavpack.c \
+../apps/metadata/metadata_common.c \
+../firmware/kernel.c ../firmware/thread.c \
 ../firmware/id3.c ../firmware/common/unicode.c \
-../firmware/common/crc32.c ../uisimulator/common/io.c \
+../firmware/common/crc32.c  ../uisimulator/common/io.c \
 ../firmware/mp3data.c ../firmware/logf.c ../firmware/replaygain.c \
-../firmware/common/structec.c
-	$(SILENT)$(CC) $(CFLAGS) -I../firmware/export -iquote ../firmware/include \
+../firmware/common/structec.c ../apps/tagcache.c ../apps/metadata.c
+	$(SILENT)$(CC) $(CFLAGS) $(SDLCFLAGS) -I../firmware/export -iquote../firmware/include \
+-I../apps -I../uisimulator/sdl -I../apps/metadata \
 -D__PCTOOL__ -DHAVE_TAGCACHE -DROCKBOX_HAS_LOGF -DSIMULATOR \
--DCONFIG_CODEC=1 -ldl -I../apps $+ -o $@
+-DCONFIG_CODEC=1 -ldl $+ -o $@

 checkwps: checkwps.c ../apps/gui/wps_parser.c ../apps/gui/wps_debug.c ../firmware/common/ctype.c ../apps/misc.c ../apps/recorder/bmp.c
 	$(SILENT)$(CC) $(CFLAGS) -I ../apps/gui -I../firmware/export \