Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 9e52c41a73
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 73 lines (51 sloc) 1.37 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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
CSRC := $(shell find src -name "*.c")
CHDR := $(shell find include -name "*.h")

COBJ := $(CSRC:.c=.o)

AR := ar
ARFLAGS := cq
LIB := libatto.a

CC := clang
CFLAGS := -Wall -Wextra -pedantic -std=c99 -Iinclude/ -Wno-unused-parameter -O2
LNFLAGS := -lm
EXE := atto

TESTSRC := $(shell find src/ \( -name "*.c" -and -not -name "main.c" \))
TESTOBJ := $(TESTSRC:.c=.o)
TESTEXE := tester

####

all: $(COBJ) $(EXE) lib

test: $(TESTOBJ)
$(CC) $(CFLAGS) $(TESTOBJ) $(LNFLAGS) -g -O0 -DDEBUG -DUNIT_TEST src/tester.c -o $(TESTEXE)
./tester

# creates the gmon.out files when ./atto or ./tester is run
gprof:
gcc $(CFLAGS) $(CSRC) $(LNFLAGS) -pg -o $(EXE)
gcc $(CFLAGS) $(TESTSRC) $(LNFLAGS) -pg -DUNIT_TEST -o $(TESTEXE)

$(EXE): $(COBJ)
@ echo " LINK" $(EXE)
@ $(CC) $(COBJ) $(LNFLAGS) -o $(EXE)

cleanlib:
rm -f $(LIB)

lib: cleanlib $(LIB)

$(LIB): $(LIBOBJ)
@ echo "ar $@"
@ $(AR) $(ARFLAGS) $@ $(COBJ)

%.o: %.c
@ echo " CC" $<
@ $(CC) $(CFLAGS) -c $< -o $@

debug:
@ $(MAKE) "CFLAGS=$(CFLAGS) -g -O0 -DDEBUG"

gcc:
@ $(MAKE) "CC=gcc"

clang:
@ $(MAKE) "CC=clang"

clean: cleanlib
rm -f $(COBJ) $(EXE)

todo:
@ find src -type f | xargs grep -n -i "TODO"
@ find src -type f | xargs grep -n -i "FIXME"

loc:
@ wc -l src/*.[ch]

# requires sloccount
sloc:
@ sloccount src lib | grep '(SLOC)'

.PHONY= loc sloc todo clean all debug gcc gprof
Something went wrong with that request. Please try again.