From 35f15eb06c1c82a7d68572e028373adcd4a0805a Mon Sep 17 00:00:00 2001 From: Morten Delenk Date: Sat, 24 Jan 2015 09:46:35 +0100 Subject: [PATCH] Added Linux support. +Makefile was changed, to produce dispel under linux + mac os and dispel.exe under Windows. +Added make install and make uninstall --- Makefile | 18 +++++++++++++++--- main.c | 10 +++++++--- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index c644800..99548c6 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,16 @@ CFLAGS=-Wall -O2 LDFLAGS= SOURCES=main.c 65816.c 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) $(EXECUTABLE): $(OBJECTS) @@ -12,6 +20,10 @@ $(EXECUTABLE): $(OBJECTS) .c.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: rm *.o ${EXECUTABLE} diff --git a/main.c b/main.c index 44b1dca..ea5d4e2 100644 --- a/main.c +++ b/main.c @@ -11,8 +11,12 @@ #ifdef __APPLE__ #include #else +#ifdef __linux__ +#include +#else #include #endif +#endif #include "dispel.h" @@ -275,12 +279,12 @@ int main(int argc, char *argv[]) } // Read the file into memory -#ifdef __APPLE__ - fseek(fin, 0L, SEEK_END); +#if defined(__APPLE__) || defined(__linux__) + fseek(fin, 0L, SEEK_END); //Apple and linux code len = ftell(fin); fseek(fin, 0L, SEEK_SET); #else - len = filelength(fileno(fin)); + len = filelength(fileno(fin)); //Windows code #endif // Make sure the image is big enough