ex36 prep
This commit is contained in:
parent
3fc7adac10
commit
8f91cf3d0c
2
lcthw-remnants-2/liblcthw/.gitignore
vendored
2
lcthw-remnants-2/liblcthw/.gitignore
vendored
@ -1,3 +1,5 @@
|
|||||||
tests/runtests
|
tests/runtests
|
||||||
tests/*_tests
|
tests/*_tests
|
||||||
tests/**/*_tests
|
tests/**/*_tests
|
||||||
|
bstrlib.c
|
||||||
|
bstrlib.h
|
||||||
|
@ -1,8 +1,18 @@
|
|||||||
|
BSTRLIB_BASE_URL ?= https://raw.githubusercontent.com/websnarf/bstrlib/208b1f2a4dfc96b806ed499bd1909e87ec15981d
|
||||||
CFLAGS = -g -O2 -Wall -Wextra -Isrc -Lbuild -rdynamic -DNDEBUG $(OPTFLAGS)
|
CFLAGS = -g -O2 -Wall -Wextra -Isrc -Lbuild -rdynamic -DNDEBUG $(OPTFLAGS)
|
||||||
LDLIBS = -ldl $(OPTLIBS)
|
LDLIBS = -ldl $(OPTLIBS)
|
||||||
|
|
||||||
PREFIX ?= /usr/local
|
PREFIX ?= /usr/local
|
||||||
|
|
||||||
|
FIND ?= find
|
||||||
|
CD ?= cd
|
||||||
|
PATCH ?= patch
|
||||||
|
INSTALL ?= install
|
||||||
|
MKDIR ?= mkdir -p
|
||||||
|
CURL ?= curl -sSL
|
||||||
|
RANLIB ?= ranlib
|
||||||
|
RUNTESTS ?= ./tests/runtests
|
||||||
|
|
||||||
SOURCES = $(wildcard src/**/*.c src/*.c)
|
SOURCES = $(wildcard src/**/*.c src/*.c)
|
||||||
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
|
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
|
||||||
|
|
||||||
@ -13,7 +23,6 @@ LIBNAME = lcthw
|
|||||||
TARGET = build/lib$(LIBNAME).a
|
TARGET = build/lib$(LIBNAME).a
|
||||||
SO_TARGET = $(patsubst %.a,%.so,$(TARGET))
|
SO_TARGET = $(patsubst %.a,%.so,$(TARGET))
|
||||||
|
|
||||||
# The Target Build
|
|
||||||
all: $(TARGET) $(SO_TARGET) tests
|
all: $(TARGET) $(SO_TARGET) tests
|
||||||
|
|
||||||
dev: CFLAGS = -g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
|
dev: CFLAGS = -g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
|
||||||
@ -22,37 +31,45 @@ dev: all
|
|||||||
$(TARGET): CFLAGS += -fPIC
|
$(TARGET): CFLAGS += -fPIC
|
||||||
$(TARGET): build $(OBJECTS)
|
$(TARGET): build $(OBJECTS)
|
||||||
$(AR) rcs $@ $(OBJECTS)
|
$(AR) rcs $@ $(OBJECTS)
|
||||||
ranlib $@
|
$(RANLIB) $@
|
||||||
|
|
||||||
$(SO_TARGET): $(TARGET) $(OBJECTS)
|
$(SO_TARGET): $(TARGET) $(OBJECTS)
|
||||||
$(CC) -shared -o $@ $(OBJECTS)
|
$(CC) -shared -o $@ $(OBJECTS)
|
||||||
|
|
||||||
build:
|
build: bin src/lcthw/bstrlib.c src/lcthw/bstrlib.h
|
||||||
@mkdir -p build
|
@$(MKDIR) $@
|
||||||
@mkdir -p bin
|
|
||||||
|
bin:
|
||||||
|
@$(MKDIR) $@
|
||||||
|
|
||||||
|
src/lcthw/bstrlib.c: src/lcthw/bstrlib.h
|
||||||
|
$(CURL) -o $@ $(BSTRLIB_BASE_URL)/bstrlib.c
|
||||||
|
$(CD) src/lcthw && $(PATCH) -p1 < bstrlib.patch
|
||||||
|
|
||||||
|
src/lcthw/bstrlib.h:
|
||||||
|
$(CURL) -o $@ $(BSTRLIB_BASE_URL)/bstrlib.h
|
||||||
|
|
||||||
# The Unit Tests
|
|
||||||
.PHONY: tests
|
.PHONY: tests
|
||||||
tests: LDLIBS += -static -l$(LIBNAME) -lbsd
|
tests: LDLIBS += -static -l$(LIBNAME) -lbsd
|
||||||
tests: ./tests/runtests $(TESTS)
|
tests: $(RUNTESTS) $(TESTS)
|
||||||
./tests/runtests ./tests/lcthw
|
$(RUNTESTS) ./tests/lcthw
|
||||||
|
|
||||||
valgrind:
|
valgrind:
|
||||||
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
|
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
|
||||||
|
|
||||||
# The Cleaner
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf build $(OBJECTS) $(TESTS)
|
$(RM) -r build $(OBJECTS) $(TESTS)
|
||||||
rm -f tests/tests.log tests/runtests
|
$(RM) tests/tests.log tests/runtests
|
||||||
find . -name "*.gc*" -exec rm {} \;
|
$(FIND) . -name "*.gc*" -exec rm {} \;
|
||||||
rm -rf `find . -name "*.dSYM" -print`
|
$(RM) -r `find . -name "*.dSYM" -print`
|
||||||
|
|
||||||
|
distclean: clean
|
||||||
|
$(RM) src/lcthw/bstrlib.c src/lcthw/bstrlib.h
|
||||||
|
|
||||||
# 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/
|
||||||
|
|
||||||
# The Checker
|
|
||||||
BADFUNCS='[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)'
|
BADFUNCS='[^_.>a-zA-Z0-9](str(n?cpy|n?cat|xfrm|n?dup|str|pbrk|tok|_)|stpn?cpy|a?sn?printf|byte_)'
|
||||||
check:
|
check:
|
||||||
@echo Files with potentially dangerous functions
|
@echo Files with potentially dangerous functions
|
||||||
|
12
lcthw-remnants-2/liblcthw/src/lcthw/bstrlib.patch
Normal file
12
lcthw-remnants-2/liblcthw/src/lcthw/bstrlib.patch
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
--- a/bstrlib.c 2016-04-21 12:26:50.000000000 -0400
|
||||||
|
+++ b/bstrlib.c 2016-04-21 12:27:59.000000000 -0400
|
||||||
|
@@ -22,7 +22,8 @@
|
||||||
|
#include <string.h>
|
||||||
|
#include <ctype.h>
|
||||||
|
#include <limits.h>
|
||||||
|
-#include "bstrlib.h"
|
||||||
|
+// PATCH to include adjacent bstrlib.h
|
||||||
|
+#include <lcthw/bstrlib.h>
|
||||||
|
|
||||||
|
/* Optionally include a mechanism for debugging memory */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user