Skip to content

Commit

Permalink
Fix Makefile debug targets
Browse files Browse the repository at this point in the history
  • Loading branch information
zedr committed Sep 2, 2023
1 parent 05f42f7 commit 7f260e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
30 changes: 20 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
.PHONY: default all test clean debug

CC ?= gcc
STD := c99
.PHONY: default all test debug clean

CC ?= gcc
STD := c99
SHELL := /usr/bin/env bash
SOURCES := src/tinycols/*.c src/queue.c
INCDIR := include/
INCLUDES = $(shell find $(INCDIR) -type f -name *.h)
INC := -I ${INCLUDES}
INC := -I ${INCLUDES}
COMPILE := -DLINUX_TARGET -Wall -Werror -pedantic -std=${STD}
CFLAGS := ${COMPILE}
DBG_CFLAGS := -g -p
DBG_CFLAGS := -g -p -fsanitize=address -fsanitize=undefined

default: build/tinycols

Expand All @@ -22,20 +21,29 @@ build:
@mkdir build

build/test_tinycols: build
@${CC} ${CFLAGS} \
@${CC} ${CFLAGS} ${DBG_CFLAGS} \
-D_POSIX_C_SOURCE=199309L \
-o build/test_tinycols \
lib/*.c tests/test_tinycols.c ${SOURCES}

build/test_queue: build
@${CC} ${CFLAGS} \
@${CC} ${CFLAGS} ${DBG_CFLAGS} \
-D_POSIX_C_SOURCE=199309L \
-o build/test_queue \
lib/*.c src/queue.c src/tinycols/*.c tests/test_queue.c

build/tinycols: build
@${CC} ${CFLAGS} -std=gnu99 -lncurses \
-o build/tinycols \
@${CC} ${CFLAGS} \
-std=gnu99 \
-lncurses \
-o $@ \
src/main.c src/gfx.c ${SOURCES}

build/tinycols-dbg: build
@${CC} ${CFLAGS} ${DBG_CFLAGS} \
-std=gnu99 \
-lncurses \
-o $@ \
src/main.c src/gfx.c ${SOURCES}

build/tinycols-debug: build
Expand All @@ -49,5 +57,7 @@ test:
@build/test_tinycols
@build/test_queue

debug: build/tinycols-dbg

clean:
@rm -rf build
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,13 @@ A jewels matching game for the Linux terminal.
## Build

### Pre-requisites
- `make`
- `gcc`
- `ncurses-devel`
- A C compiler

For debugging:
- libasan
- libubsan

### Instructions
Run `make`.
Expand Down

0 comments on commit 7f260e3

Please sign in to comment.