]> Shamusworld >> Repos - rln/commitdiff
Fixed makefile to do automagic platform detection.
authorJames Hammons <jlhamm@acm.org>
Thu, 29 Dec 2011 16:51:26 +0000 (16:51 +0000)
committerJames Hammons <jlhamm@acm.org>
Thu, 29 Dec 2011 16:51:26 +0000 (16:51 +0000)
makefile
rln.c

index e9e579778902db06817235f94ad18c3e0aae0f13..e784557287dae6fbee56df1d9bc33828ccde7ddb 100644 (file)
--- a/makefile
+++ b/makefile
@@ -5,9 +5,25 @@ CC = gcc
 PROGNAME = rln 
 LIBS = 
 
+# Figure out which system we're compiling for, and set the appropriate variables
+
+OSTYPE := $(shell uname -a)
+
+ifeq "$(findstring Msys,$(OSTYPE))" "Msys"                     # Win32
+
+OSDEFINE   := WIN32
+
+else                                                                                   # ???
+
+OSDEFINE   := __GCCUNIX__
+
+endif
+
+
 # Change this to -DWIN32 for Windows :-)
-CFLAGS = -g -I. -D__GCCUNIX__
+#CFLAGS = -g -I. -D__GCCUNIX__
 #CFLAGS = -g -I. -DWIN32
+CFLAGS = -g -I. -D$(OSDEFINE)
 
 SRCS = rln.c 
 
diff --git a/rln.c b/rln.c
index da8fb781ef61c6c6ddf4da633c9521db458ded10..beb8c9330983fe94c8eab7b4bb288093ba5bb27d 100644 (file)
--- a/rln.c
+++ b/rln.c
@@ -950,7 +950,8 @@ int dofile(char * fname, int flag, char * sym)
        // Reached maximum file handles
        if (hd == NHANDLES)
        {
-               if (flush_handles()) return 1;
+               if (flush_handles())
+                       return 1;
        }
 
        // Attempt to open input file
@@ -2112,7 +2113,7 @@ int doinclude(char * fname, int handle, char * sym1, char * sym2, int segment)
        unsigned symtype = 0;
 
        fsize = FSIZE(handle);                                   // Get size of include file
-       dsize = (fsize+secalign) & ~secalign;                     // Round up to a alignment boundary
+       dsize = (fsize + secalign) & ~secalign;                   // Round up to a alignment boundary
 
        sym1len = strlen(sym1) + 1;                              // Get sym1 length + null termination
        sym2len = strlen(sym2) + 1;                              // Get sym2 length + null termination
@@ -2129,7 +2130,7 @@ int doinclude(char * fname, int handle, char * sym1, char * sym2, int segment)
        }
 
        // Read in binary data
-       if (read(handle, ptr+32, fsize) != fsize)
+       if (read(handle, ptr + 32, fsize) != fsize)
        {
                printf("File read error on %s\n", fname);
                close(handle);