Initial commit, basically just a 'hello world' with a Makefile
This commit is contained in:
parent
0da73eddc6
commit
840f75020a
6 changed files with 94 additions and 0 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -36,6 +36,7 @@
|
|||
*.i*86
|
||||
*.x86_64
|
||||
*.hex
|
||||
*.img
|
||||
|
||||
# Debug files
|
||||
*.dSYM/
|
||||
|
|
|
|||
64
Makefile
Normal file
64
Makefile
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
# Directory layout
|
||||
SRCDIR = src
|
||||
OBJDIR = obj
|
||||
INCDIR = include
|
||||
|
||||
# Compiler and flags
|
||||
CC = wcc386
|
||||
LD = wlink
|
||||
CFLAGS = -zq -i=$(INCDIR)
|
||||
|
||||
# Project name (root) — everything else derives from this
|
||||
NAME = dspace
|
||||
TARGET = $(NAME).exe
|
||||
IMG = $(NAME).img
|
||||
|
||||
# Deploy location for testing in DOSBox-X
|
||||
DOSBOX_DRIVE = ~/DosBox-x/C_Drive
|
||||
|
||||
# OpenWatcom DOS extender stub, needed on the disk image alongside TARGET
|
||||
DOS4GW = ~/openwatcom_c/binw/dos4gw.exe
|
||||
|
||||
# Disk image geometry (1.44MB floppy, FAT12)
|
||||
IMG_BLOCKS = 1440
|
||||
IMG_FAT = 12
|
||||
|
||||
# Source and object files
|
||||
SRCS = $(wildcard $(SRCDIR)/*.c)
|
||||
OBJS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCS))
|
||||
DEPS = $(OBJS:.o=.d)
|
||||
|
||||
# Default target
|
||||
all: $(TARGET)
|
||||
|
||||
# Link object files into executable
|
||||
$(TARGET): $(OBJS)
|
||||
$(LD) system dos4g name $@ file { $(OBJS) }
|
||||
|
||||
# Compile .c files to .o files, with auto-dependency generation
|
||||
$(OBJDIR)/%.o: $(SRCDIR)/%.c | $(OBJDIR)
|
||||
$(CC) -fo=$@ $(CFLAGS) -ad=$(@:.o=.d) -adfs $<
|
||||
|
||||
# Ensure obj/ exists before any compile runs
|
||||
$(OBJDIR):
|
||||
mkdir -p $(OBJDIR)
|
||||
|
||||
# Pull in auto-generated header dependencies (silently ignored if missing)
|
||||
-include $(DEPS)
|
||||
|
||||
# Clean up build artifacts
|
||||
clean:
|
||||
rm -f $(OBJS) $(DEPS) $(TARGET) $(IMG)
|
||||
|
||||
test: $(TARGET)
|
||||
cp $(TARGET) $(DOSBOX_DRIVE)/
|
||||
echo 'Ready to test'
|
||||
|
||||
image: $(TARGET)
|
||||
rm -f $(IMG)
|
||||
dd if=/dev/zero of=$(IMG) bs=1024 count=$(IMG_BLOCKS)
|
||||
mkfs.vfat -F $(IMG_FAT) $(IMG)
|
||||
mcopy -i $(IMG) $(TARGET) ::
|
||||
mcopy -i $(IMG) $(DOS4GW) ::
|
||||
|
||||
.PHONY: all clean test image
|
||||
6
include/util.h
Normal file
6
include/util.h
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
#ifndef _UTIL_H_
|
||||
#define _UTIL_H_
|
||||
|
||||
void displayMessage(int n);
|
||||
|
||||
#endif
|
||||
3
ow_setup.sh
Executable file
3
ow_setup.sh
Executable file
|
|
@ -0,0 +1,3 @@
|
|||
export WATCOM=~/openwatcom_c
|
||||
export PATH=$WATCOM/bin:$WATCOM/binl:$WATCOM/binw:$PATH
|
||||
export INCLUDE=$WATCOM/lh
|
||||
15
src/main.c
Normal file
15
src/main.c
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
void main() {
|
||||
int i = 0;
|
||||
|
||||
printf("DSPACE starting...\n");
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
displayMessage(i + 1);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
5
src/util.c
Normal file
5
src/util.c
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
#include <stdio.h>
|
||||
|
||||
void displayMessage(int n) {
|
||||
printf("%02d: Hello MS-DOS!\n", n);
|
||||
}
|
||||
Loading…
Reference in a new issue