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 |
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)
LDFLAGS += -lasound
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 xyw.h
$(CC) $(CFLAGS) -c devices/system.c -o devices/system.o
devices/terminal.o: devices/terminal.c xyw.h
$(CC) $(CFLAGS) -c devices/terminal.c -o devices/terminal.o
devices/clock.o: devices/clock.c xyw.h
$(CC) $(CFLAGS) -c devices/clock.c -o devices/clock.o
devices/file.o: devices/file.c xyw.h
$(CC) $(CFLAGS) -c devices/file.c -o devices/file.o
devices/beeper.o: devices/beeper.c xyw.h
$(CC) $(CFLAGS) -c devices/beeper.c -o devices/beeper.o
test:
./test.sh
clean:
rm -f xyw xyw.exe $(OBJS)
|