Advertisement
Guest User

Makefile

a guest
Sep 15th, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Make 1.33 KB | None | 0 0
  1. CFLAGS=-g -O2 -Wall -Wextra -Isrc/ -rdynamic -DNDEBUG $(OPTFLAGS)
  2. LIBS=-ldl $(OPTLIBS)
  3. PREFIX?=/usr/local
  4.  
  5. SOURCES=$(wildcard src/**/*.c src/*.c)
  6. OBJECTS=$(patsubst %.c,%.o,$(SOURCES))
  7.  
  8. TEST_SRC=$(wildcard tests/*_tests.c)
  9. TESTS=$(patsubst %.c,%,$(TEST_SRC))
  10.  
  11. TARGET=build/liblcthw.a
  12. SO_TARGET=$(patsubst %.a,%.so,$(TARGET))
  13.  
  14. # The Target Build
  15. all: $(TARGET) $(SO_TARGET) tests
  16.  
  17. dev: CFLAGS=-g -Wall -Isrc/ -Wall -Wextra $(OPTFLAGS)
  18. dev: all
  19.  
  20. $(TARGET): CFLAGS += -fPIC
  21. $(TARGET): build $(OBJECTS)
  22.         ar rcs $@ $(OBJECTS)
  23.         ranlib $@
  24.  
  25. $(SO_TARGET): $(TARGET) $(OBJECTS)
  26.         $(CC) -shared -o $@ $(OBJECTS)
  27.  
  28. build:
  29.         @mkdir -p build
  30.         @mkdir -p bin
  31.  
  32. # The Unit Tests
  33. .PHONY: tests
  34. tests: CFLAGS += $(TARGET)
  35. tests: $(TESTS)
  36.         sh ./tests/runtests.sh
  37.  
  38. valgrind:
  39.         VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
  40.  
  41. # The Cleaner
  42. clean:
  43.         rm -rf build $(OBJECTS) $(TESTS)
  44.         rm -f tests/tests.log
  45.         find . -name "*.gc*" -exec rm {} \;
  46.         rm -rf `find . -name "*.dSYM" -print`
  47.  
  48. # The Install
  49. install: all
  50.         install -d $(DESTDIR)/$(PREFIX)/lib/
  51.         install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/
  52.  
  53. # The Checker
  54. BADFUNCS='[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)'
  55. check:
  56.         @echo Files with potentially dangerous functions.
  57.         @egrep $(BADFUNCS) $(SOURCES) || true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement