Added nmake Makefile

This commit is contained in:
Kyler Olsen 2025-11-24 15:11:55 -07:00
parent a193006061
commit ec36f36713
2 changed files with 79 additions and 0 deletions

69
SLS_C/Makefile.nmake Normal file
View File

@ -0,0 +1,69 @@
# MSVC nmake build file for SLS
CC = cl
CFLAGS = /std:c11 /W4 /WX /Zi /I include
LDFLAGS =
SRCDIR = src
OBJDIR = obj
BINDIR = bin
TESTDIR = tests
TARGET = $(BINDIR)\sls.exe
TEST_TARGET = $(BINDIR)\sls_tests.exe
# --- MANUALLY LIST SOURCE FILES HERE ---
SOURCES = \
$(SRCDIR)\main.c \
$(SRCDIR)\lexer.c \
$(SRCDIR)\string.c
TEST_SOURCES = \
$(TESTDIR)\lexer_tests.c
# ---------------------------------------
OBJECTS = $(SOURCES:$(SRCDIR)\%.c=$(OBJDIR)\%.obj)
TEST_OBJECTS = $(TEST_SOURCES:$(TESTDIR)\%.c=$(OBJDIR)\%.obj)
# Default rule
all: build
# === BUILD MAIN PROGRAM ===
build: $(TARGET)
$(TARGET): dirs $(OBJECTS)
link $(OBJECTS) /OUT:$@ $(LDFLAGS)
# === COMPILE RULE ===
$(OBJDIR)\%.obj: $(SRCDIR)\%.c
$(CC) $(CFLAGS) /c $< /Fo$@
$(OBJDIR)\%.obj: $(TESTDIR)\%.c
$(CC) $(CFLAGS) /c $< /Fo$@
# === RUN PROGRAM ===
run: $(TARGET)
$(TARGET)
# === TEST BUILD & RUN ===
test: $(TEST_TARGET)
$(TEST_TARGET)
$(TEST_TARGET): dirs $(TEST_OBJECTS) $(OBJECTS:$(OBJDIR)\main.obj=)
link $(TEST_OBJECTS) $(OBJECTS:$(OBJDIR)\main.obj=) /OUT:$@ $(LDFLAGS)
# === CREATE DIRECTORIES ===
dirs:
if not exist $(OBJDIR) mkdir $(OBJDIR)
if not exist $(BINDIR) mkdir $(BINDIR)
# === CLEAN ===
clean:
rmdir /s /q $(OBJDIR)
rmdir /s /q $(BINDIR)

View File

@ -4,8 +4,18 @@ This is the C implementation for the YREA SLS interpreter.
## Running
### Linux (UNIX)
Build Project: `make build`
Build and Run Project: `make run`
Build and Run Tests: `make test`
Interpreter binary location: `./bin/sls`
### Windows
Build Project: `nmake /f Makefile.nmake build`
Build and Run Project: `nmake /f Makefile.nmake run`
Build and Run Tests: `nmake /f Makefile.nmake test`
Interpreter binary location: `.\bin\sls.exe`