Skip to content
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

Updates allowing to improve building on linux. #13

Open
wants to merge 21 commits into
base: markusC64-v637-branch
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
958ada4
Refactor / minimize deps: move version to a separated file.
t-w May 6, 2024
0314a9f
Refactor / minimize deps: move fileio declarations to its own header.
t-w May 6, 2024
6d4940f
Refactor / minimize deps: move drive module declarations to its own h…
t-w May 6, 2024
b77e1e3
Refactor / minimize deps: move global variables' declarations to a se…
t-w May 6, 2024
bd2ff5d
Refactor / minimize deps: move global defines to a separated header.
t-w May 6, 2024
5e83f3a
fileio: minimize dependencies.
t-w May 6, 2024
7a3dd5a
nibconv: minimize dependencies.
t-w May 6, 2024
6c1d2d5
makefile (GNU): do not link opencbm to programs that not require it.
t-w May 6, 2024
1860ef5
makefile (GNU): compile first programs that do not require opencbm.
t-w May 6, 2024
c3582a6
Add main makefile (where the OS / environment should be selected).
t-w May 6, 2024
8978bc8
Fix linux makefile.
t-w May 6, 2024
75870f5
Refact / minimize deps: include opencbm only where required (nibread …
t-w May 6, 2024
c032b74
Update gitignore (add *.o and *~).
t-w May 6, 2024
4e7c396
Revert "fileio: minimize dependencies."
t-w May 6, 2024
41e3e9d
Refact / minimize deps: include opencbm only where required (cont.).
t-w May 6, 2024
c2ea414
Fix double object defs.
t-w May 6, 2024
cfa8e70
Set correct build source type.
t-w May 6, 2024
bbdfce2
gnu makefile: more warnings / compiler checks.
t-w May 6, 2024
35d159b
makefile linux: set example path to opencbm.
t-w May 6, 2024
80e1981
Fix source files' permissions.
t-w May 6, 2024
a6d31f7
mnibarch: add include guard.
t-w May 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file modified .cvsignore
100755 → 100644
Empty file.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,5 @@ WINBUILD-nibread/objfre*
/obj*
/objchk*
/objfre*
*.o
*~
31 changes: 18 additions & 13 deletions GNU/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,35 @@ dos:
CFLAGS="-I include/DOS/ $(CFLAGS)" \
EXE=".exe" \
-f GNU/Makefile \
nibread nibwrite nibconv nibscan nibrepair
nibconv nibscan nibrepair nibread nibwrite

linux:
${MAKE} CFLAGS="-I include/LINUX/ -I ${CBM_LNX_PATH}/include ${CFLAGS} -std=c99" \
${MAKE} CFLAGS="-I include/LINUX/ -I ${CBM_LNX_PATH}/include ${CFLAGS} -std=c99 -D_BSD_SOURCE" \
LDFLAGS="-L${CBM_LNX_PATH}/lib -lopencbm" \
-f GNU/Makefile \
nibread nibwrite nibconv nibscan nibrepair nibsrqtest
nibconv nibscan nibrepair nibread nibwrite nibsrqtest

win32:
${MAKE} CFLAGS="-I include/WINDOWS/ -I ${CBM_WIN_PATH}/include -D WIN32 ${CFLAGS} -std=c99" \
LDFLAGS="-L${CBM_WIN_PATH}/bin/i386/ -lopencbm" \
EXE=".exe" \
-f GNU/Makefile \
nibread nibwrite nibconv nibscan nibrepair nibsrqtest
nibconv nibscan nibrepair nibread nibwrite nibsrqtest

win64:
${MAKE} CFLAGS="-I include/WINDOWS/ -I ${CBM_WIN_PATH}/include -D WIN32 ${CFLAGS} -std=c99" \
LDFLAGS="-L${CBM_WIN_PATH}/bin/amd64/ -lopencbm" \
EXE=".exe" \
-f GNU/Makefile \
nibread nibwrite nibconv nibscan nibrepair nibsrqtest
nibconv nibscan nibrepair nibread nibwrite nibsrqtest

# Warning level. Don't reduce, fix your new code instead.
WARNS= -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wpointer-arith
WARNS= -W -Wall -Wstrict-prototypes -Wno-unused-parameter -Wpointer-arith \
-Wextra -Wconversion -pedantic \
-Werror-implicit-function-declaration \
-Wsign-conversion
# -Werror=format-security


# Common objects
OBJ=gcr.o prot.o fileio.o crc.o md5.o lz.o
Expand All @@ -89,7 +94,7 @@ buildall: ${PROG}

nibread: ${OBJ} ${NIBREAD_OBJ} ${NIBTOOLS_BIN} ${ARCH_OBJ}
${CC} -o nibread$(EXE) ${OBJ} ${NIBREAD_OBJ} ${ARCH_OBJ} ${LDFLAGS}

nibsrqtest: ${NIBSRQTEST_OBJ} ${NIBTOOLS_BIN} ${ARCH_OBJ}
${CC} -o nibsrqtest$(EXE) ${NIBSRQTEST_OBJ} ${ARCH_OBJ} ${LDFLAGS}

Expand All @@ -103,20 +108,20 @@ nibsrqtest.c: ${NIBTOOLS_BIN}
nibwrite.c: ${NIBTOOLS_BIN}

nibconv: ${OBJ} nibconv.o
${CC} -o nibconv$(EXE) nibconv.o ${OBJ} $(LDFLAGS)
${CC} -o nibconv$(EXE) nibconv.o ${OBJ}

nibrepair: ${OBJ} nibrepair.o
${CC} -o nibrepair$(EXE) nibrepair.o ${OBJ} $(LDFLAGS)
${CC} -o nibrepair$(EXE) nibrepair.o ${OBJ}

nibscan: ${OBJ} nibscan.o
${CC} -o nibscan$(EXE) nibscan.o ${OBJ} $(LDFLAGS)
${CC} -o nibscan$(EXE) nibscan.o ${OBJ}

clean:
${RM} *.o ${MNIB_BIN} *.bin *.inc nib*.exe

distclean: clean
${RM} ${PROG} *.exe

drive.o: nibtools_1541.inc nibtools_1541_ihs.inc nibtools_1571.inc nibtools_1571_ihs.inc nibtools_1571_srq.inc nibtools_1571_srq_test.inc

*.o: gcr.h nibtools.h
Expand All @@ -136,15 +141,15 @@ nibtools_1541_ihs.bin: nibtools_15x1_ihs.asm
nibtools_1571_ihs.bin: nibtools_15x1_ihs.asm
$(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $<
$(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp

nibtools_1571_srq.bin: nibtools_1571_srq.asm
$(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $<
$(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp

nibtools_1571_srq_test.bin: nibtools_1571_srq_test.asm
$(CA65) $(CA65_FLAGS) -D DRIVE=1571 -o $*.tmp $<
$(LD65) -o $@ --target none $*.tmp && rm -f $*.tmp

.bin.inc:
test -s $< && od -txC -v -An $< | \
sed 's/\([0-9a-f]\{2\}\) */0x\1,/g; $$s/,$$//' > $@
10 changes: 6 additions & 4 deletions LINUX/Makefile
Original file line number Diff line number Diff line change
@@ -1,20 +1,22 @@
# $Id: Makefile,v 1.1.1.1 2007/01/21 17:15:35 peter Exp $

RELATIVEPATH=../
include ${RELATIVEPATH}LINUX/config.make
#RELATIVEPATH=../
#include ${RELATIVEPATH}LINUX/config.make

.PHONY: all mrproper clean install uninstall install-files

OBJS = nibread.o nibwrite.o nibscan.o nibconv.o nibrepair.o nibsrqtest.o read.o write.o gcr.o prot.o crc.o drive.o fileio.o ihs.o lz.o md5.o
PROG = nibread nibwrite nibscan nibconv nibrepair nibsrqtest

CBM_LNX_PATH=../../../opencbm/OpenCBM/opencbm

all:
make -f GNU/Makefile CBM_LNX_PATH="../" linux
make -f GNU/Makefile CBM_LNX_PATH=$(CBM_LNX_PATH) linux

mrproper: clean

clean:
make -f GNU/Makefile CBM_LNX_PATH="../" distclean
make -f GNU/Makefile distclean

install-files: $(PROG)
install -m 755 -s $(PROG) $(BINDIR)
Expand Down
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@

#TARGET_ENV=GNU
TARGET_ENV=LINUX
#TARGET_ENV=WSDK

all:
make -f $(TARGET_ENV)/Makefile

clean:
make -f $(TARGET_ENV)/Makefile clean

install:
make -f $(TARGET_ENV)/Makefile install

uninstall:
make -f $(TARGET_ENV)/Makefile uninstall

.PHONY: all clean install uninstall
4 changes: 4 additions & 0 deletions drive.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include <time.h>
#include <signal.h>

#ifndef DJGPP
#include <opencbm.h>
#endif

#include "mnibarch.h"
#include "gcr.h"
#include "nibtools.h"
Expand Down
34 changes: 34 additions & 0 deletions drive.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

#ifndef DRIVE_H
#define DRIVE_H

int compare_extension(unsigned char * filename, unsigned char * extension);
unsigned char burst_read(CBM_FILE f);
void burst_write(CBM_FILE f, unsigned char c);
int burst_read_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length);
int burst_write_n(CBM_FILE f, unsigned char *Buffer, unsigned int Length);
int burst_read_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length);
int burst_write_track(CBM_FILE f, unsigned char *Buffer, unsigned int Length);
void ARCH_SIGNALDECL handle_signals(int sig);
void ARCH_SIGNALDECL handle_exit(void);
int upload_code(CBM_FILE fd, BYTE drive);
int reset_floppy(CBM_FILE fd, BYTE drive);
int init_floppy(CBM_FILE fd, BYTE drive, int bump);
int set_density(CBM_FILE fd, BYTE density);
BYTE set_bitrate(CBM_FILE fd, BYTE density);
BYTE set_default_bitrate(CBM_FILE fd, int track);
BYTE scan_track(CBM_FILE fd, int track);
void perform_bump(CBM_FILE fd, BYTE drive);
int test_par_port(CBM_FILE fd);
void send_mnib_cmd(CBM_FILE fd, BYTE cmd, BYTE *args, int num_args);
void set_full_track(CBM_FILE fd);
void motor_on(CBM_FILE fd);
void motor_off(CBM_FILE fd);
void step_to_halftrack(CBM_FILE fd, int halftrack);
int verify_floppy(CBM_FILE fd);
#ifdef DJGPP
#include <unistd.h>
int find_par_port(CBM_FILE fd);
#endif

#endif
25 changes: 25 additions & 0 deletions fileio.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

#ifndef FILEIO_H
#define FILEIO_H

void parseargs(char *argv[]);
void switchusage(void);
int load_file(char *filename, BYTE *file_buffer);
int save_file(char *filename, BYTE *file_buffer, int length);
int read_nib(BYTE *file_buffer, int file_buffer_size, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int read_nb2(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int read_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int read_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int write_nib(BYTE*file_buffer, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int write_g64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
int write_d64(char *filename, BYTE *track_buffer, BYTE *track_density, size_t *track_length);
size_t compress_halftrack(int halftrack, BYTE *track_buffer, BYTE track_density, size_t track_length);
int align_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment);
int sync_tracks(BYTE *track_buffer, BYTE *track_density, size_t *track_length, BYTE *track_alignment);
int write_dword(FILE * fd, DWORD * buf, int num);
unsigned int crc_dir_track(BYTE *track_buffer, size_t *track_length);
unsigned int crc_all_tracks(BYTE *track_buffer, size_t *track_length);
unsigned int md5_dir_track(BYTE *track_buffer, size_t *track_length, unsigned char *result);
unsigned int md5_all_tracks(BYTE *track_buffer, size_t *track_length, unsigned char *result);

#endif
Empty file modified ihs.c
100755 → 100644
Empty file.
Empty file modified ihs.h
100755 → 100644
Empty file.
12 changes: 11 additions & 1 deletion include/LINUX/mnibarch.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
#include <opencbm.h>

#ifndef MNIBARCH_H
#define MNIBARCH_H

#include <stdint.h>
#include <unistd.h>

#define delay(x) usleep((x) * 1000)
Expand All @@ -12,6 +16,12 @@ typedef unsigned char BYTE;
// __int32 and min() are needed for bitshifter.c (included by fileio.c)
typedef int32_t __int32;

#ifndef CBM_FILE
typedef int CBM_FILE;
#endif

#ifndef min
#define min(x, y) ((x) > (y) ? (y) : (x))
#endif

#endif
Empty file modified lz.c
100755 → 100644
Empty file.
Empty file modified lz.h
100755 → 100644
Empty file.
6 changes: 5 additions & 1 deletion nibconv.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@

#include "mnibarch.h"
#include "gcr.h"
#include "nibtools.h"
#include "drive.h"
#include "fileio.h"
#include "lz.h"
#include "nibtools_version.h"
#include "prot.h"

void usage(void);

int _dowildcard = 1;

BYTE compressed_buffer[(MAX_HALFTRACKS_1541 + 2) * NIB_TRACK_LENGTH];
Expand Down
4 changes: 4 additions & 0 deletions nibread.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
#include <time.h>
#include <ctype.h>

#ifndef DJGPP
#include <opencbm.h>
#endif

#include "mnibarch.h"
#include "gcr.h"
#include "nibtools.h"
Expand Down
4 changes: 4 additions & 0 deletions nibsrqtest.c
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
#include <time.h>
#include <ctype.h>

#ifndef DJGPP
#include <opencbm.h>
#endif

#include "mnibarch.h"
#include "gcr.h"
#include "nibtools.h"
Expand Down
Loading