Repository navigation
Expand file tree
/
Copy pathMakefile.win
More file actions
55 lines (44 loc) · 1.54 KB
/
Copy pathMakefile.win
File metadata and controls
55 lines (44 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#
# NMake Makefile for the infix FFI Library (Windows + MSVC)
#
# USAGE: This Makefile is for the native Windows toolchain.
# It must be run with `nmake.exe` from a Visual Studio Developer Command Prompt.
# Its *only* purpose is to build the static library `infix.lib`.
#
# TARGETS:
# nmake /f Makefile.win - Builds infix.lib (default)
# nmake /f Makefile.win clean - Removes build artifacts
#
# --- Compiler and Toolchain ---
CC = cl.exe
LIB = lib.exe
# --- Directories ---
SRC_DIR = src
INC_DIR = include
OBJ_DIR = obj
LIB_NAME = infix.lib
# --- Flags ---
# Includes the necessary flags for C11 atomics and all required include paths.
CFLAGS = /std:c11 /W4 /Zi /nologo /experimental:c11atomics /DINFIX_DEBUG_ENABLED=1 /I$(INC_DIR) /Isrc /Isrc\arch\x64 /Isrc\arch\aarch64 /Isrc\arch\riscv
# --- Source & Object Files ---
LIB_OBJECTS = $(OBJ_DIR)\infix.obj
# --- Main Targets ---
all: $(OBJ_DIR)\$(LIB_NAME)
shared: $(OBJ_DIR)\infix.dll
# --- Build Rules ---
# Rule to create the static library from its object files.
$(OBJ_DIR)\$(LIB_NAME): $(LIB_OBJECTS)
@echo AR $@
$(LIB) /OUT:$@ $(LIB_OBJECTS)
# Rule to create the dynamic library (DLL).
$(OBJ_DIR)\infix.dll: $(LIB_OBJECTS)
@echo LD $@
$(CC) /LD /Fe$@ $(LIB_OBJECTS) /link /DLL
# Inference Rule to build .obj files from .c files found in the core source directory.
{$(SRC_DIR)}.c{$(OBJ_DIR)}.obj:
@if not exist $(OBJ_DIR) mkdir $(OBJ_DIR)
@echo CC $**
$(CC) $(CFLAGS) /DINFIX_BUILDING_DLL /c $** /Fo$@
# --- Cleanup ---
clean:
@if exist $(OBJ_DIR) rmdir /S /Q $(OBJ_DIR)