-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Amiga support #26
base: master
Are you sure you want to change the base?
Changes from all commits
6596472
71517a1
f4b4e50
c5edda3
7f0aa49
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# Usage: | ||
# "make" - recommended: builds lib and app | ||
# "make clean" - removes all tmp files | ||
# "make lib" - builds only lib | ||
# "make app" - builds only app if lib is present | ||
|
||
CC = m68k-amigaos-gcc | ||
AR = m68k-amigaos-ar | ||
INCLUDES_APP = -Isrc -Ilib/public -I. | ||
INCLUDES_LIB = -Ilib | ||
CC_FLAGS_COMMON = -Wall -Wsign-compare -std=c11 -O3 -fomit-frame-pointer -fbaserel | ||
CC_FLAGS_APP = $(INCLUDES_APP) $(CC_FLAGS_COMMON) | ||
CC_FLAGS_LIB = $(INCLUDES_LIB) $(CC_FLAGS_COMMON) | ||
|
||
# LTO for Amiga since every optimization counts! | ||
LDFLAGS = -noixemul -flto | ||
|
||
PACKER_SRC_DIR = $(ROOT)/src | ||
TMP_DIR = tmp | ||
|
||
LIB_IGNORE = \ | ||
lib/lh_new_decoder.c \ | ||
lib/pma_common.c \ | ||
lib/bit_stream_reader.c \ | ||
lib/tree_decode.c \ | ||
lib/lha_arch_win32.c \ | ||
lib/lha_arch_unix.c | ||
|
||
LIB_SRCS = $(filter-out $(LIB_IGNORE), $(wildcard lib/*.c)) | ||
LIB_OBJS = $(addprefix $(TMP_DIR)/lib_, $(notdir $(LIB_SRCS:.c=.o))) | ||
|
||
APP_SRCS = $(wildcard src/*.c) | ||
APP_OBJS = $(addprefix $(TMP_DIR)/app_, $(notdir $(APP_SRCS:.c=.o))) | ||
|
||
#------------------------------------------------------------------------- Goals | ||
|
||
lhasa: lib app | ||
|
||
lib: lib/public/liblhasa.a | ||
|
||
app: bin/lhasa | ||
|
||
clean: | ||
@echo Removing tmp and lib contents | ||
$(RM) tmp/*.o | ||
$(RM) lib/public/liblhasa.a | ||
|
||
#----------------------------------------------------------------- How it's made | ||
|
||
tmp/lib_%.o: lib/%.c | ||
@echo Building: $< | ||
@$(CC) $(CC_FLAGS_LIB) -c -o $@ $< | ||
|
||
tmp/app_%.o: src/%.c | ||
@echo Building: $< | ||
@$(CC) $(CC_FLAGS_APP) -c -o $@ $< | ||
|
||
lib/public/liblhasa.a: $(LIB_OBJS) | ||
@echo linking $@ | ||
@$(AR) rcs $@ $(LIB_OBJS) | ||
|
||
bin/lhasa: lib/public/liblhasa.a $(APP_OBJS) | ||
@echo linking $@ | ||
@$(CC) $(CC_FLAGS_LIB) -o $@ $(APP_OBJS) -llhasa -Wall $(LDFLAGS) -Llib/public | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
/* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think if you add the name of this file to the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done! |
||
|
||
Copyright (c) 2012, Simon Howard | ||
|
||
Permission to use, copy, modify, and/or distribute this software | ||
for any purpose with or without fee is hereby granted, provided | ||
that the above copyright notice and this permission notice appear | ||
in all copies. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL | ||
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE | ||
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR | ||
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, | ||
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN | ||
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. | ||
|
||
*/ | ||
|
||
// | ||
// Architecture-specific files for compilation on Amiga. | ||
// | ||
|
||
#define _GNU_SOURCE | ||
#include "lha_arch.h" | ||
|
||
#if LHA_ARCH == LHA_ARCH_AMIGA | ||
|
||
#include <stdio.h> | ||
#include <errno.h> | ||
#include <fcntl.h> | ||
#include <unistd.h> | ||
#include <utime.h> | ||
#include <sys/stat.h> | ||
#include <sys/types.h> | ||
#include <stdlib.h> | ||
|
||
int lha_arch_vasprintf(char **result, char *fmt, va_list args) | ||
{ | ||
int len; | ||
va_list args2; | ||
va_copy(args2, args); | ||
char szTmp[2]; | ||
len = vsnprintf(szTmp, 2, fmt, args2); | ||
va_end(args2); | ||
if (len >= 0) { | ||
*result = malloc(len + 1); | ||
if (*result != NULL) { | ||
va_copy(args2, args); | ||
return vsprintf(*result, fmt, args); | ||
va_end(args2); | ||
} | ||
} | ||
*result = NULL; | ||
return -1; | ||
} | ||
|
||
void lha_arch_set_binary(FILE *handle) | ||
{ | ||
// No-op on Amiga systems: there is no difference between | ||
// "text" and "binary" files. | ||
} | ||
|
||
int lha_arch_mkdir(char *path, unsigned int unix_perms) | ||
{ | ||
return mkdir(path, unix_perms) == 0; | ||
} | ||
|
||
int lha_arch_chown(char *filename, int unix_uid, int unix_gid) | ||
{ | ||
return 1; | ||
} | ||
|
||
int lha_arch_chmod(char *filename, int unix_perms) | ||
{ | ||
return 1; | ||
} | ||
|
||
int lha_arch_utime(char *filename, unsigned int timestamp) | ||
{ | ||
struct utimbuf times; | ||
|
||
times.actime = (time_t) timestamp; | ||
times.modtime = (time_t) timestamp; | ||
|
||
return utime(filename, ×) == 0; | ||
} | ||
|
||
FILE *lha_arch_fopen(char *filename, int unix_uid, int unix_gid, int unix_perms) | ||
{ | ||
return fopen(filename, "wb"); | ||
} | ||
|
||
LHAFileType lha_arch_exists(char *filename) | ||
{ | ||
struct stat statbuf; | ||
|
||
if (stat(filename, &statbuf) != 0) { | ||
if (errno == ENOENT) { | ||
return LHA_FILE_NONE; | ||
} else { | ||
return LHA_FILE_ERROR; | ||
} | ||
} | ||
|
||
if (S_ISDIR(statbuf.st_mode)) { | ||
return LHA_FILE_DIRECTORY; | ||
} else { | ||
return LHA_FILE_FILE; | ||
} | ||
} | ||
|
||
int lha_arch_symlink(char *path, char *target) | ||
{ | ||
return 1; | ||
} | ||
|
||
#endif /* LHA_ARCH_AMIGA */ | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add the name of this file to the
EXTRA_DIST =
list inMakefile.am
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done! This file is temporary until I find a way to force autotools to not use libtool on Amiga build.