Skip to content

Commit

Permalink
Fix the Makefile for liblcthw and use the latest from the book.
Browse files Browse the repository at this point in the history
  • Loading branch information
zedshaw committed Apr 1, 2012
1 parent 02c5ea0 commit c3a6ef6
Showing 1 changed file with 18 additions and 15 deletions.
33 changes: 18 additions & 15 deletions Makefile
@@ -1,4 +1,4 @@
CFLAGS=-g -O2 -Wall -Wextra -Isrc -pthread -rdynamic -DNDEBUG $(OPTFLAGS) CFLAGS=-g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
LIBS=-ldl $(OPTLIBS) LIBS=-ldl $(OPTLIBS)
PREFIX?=/usr/local PREFIX?=/usr/local


Expand All @@ -8,8 +8,9 @@ OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
TEST_SRC=$(wildcard tests/*_tests.c) TEST_SRC=$(wildcard tests/*_tests.c)
TESTS=$(patsubst %.c,%,$(TEST_SRC)) TESTS=$(patsubst %.c,%,$(TEST_SRC))


TARGET=build/libYOUR_LIBRARY.a TARGET=build/liblcthw.a


# The Target Build
all: $(TARGET) tests all: $(TARGET) tests


dev: CFLAGS=-g -Wall -Isrc -Wall -Wextra $(OPTFLAGS) dev: CFLAGS=-g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
Expand All @@ -24,27 +25,29 @@ build:
@mkdir -p build @mkdir -p build
@mkdir -p bin @mkdir -p bin


clean: # The Unit Tests
rm -rf build $(OBJECTS) $(TESTS)
rm -f tests/tests.log
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`

.PHONY: tests .PHONY: tests
tests: CFLAGS += $(TARGET)
tests: $(TESTS) tests: $(TESTS)
sh ./tests/runtests.sh sh ./tests/runtests.sh


$(TESTS): %: %.c $(TARGET) valgrind:
$(CC) $(CFLAGS) -o $@ $< $(TARGET) $(LIBS) VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)


check: # The Cleaner
@echo Files with potentially dangerous functions. clean:
@egrep '[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)' $(SOURCES) rm -rf build $(OBJECTS) $(TESTS)
rm -f tests/tests.log
find . -name "*.gc*" -exec rm {} \;
rm -rf `find . -name "*.dSYM" -print`


# The Install
install: all install: all
install -d $(DESTDIR)/$(PREFIX)/lib/ install -d $(DESTDIR)/$(PREFIX)/lib/
install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/ install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/


valgrind: # The Checker
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE) check:
@echo Files with potentially dangerous functions.
@egrep '[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)' $(SOURCES) || true


0 comments on commit c3a6ef6

Please sign in to comment.