As part of a push towards making RPCEmu packageable, I've spent today
tidying up its use of paths.  The patch below still has a few rough edges,
but it makes RPCEmu much more compliant with things like the Debian
Filesystem Hierarchy Guidelines.

I've added some preprocessor definitions to the build process:

CONFIG_DIR: The directory in which the rpc.cfg and any other configuration
file lives
CMOS_DIR: The directory in which CMOS RAM dumps are read from and saved
(currently only file is cmos.ram)
ARMCODE_DIR: The directory to executable ARM code - subdirectories are
'roms' and 'poduleroms'
DRIVES_DIR: Hard disc and CD images, and HostFS mounts.  Contents might be
'hd4.hdf', 'boot.adf'[1], 'notboot.adf', 'hostfs', 'cdimage.iso'.  On Unix
I'd envisage that this might contain symbolic links to wherever these
different bits might be (hostfs could be a USB stick, for example)
LOG_DIR: Where logfiles are emitted

[1] I fixed a discrepancy where there's a table at the top of a file to set
the floppy file names, but then they're hardcoded elsewhere.

CONFIG_DIR and LOG_DIR are fixed at build time - the latter only because
there are lots of places in the code that emit logfiles and I was too lazy
to change them all.  The configuration file can now override the pathnames
of the others:

armcode_dir = /home/fred/riscos
drives_dir = /mnt/rpc
cmos_dir = /tmp

Then I've added some autoconf stuff to define these based on the usual
installation directory settings to ./configure (see Makefile.am)

So to install rpcemu system-wide it should be a case of:
aclocal;automake;autoconf
./configure
(use --prefix=/somewhere if you don't want it to go in /usr/local)
make
sudo make install

By default configure will put things in:
CONFIG_DIR=/usr/local/etc/rpcemu/
CMOS_DIR=/usr/local/var/lib/rpcemu/
ARMCODE_DIR=/usr/local/share/rpcemu/
DRIVES_DIR=/usr/local/var/lib/rpcemu/
LOG_DIR=/usr/local/var/log/rpcemu/
and install the binary as /usr/local/bin/rpcemu

Any potential packager can just shuffle these around for wherever the files
should go, most simply by changing the options to ./configure (things like
--localstatedir)

I've barely touched the Windows version, but it should fallback gracefully
if none of these paths are defined, or the lines are missing in the config
file.  The Windows Makefile can just define these macros to move things
around as it likes.

To build it the old way under Unix (ie all files in the one directory), do:
./configure --enable-portableinstall
That fails to define any of the settings so it should fallback to the old
behaviour (but the configuration file settings will still work if present).

I won't have any more time to work on this for some weeks, so thought I'd
post it and see what people think...

Theo
Index: rpc.cfg
===================================================================
--- rpc.cfg	(revision 135)
+++ rpc.cfg	(working copy)
@@ -8,3 +8,6 @@
 cpu_type = SA110
 mem_size = 16
 ipaddress = 172.31.0.1
+#armcode_dir = .
+#drives_dir = .
+#cmos_dir = .
Index: hostfs/hostfs.txt
===================================================================
--- hostfs/hostfs.txt	(revision 0)
+++ hostfs/hostfs.txt	(revision 0)
@@ -0,0 +1,2 @@
+This directory called 'hostfs' contains files that will be visible under
+HostFS in the emulator.  Put files you want to share with RISC OS here.
Index: src/icside.c
===================================================================
--- src/icside.c	(revision 135)
+++ src/icside.c	(working copy)
@@ -61,7 +61,7 @@
 {
 /*        FILE *f;
         char fn[512];
-        append_filename(fn,exname,"zidefs",sizeof(fn));
+        append_filename(fn,drivesdir,"zidefs",sizeof(fn));
         f=fopen(fn,"rb");
         if (!f)
         {
Index: src/arm.c
===================================================================
--- src/arm.c	(revision 135)
+++ src/arm.c	(working copy)
@@ -380,7 +380,7 @@
         }
         r15mask=0x3FFFFFC;
 //        if (!olog)
-//           olog=fopen("armlog.txt","wt");
+//           olog=fopen(LOG_DIR "armlog.txt","wt");
         pccache=0xFFFFFFFF;
         updatemode(SUPERVISOR);
         cpsr=15;
@@ -471,7 +471,7 @@
 //        return;
         if (indumpregs) return;
         indumpregs=1;
-//        f=fopen("ram.dmp","wb");
+//        f=fopen(LOG_DIR "ram.dmp","wb");
         sprintf(s,"R 0=%08X R 4=%08X R 8=%08X R12=%08X\nR 1=%08X R 5=%08X R 9=%08X R13=%08X\nR 2=%08X R 6=%08X R10=%08X R14=%08X\nR 3=%08X R 7=%08X R11=%08X R15=%08X\n%i %s\n%08X %08X %08X",armregs[0],armregs[4],armregs[8],armregs[12],armregs[1],armregs[5],armregs[9],armregs[13],armregs[2],armregs[6],armregs[10],armregs[14],armregs[3],armregs[7],armregs[11],armregs[15],ins,(mmu)?"MMU enabled":"MMU disabled",oldpc,oldpc2,oldpc3);
 //        error("%s",s);
         rpclog("%s",s);
@@ -480,7 +480,7 @@
 //        fwrite(ram,0x400000,1,f);
 //        fclose(f);
 memmode=1;
-/*        f=fopen("kernel.dmp","wb");
+/*        f=fopen(LOG_DIR "kernel.dmp","wb");
         for (c=0xC0000000;c<0xC0200000;c+=4096)
         {
                 armirq=0;
@@ -493,12 +493,12 @@
                 }
         }
         fclose(f);*/
-/*        f=fopen("ram.dmp","wb");
+/*        f=fopen(LOG_DIR "ram.dmp","wb");
         for (c=0x8000;c<0x60000;c++)
             putc(readmemb(c),f);
         fclose(f);*/
 
-/*        f=fopen("ram30.dmp","wb");
+/*        f=fopen(LOG_DIR "ram30.dmp","wb");
         for (c=0x2228000;c<0x2229000;c+=4)
         {
                 templ=readmeml(c);
@@ -508,7 +508,7 @@
                 putc(templ>>24,f);
         }
         fclose(f);
-        f=fopen("ram31.dmp","wb");
+        f=fopen(LOG_DIR "ram31.dmp","wb");
         for (c=(PC-0x1000);c<(PC+0x1000);c+=4)
         {
                 templ=readmeml(c);
@@ -518,7 +518,7 @@
                 putc(templ>>24,f);
         }
         fclose(f);
-        f=fopen("ram32.dmp","wb");
+        f=fopen(LOG_DIR "ram32.dmp","wb");
         for (c=(PC&~0x3FF);c<((PC&~0x3FF)+0x400);c+=4)
         {
                 templ=pccache2[c>>2];
@@ -528,12 +528,12 @@
                 putc(templ>>24,f);
         }
         fclose(f);
-        f=fopen("ram1c0.dmp","wb");
+        f=fopen(LOG_DIR"ram1c0.dmp","wb");
         for (c=0x1C01C00;c<0x1C02000;c++)
             putc(readmemb(c),f);
         fclose(f);
-        f=fopen("ram0.dmp","wb");
-        ff=fopen("ram02.dmp","wb");
+        f=fopen(LOG_DIR "ram0.dmp","wb");
+        ff=fopen(LOG_DIR"ram02.dmp","wb");
         for (c=0;c<0x800;c+=4)
         {
                 templ=readmeml(c);
@@ -548,7 +548,7 @@
         }
         fclose(ff);
         fclose(f);
-        f=fopen("program.dmp","wb");
+        f=fopen(LOG_DIR "program.dmp","wb");
         armirq=0;
 //        databort=0;
         for (c=0;c<0x40000;c++)
@@ -2720,7 +2720,7 @@
                                                         templ=armregs[15]&0x3FFFFFC;
                                                         armregs[15]=((GETADDR(RN)^rotate2(opcode))&0xFC000003)|templ;
                                                 if ((armregs[cpsr]&mmask)!=mode) updatemode(armregs[cpsr]&mmask);
-//                                                        if (!olog) olog=fopen("armlog.txt","wt");
+//                                                        if (!olog) olog=fopen(LOG_DIR "armlog.txt","wt");
 //                                                        sprintf(s,"TEQP %08X %i\n",armregs[15],getline());
 //                                                        fputs(s,olog);
                                                 }
@@ -3637,7 +3637,7 @@
                                         //cycles-=3;
 /*                                        if (RD==7)
                                         {
-                                                if (!olog) olog=fopen("armlog.txt","wt");
+                                                if (!olog) olog=fopen(LOG_DIR "armlog.txt","wt");
                                                 sprintf(s,"LDRB R7 %02X,%07X\n",armregs[7],PC);
                                                 fputs(s,olog);
                                         }*/
Index: src/configure.ac
===================================================================
--- src/configure.ac	(revision 135)
+++ src/configure.ac	(working copy)
@@ -78,6 +78,24 @@
 AC_C_BIGENDIAN(, , AC_MSG_ERROR(unknown endianness))
 AC_ISC_POSIX
 
+AC_ARG_ENABLE(portableinstall,
+	      AC_HELP_STRING([--enable-portableinstall], [build that can run from anywhere in the filesystem]))
+ AM_CONDITIONAL(PORTABLE_INSTALL, [test "$enable_portableinstall" = "yes"])
+
+
+
+#AC_MSG_CHECKING([for ROMs path])
+#AC_ARG_ENABLE(rom-path,
+#	      AC_HELP_STRING([--rom-path], [path for OS ROMs]))
+#if test "$rom_path" = "yes"; then
+#   CFLAGS="$CFLAGS -D$rom_path"
+#   AC_MSG_RESULT([yes])
+#else
+#   AC_MSG_RESULT([no])
+#fi
+
+
+
 # Do not run test for Allegro with Win32/MinGW version, as binary builds have
 # `allegro-config' missing.
 # NOTE: For the following Autoconf macro to be supported, you need to extract
Index: src/rpcemu.c
===================================================================
--- src/rpcemu.c	(revision 135)
+++ src/rpcemu.c	(working copy)
@@ -40,6 +40,20 @@
 const char *username = NULL;
 const char *ipaddress = NULL;
 
+const char *drivesdir = NULL;
+const char *cmosdir = NULL;
+const char *armcodedir = NULL;
+
+#ifndef DRIVES_DIR
+#define DRIVES_DIR exname
+#endif
+#ifndef CMOS_DIR
+#define CMOS_DIR exname
+#endif
+#ifndef ARMCODE_DIR
+#define ARMCODE_DIR exname
+#endif
+
 void loadconfig();
 void saveconfig();
 
@@ -61,11 +75,14 @@
 {
         int c;
         char *p;
-        get_executable_name(exname,511);
+        char driveimage[MAX_PATH];
+
+        get_executable_name(exname,MAX_PATH);
         p=get_filename(exname);
         *p=0;
-        append_filename(HOSTFS_ROOT,exname,"hostfs",511);
-        for (c=0;c<511;c++)
+        loadconfig();
+        append_filename(HOSTFS_ROOT,drivesdir,"hostfs",MAX_PATH);
+        for (c=0;c<MAX_PATH;c++)
         {
                 if (HOSTFS_ROOT[c]=='\\')
                    HOSTFS_ROOT[c]='/';
@@ -87,12 +104,13 @@
         reseti2c();
 //printf("i2C reset!\n");
         loadcmos();
-        loadadf("boot.adf",0);
-        loadadf("notboot.adf",1);
+        append_filename(driveimage,drivesdir,discname[0],MAX_PATH);
+        loadadf(driveimage,0);
+        append_filename(driveimage,drivesdir,discname[1],MAX_PATH);
+        loadadf(driveimage,1);
 //printf("About to init video...\n");
         initvideo();
 //printf("Video inited!\n");
-        loadconfig();
         initsound();
         reallocmem(rammask+1);
         initcodeblocks();
@@ -151,7 +169,11 @@
 {
         char fn[512];
         char *p;
+#ifdef CONFIG_DIR
+        append_filename(fn,CONFIG_DIR,"rpc.cfg",511);
+#else
         append_filename(fn,exname,"rpc.cfg",511);
+#endif
         set_config_file(fn);
         p=(char *)get_config_string(NULL,"mem_size",NULL);
         if (!p)                    rammask=0x7FFFFF;
@@ -188,6 +210,10 @@
         mousehackon=get_config_int(NULL,"mouse_following",1);
         username=get_config_string(NULL,"username",NULL);
         ipaddress=get_config_string(NULL,"ipaddress",NULL);
+        armcodedir=get_config_string(NULL,"armcode_dir",ARMCODE_DIR);
+        cmosdir=get_config_string(NULL,"cmos_dir",CMOS_DIR);
+        drivesdir=get_config_string(NULL,"drives_dir",DRIVES_DIR);
+//printf("cmosdir=%s\narmcodedir=%s\ndrivesdir=%s\n",cmosdir,armcodedir,drivesdir);
 }
 
 void saveconfig()
@@ -215,4 +241,8 @@
         set_config_int(NULL,"cdrom_type",cdromtype);
         set_config_string(NULL,"cdrom_iso",isoname);
         set_config_int(NULL,"mouse_following",mousehackon);
+/*        set_config_string(NULL,"armcode_dir",armcodedir);
+        set_config_string(NULL,"cmos_dir",cmosdir);
+        set_config_string(NULL,"drives_dir",drivesdir);
+*/
 }
Index: src/rpcemu.h
===================================================================
--- src/rpcemu.h	(revision 135)
+++ src/rpcemu.h	(working copy)
@@ -111,6 +111,9 @@
 extern int stretchmode;
 extern const char *username;
 extern const char *ipaddress;
+extern const char *armcodedir;
+extern const char *drivesdir;
+extern const char *cmosdir;
 
 extern uint32_t soundaddr[4];
 
@@ -127,6 +130,11 @@
 extern int quited;
 
 extern char exname[512];
+
+#ifndef LOG_DIR
+#define LOG_DIR
+#endif
+
 extern int timetolive;
 /*rpcemu.c*/
 extern void fatal(const char *format, ...);
@@ -149,6 +157,7 @@
 extern int cdromtype;
 
 
+#define MAX_PATH 512
 
 #if defined i386 || defined __i386 || defined __i386__ || defined _X86_ || defined WIN32 || defined _WIN32 || defined _WIN32 || defined _MSC_VER
 	#ifdef _MSC_VER
Index: src/ide.c
===================================================================
--- src/ide.c	(revision 135)
+++ src/ide.c	(working copy)
@@ -67,20 +67,23 @@
 
 void loadhd(int d, char *fn)
 {
+        char hdpath[MAX_PATH];
+/* look in our configured drives directory for the HD image file*/
+        append_filename(hdpath,drivesdir,fn,MAX_PATH);
         if (!hdfile[d])
         {
-                hdfile[d]=fopen(fn,"rb+");
+                hdfile[d]=fopen(hdpath,"rb+");
                 if (!hdfile[d])
                 {
-                        hdfile[d]=fopen64(fn,"rb+");
+                        hdfile[d]=fopen64(hdpath,"rb+");
                         if (!hdfile[d])
                         {
-                                hdfile[d]=fopen(fn,"wb");
-                                if (!hdfile[d]) fatal("Cannot create file %s", fn);
+                                hdfile[d]=fopen(hdpath,"wb");
+                                if (!hdfile[d]) fatal("Cannot create file %s", hdpath);
                                 putc(0,hdfile[d]);
                                 fclose(hdfile[d]);
-                                hdfile[d]=fopen64(fn,"rb+");
-                                if (!hdfile[d]) fatal("Cannot open file %s", fn);
+                                hdfile[d]=fopen64(hdpath,"rb+");
+                                if (!hdfile[d]) fatal("Cannot open file %s", hdpath);
                         }
                 }
                 switch (d)
Index: src/cmos.c
===================================================================
--- src/cmos.c	(revision 135)
+++ src/cmos.c	(working copy)
@@ -45,25 +45,27 @@
 void loadcmos()
 {
         char fn[512];
-        append_filename(fn,exname,"cmos.ram",511);
+        append_filename(fn,cmosdir,"cmos.ram",511);
         cmosf=fopen(fn,"rb");
 
 	if (!cmosf) {
-          fprintf(stderr, "Could not open CMOS file '%s': %s\n", fn, strerror(errno));
-	  exit(EXIT_FAILURE);
+          fprintf(stderr, "Could not open CMOS file '%s', zeroing CMOS: %s\n", fn, strerror(errno));
+          memset(cmosram,0,256);
+//	  exit(EXIT_FAILURE);
         }
-
-        fread(cmosram,256,1,cmosf);
-        fclose(cmosf);
+        else
+        {
+          fread(cmosram,256,1,cmosf);
+          fclose(cmosf);
+        }
         cmosgettime();
-//        memset(cmosram,0,256);
 }
 
 void savecmos()
 {
         char fn[512];
-        append_filename(fn,exname,"cmos.ram",511);
-        cmosf=fopen("cmos.ram","wb");
+        append_filename(fn,cmosdir,"cmos.ram",511);
+        cmosf=fopen(fn,"wb");
 //        for (c=0;c<256;c++)
 //            putc(cmosram[(c-0x40)&0xFF],cmosf);
         fwrite(cmosram,256,1,cmosf);
Index: src/rpc-dos.c
===================================================================
--- src/rpc-dos.c	(revision 135)
+++ src/rpc-dos.c	(working copy)
@@ -62,7 +62,7 @@
 {
    char buf[256];
    return;
-if (!arclog) arclog=fopen("rpclog.txt","wt");
+if (!arclog) arclog=fopen(LOG_DIR "rpclog.txt","wt");
    va_list ap;
    va_start(ap, format);
    vsprintf(buf, format, ap);
@@ -139,7 +139,7 @@
         install_timer();
         install_mouse();
 infocus=0;
-//        arclog=fopen("arclog.txt","wt");
+//        arclog=fopen(LOG_DIR "arclog.txt","wt");
         if (startrpcemu())
            return -1;
 	//startblitthread();
Index: src/rpc-win.c
===================================================================
--- src/rpc-win.c	(revision 135)
+++ src/rpc-win.c	(working copy)
@@ -74,7 +74,7 @@
 {
    char buf[1024];
 //return;
-   if (!arclog) arclog=fopen("rlog.txt","wt");
+   if (!arclog) arclog=fopen(LOG_DIR "rlog.txt","wt");
    if (!arclog) return;
    va_list ap;
    va_start(ap, format);
@@ -336,7 +336,7 @@
         install_timer();
         install_mouse();
 infocus=0;
-//        arclog=fopen("arclog.txt","wt");
+//        arclog=fopen(LOG_DIR "arclog.txt","wt");
         if (startrpcemu())
            return -1;
         opendlls();
Index: src/rpc-linux.c
===================================================================
--- src/rpc-linux.c	(revision 135)
+++ src/rpc-linux.c	(working copy)
@@ -113,7 +113,7 @@
 {
    char buf[256];
 //   return;
-if (!arclog) arclog=fopen("rpclog.txt","wt");
+if (!arclog) arclog=fopen(LOG_DIR "rpclog.txt","wt");
    va_list ap;
    va_start(ap, format);
    vsprintf(buf, format, ap);
Index: src/ArmDynarec.c
===================================================================
--- src/ArmDynarec.c	(revision 135)
+++ src/ArmDynarec.c	(working copy)
@@ -359,7 +359,7 @@
         }
         r15mask=0x3FFFFFC;
 //        if (!olog)
-//           olog=fopen("armlog.txt","wt");
+//           olog=fopen(LOG_DIR "armlog.txt","wt");
         pccache=0xFFFFFFFF;
         updatemode(SUPERVISOR);
         cpsr=15;
@@ -450,7 +450,7 @@
 //        return;
         if (indumpregs) return;
         indumpregs=1;
-//        f=fopen("ram.dmp","wb");
+//        f=fopen(LOG_DIR "ram.dmp","wb");
         sprintf(s,"R 0=%08X R 4=%08X R 8=%08X R12=%08X\nR 1=%08X R 5=%08X R 9=%08X R13=%08X\nR 2=%08X R 6=%08X R10=%08X R14=%08X\nR 3=%08X R 7=%08X R11=%08X R15=%08X\n%u %s\n%08X %08X %08X",armregs[0],armregs[4],armregs[8],armregs[12],armregs[1],armregs[5],armregs[9],armregs[13],armregs[2],armregs[6],armregs[10],armregs[14],armregs[3],armregs[7],armregs[11],armregs[15],ins,(mmu)?"MMU enabled":"MMU disabled",oldpc,oldpc2,oldpc3);
 //        error("%s",s);
         rpclog("%s",s);
@@ -459,7 +459,7 @@
 //        fwrite(ram,0x400000,1,f);
 //        fclose(f);
 memmode=1;
-/*        f=fopen("kernel.dmp","wb");
+/*        f=fopen(LOG_DIR "kernel.dmp","wb");
         for (c=0xC0000000;c<0xC0200000;c+=4096)
         {
                 armirq=0;
@@ -472,7 +472,7 @@
                 }
         }
         fclose(f);
-        f=fopen("bsdkernel.dmp","wb");
+        f=fopen(LOG_DIR "bsdkernel.dmp","wb");
         for (c=0xF0000000;c<0xF0800000;c+=4096)
         {
                 armirq=0;
@@ -490,7 +490,7 @@
                 }
         }
         fclose(f);
-        f=fopen("prog.dmp","wb");
+        f=fopen(LOG_DIR "prog.dmp","wb");
         for (c=0x40000000;c<0x40200000;c+=4096)
         {
                 armirq=0;
@@ -503,28 +503,28 @@
                 }
         }
         fclose(f);
-        f=fopen("ram.dmp","wb");
+        f=fopen(LOG_DIR "ram.dmp","wb");
         for (c=0x8000;c<0x70000;c++)
             putc(readmemb(c),f);
         fclose(f);*/
-        f=fopen("ram0.dmp","wb");
+        f=fopen(LOG_DIR "ram0.dmp","wb");
         for (c=0x0000;c<0x8000;c++)
             putc(readmemb(c),f);
         fclose(f);
 
-        f=fopen("ram21.dmp","wb");
+        f=fopen(LOG_DIR "ram21.dmp","wb");
         for (c=0x2100000;c<0x21FFFFF;c++)
             putc(readmemb(c),f);
         fclose(f);
-  /*      f=fopen("ram10.dmp","wb");
+  /*      f=fopen(LOG_DIR "ram10.dmp","wb");
         for (c=0x10000000;c<0x10800000;c++)
             putc(readmemb(c),f);
         fclose(f);*/
-/*        f=fopen("bsdk.dmp","wb");
+/*        f=fopen(LOG_DIR "bsdk.dmp","wb");
         for (c=0xF0000000;c<0xF0800000;c++)
             putc(readmemb(c),f);
         fclose(f);*/
-/*        f=fopen("ram31.dmp","wb");
+/*        f=fopen(LOG_DIR "ram31.dmp","wb");
         for (c=(PC-0x1000);c<(PC+0x1000);c+=4)
         {
                 templ=readmeml(c);
@@ -534,7 +534,7 @@
                 putc(templ>>24,f);
         }
         fclose(f);
-        f=fopen("ram32.dmp","wb");
+        f=fopen(LOG_DIR "ram32.dmp","wb");
         for (c=(PC&~0x3FF);c<((PC&~0x3FF)+0x400);c+=4)
         {
                 templ=pccache2[c>>2];
@@ -544,12 +544,12 @@
                 putc(templ>>24,f);
         }
         fclose(f);*/
-        f=fopen("rambsd.dmp","wb");
+        f=fopen(LOG_DIR "rambsd.dmp","wb");
         for (c=0x3D9000;c<0x3DF000;c++)
             putc(readmemb(c),f);
         fclose(f);
-/*        f=fopen("ram0.dmp","wb");
-        ff=fopen("ram02.dmp","wb");
+/*        f=fopen(LOG_DIR "ram0.dmp","wb");
+        ff=fopen(LOG_DIR "ram02.dmp","wb");
         for (c=0;c<0x800;c+=4)
         {
                 templ=readmeml(c);
@@ -564,7 +564,7 @@
         }
         fclose(ff);
         fclose(f);
-        f=fopen("program.dmp","wb");
+        f=fopen(LOG_DIR "program.dmp","wb");
         armirq=0;
 //        databort=0;
         for (c=0;c<0x40000;c++)
Index: src/podulerom.c
===================================================================
--- src/podulerom.c	(revision 135)
+++ src/podulerom.c	(working copy)
@@ -54,7 +54,7 @@
         poduleromsize = 0;
 
         getcwd(olddir,sizeof(olddir));
-        append_filename(fn,exname,"poduleroms",sizeof(fn));
+        append_filename(fn,armcodedir,"poduleroms",sizeof(fn));
         if (chdir(fn) == 0)
         {
                 finished=al_findfirst("*.*",&ff,FA_ALL&~FA_DIREC);
Index: src/Makefile.am
===================================================================
--- src/Makefile.am	(revision 135)
+++ src/Makefile.am	(working copy)
@@ -2,12 +2,55 @@
 
 bin_PROGRAMS = rpcemu
 noinst_SCRIPTS = ../rpcemu
+
+PROGRAM_NAME = rpcemu
+
+#sysconf_DATA = ../rpc.cfg
+# the place that RPCemu's configuration file lives
+rpcemuconfigdir = $(sysconfdir)/$(PROGRAM_NAME)
+# install the default config file
+rpcemuconfig_DATA = ../rpc.cfg
+
+#localstate_DATA = ../cmos.ram
+# the place the RPCemu's CMOS RAM lives
+rpcemulocalstatedir = $(localstatedir)/lib/$(PROGRAM_NAME)
+# install the default CMOS file
+rpcemulocalstate_DATA = ../cmos.ram
+
+# the place where (links to) our storage media images live
+rpcemudrivesdir = $(rpcemulocalstatedir)/
+# subdirectory for hostfs
+rpcemuhostfsdir = $(rpcemudrivesdir)/hostfs/
+# install a placeholder text file
+rpcemuhostfs_DATA = ../hostfs/hostfs.txt
+
+# the place where our ARM code lives (OS ROMs, podule ROMs, any other modules)
+rpcemuarmcodedir = $(datadir)/$(PROGRAM_NAME)
+rpcemuromdir = $(rpcemuarmcodedir)/roms
+# install the 'ROMs-go-here' text file
+rpcemurom_DATA = ../roms/roms.txt
+
+rpcemulogdir = $(localstatedir)/log/$(PROGRAM_NAME)
+# a bit of a hack - provide some file so that the log directory is created
+# since some logging functions don't check their return value and will
+# cause a segfault if the file can't be opened
+rpcemulog_DATA = ../roms/roms.txt
+
 CLEANFILES = $(noinst_SCRIPTS)
 
 ../rpcemu: rpcemu
 	cp rpcemu ..
 
+if PORTABLE_INSTALL
 rpcemu_CFLAGS = $(allegro_CFLAGS)
+else
+rpcemu_CFLAGS = $(allegro_CFLAGS) \
+	-DCONFIG_DIR=\"$(rpcemuconfigdir)/\" \
+	-DCMOS_DIR=\"$(rpcemulocalstatedir)/\" \
+	-DARMCODE_DIR=\"$(rpcemuarmcodedir)/\" \
+	-DDRIVES_DIR=\"$(rpcemudrivesdir)/\" \
+	-DLOG_DIR=\"$(rpcemulogdir)/\"
+endif
 
 # workaround for Win32 Allegro, which has `allegro-config' missing
 if OS_WIN
Index: src/romload.c
===================================================================
--- src/romload.c	(revision 135)
+++ src/romload.c	(working copy)
@@ -24,7 +24,7 @@
 	const char *dirname = "roms";
 
         getcwd(olddir,sizeof(olddir));
-        append_filename(fn,exname,dirname,sizeof(fn));
+        append_filename(fn,armcodedir,dirname,sizeof(fn));
         if (chdir(fn))
 	{
 		error("Cannot find roms directory %s",dirname);
_______________________________________________
Rpcemu mailing list
[email protected]
http://www.riscos.info/cgi-bin/mailman/listinfo/rpcemu

Reply via email to