\r
        n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
        if (n < 0) {\r
+               char *t;\r
                lprintf("menu_loop_romsel failed, dir: %s\n", curr_path);\r
 \r
                // try root\r
-               plat_get_root_dir(curr_path, len);\r
+               t = getcwd(curr_path, len);\r
+               if (t == NULL)\r
+                       plat_get_root_dir(curr_path, len);\r
                n = scandir(curr_path, &namelist, scandir_filter, (void *)scandir_cmp);\r
                if (n < 0) {\r
                        // oops, we failed\r
 
-\r
 # you may or may not need to change this\r
 #devkit_path = x:/stuff/dev/devkitgp2x/\r
-devkit_path = /usr/local/devkitPro/devkitGP2X/\r
+devkit_path ?= $(HOME)/opt/devkitGP2X/\r
 lgcc_path = $(devkit_path)lib/gcc/arm-linux/4.0.3/\r
-export CROSS = arm-linux-\r
+CROSS = arm-linux-\r
 #CROSS = $(devkit_path)bin/arm-linux-\r
 \r
 # settings\r
 #up = 1\r
 \r
-DEFINC = -I../.. -I. -D__GP2X__ -DARM\r
-# -ftracer\r
-COPT_COMMON = -static -s -O2 -Wall -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
-CFLAGS = $(COPT_COMMON) $(DEFINC) -mcpu=arm940t -mtune=arm940t\r
+CFLAGS += -O2 -Wall -fomit-frame-pointer -fstrict-aliasing -ffast-math\r
+CFLAGS += -I../.. -I. -D__GP2X__ -DARM\r
+CFLAGS += -mcpu=arm940t -mtune=arm940t\r
+LDFLAGS = -static -s -e code940 -Ttext 0x0 -L$(lgcc_path) -lgcc\r
+\r
 GCC = $(CROSS)gcc\r
 STRIP = $(CROSS)strip\r
 AS = $(CROSS)as\r
 \r
 code940.elf : $(OBJS940) ../../common/helix/$(CROSS)helix-mp3.a\r
        @echo ">>>" $@\r
-       $(LD) -static -e code940 -Ttext 0x0 $^ -L$(lgcc_path) -lgcc -o $@ -Map code940.map\r
+       $(LD) $^ $(LDFLAGS) -o $@ -Map code940.map\r
 \r
 940ym2612.o : ../../../pico/sound/ym2612.c\r
        @echo ">>>" $@\r
        $(RM) code940.elf $(OBJS940) code940.map\r
 \r
 \r
+##\r
 OBJSMP3T = mp3test.o ../gp2x.o ../asmutils.o ../usbjoy.o\r
 \r
 mp3test.gpe : $(OBJSMP3T) ../helix/helix_mp3.a\r
 cleanmp3test:\r
        $(RM) $(OBJSMP3T) mp3test.gpe\r
 \r
-# uClibc/e_pow.o : uClibc/e_pow.c\r
-#      @echo $<\r
-#      @$(GCC) $(CFLAGS) -fno-profile-generate -c $< -o $@\r
-\r
-# uClibc/e_sqrt.o : uClibc/e_sqrt.c\r
-#      @echo $<\r
-#      @$(GCC) $(CFLAGS) -fno-profile-generate -c $< -o $@\r