Added Linux support.

+Makefile was changed, to produce dispel under linux + mac os and dispel.exe
 under Windows.
+Added make install and make uninstall
This commit is contained in:
Morten Delenk 2015-01-24 09:46:35 +01:00
parent 4829ae2218
commit 35f15eb06c
2 changed files with 22 additions and 6 deletions

View file

@ -3,8 +3,16 @@ CFLAGS=-Wall -O2
LDFLAGS= LDFLAGS=
SOURCES=main.c 65816.c SOURCES=main.c 65816.c
OBJECTS=$(SOURCES:.c=.o) OBJECTS=$(SOURCES:.c=.o)
EXECUTABLE=dispel.exe CAN_INSTALL = no
ifeq ($(OS),Windows_NT)
EXECUTABLE = dispel.exe
else
EXECUTABLE = dispel
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S),Linux)
CAN_INSTALL = yes
endif
endif
all: $(SOURCES) $(EXECUTABLE) all: $(SOURCES) $(EXECUTABLE)
$(EXECUTABLE): $(OBJECTS) $(EXECUTABLE): $(OBJECTS)
@ -12,6 +20,10 @@ $(EXECUTABLE): $(OBJECTS)
.c.o: .c.o:
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
install:
cp -v $(EXECUTABLE) /usr/bin
#FIXME It ALWAYS copies dispel to /usr/bin, regardless of OS
uninstall:
rm -rf /usr/bin/$(EXECUTABLE)
clean: clean:
rm *.o ${EXECUTABLE} rm *.o ${EXECUTABLE}

10
main.c
View file

@ -11,8 +11,12 @@
#ifdef __APPLE__ #ifdef __APPLE__
#include <sys/uio.h> #include <sys/uio.h>
#else #else
#ifdef __linux__
#include <sys/io.h>
#else
#include <io.h> #include <io.h>
#endif #endif
#endif
#include "dispel.h" #include "dispel.h"
@ -275,12 +279,12 @@ int main(int argc, char *argv[])
} }
// Read the file into memory // Read the file into memory
#ifdef __APPLE__ #if defined(__APPLE__) || defined(__linux__)
fseek(fin, 0L, SEEK_END); fseek(fin, 0L, SEEK_END); //Apple and linux code
len = ftell(fin); len = ftell(fin);
fseek(fin, 0L, SEEK_SET); fseek(fin, 0L, SEEK_SET);
#else #else
len = filelength(fileno(fin)); len = filelength(fileno(fin)); //Windows code
#endif #endif
// Make sure the image is big enough // Make sure the image is big enough