Skip to content

Commit

Permalink
Merge pull request #3 from olin/add-structure
Browse files Browse the repository at this point in the history
Add a basic project structure
  • Loading branch information
MatthewBeaudouinLafon committed Apr 2, 2019
2 parents 810e829 + 198ecda commit 9cc6bac
Show file tree
Hide file tree
Showing 3 changed files with 424 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/.gitignore
@@ -0,0 +1,7 @@
## Project-Related
*.out

## C-Related
*.o
*.a
*.lib
31 changes: 31 additions & 0 deletions src/Makefile
@@ -0,0 +1,31 @@
CC=gcc
CFLAGS+=-Wall
# global includes
# LDFLAGS+=

# add debug annotations, turn off optimizations, and #define DEBUG
# use in bash with `DEBUG=1 make <foo>`
# use in fish with `env DEBUG=1 make <foo>`
ifdef DEBUG
CFLAGS+=-g -O0 -DDEBUG
endif

# link ncurses library
# foo: LDFLAGS+=-lncurses

# **GNU Make only** run all test files (any file ending in _test.c)
# turns each `foo_test.c` into `.run-foo_test.c` with "Text Functions"
test: $(patsubst %.c, .run-%.c, $(wildcard *_test.c))

# run a single file
# given `.run-foo.c`, requires `foo.c` and runs `./foo`
.run-%.c: %
./$<

# add flags for minunit libraries, works with `make test_foo` too
%_test: LDFLAGS+=-lrt -lm
%_test: %_test.c minunit.h
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^

clean:
-rm *.o *_test

0 comments on commit 9cc6bac

Please sign in to comment.