all repos — xyw @ c54e00b21018baefa7107d57ef6c34642eda51b3

A minimal virtual machine and assembler for terminals.

Makefile

 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
 56
 57
 58
CC = gcc
CFLAGS = -Wall -Wextra -g -Os -ffunction-sections -fdata-sections
LDFLAGS = -Wl,--gc-sections -s

SOURCES = xyw.c xywasm.c xywrun.c devices/system.c devices/terminal.c devices/clock.c devices/file.c devices/beeper.c
OBJS = xyw.o xywasm.o xywrun.o devices/system.o devices/terminal.o devices/clock.o devices/file.o devices/beeper.o

# beeper.c picks its audio backend at compile time via #ifdef, so the only
# thing the Makefile needs to do is link the matching system library.
ifeq ($(OS),Windows_NT)
    BIN := xyw.exe
    LDFLAGS += -lwinmm
else ifeq ($(UNAME_S),Darwin)
    LDFLAGS += -framework AudioToolbox -framework CoreFoundation
else ifeq ($(UNAME_S),Linux)
    # Only link -lasound if the ALSA headers are actually installed
    # (libasound2-dev). Mirrors the __has_include check in beeper.c, which
    # falls back to the OSS backend when they're missing.
    HAVE_ALSA := $(shell echo '\#include <alsa/asoundlib.h>' | $(CC) -E - >/dev/null 2>&1 && echo 1)
    ifeq ($(HAVE_ALSA),1)
        LDFLAGS += -lasound
    endif
endif

.PHONY: clean test

xyw: $(OBJS)
	$(CC) $(CFLAGS) $(OBJS) -o xyw $(LDFLAGS)

xyw.o: xyw.c xyw.h
	$(CC) $(CFLAGS) -c xyw.c -o xyw.o

xywrun.o: xywrun.c xyw.h
	$(CC) $(CFLAGS) -c xywrun.c -o xywrun.o

xywasm.o: xywasm.c xyw.h
	$(CC) $(CFLAGS) -c xywasm.c -o xywasm.o

devices/system.o: devices/system.c devices/system.h xyw.h
	$(CC) $(CFLAGS) -c devices/system.c -o devices/system.o

devices/terminal.o: devices/terminal.c devices/terminal.h xyw.h
	$(CC) $(CFLAGS) -c devices/terminal.c -o devices/terminal.o

devices/clock.o: devices/clock.c devices/clock.h xyw.h
	$(CC) $(CFLAGS) -c devices/clock.c -o devices/clock.o

devices/file.o: devices/file.c devices/file.h xyw.h
	$(CC) $(CFLAGS) -c devices/file.c -o devices/file.o

devices/beeper.o: devices/beeper.c devices/beeper.h xyw.h
	$(CC) $(CFLAGS) -c devices/beeper.c -o devices/beeper.o

test:
	./test.sh

clean:
	rm -f xyw xyw.exe $(OBJS)