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/*_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)
|
||||
LDLIBS = -ldl $(OPTLIBS)
|
||||
|
||||
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)
|
||||
OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
|
||||
|
||||
@ -13,7 +23,6 @@ LIBNAME = lcthw
|
||||
TARGET = build/lib$(LIBNAME).a
|
||||
SO_TARGET = $(patsubst %.a,%.so,$(TARGET))
|
||||
|
||||
# The Target Build
|
||||
all: $(TARGET) $(SO_TARGET) tests
|
||||
|
||||
dev: CFLAGS = -g -Wall -Isrc -Wall -Wextra $(OPTFLAGS)
|
||||
@ -22,37 +31,45 @@ dev: all
|
||||
$(TARGET): CFLAGS += -fPIC
|
||||
$(TARGET): build $(OBJECTS)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
ranlib $@
|
||||
$(RANLIB) $@
|
||||
|
||||
$(SO_TARGET): $(TARGET) $(OBJECTS)
|
||||
$(CC) -shared -o $@ $(OBJECTS)
|
||||
|
||||
build:
|
||||
@mkdir -p build
|
||||
@mkdir -p bin
|
||||
build: bin src/lcthw/bstrlib.c src/lcthw/bstrlib.h
|
||||
@$(MKDIR) $@
|
||||
|
||||
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
|
||||
tests: LDLIBS += -static -l$(LIBNAME) -lbsd
|
||||
tests: ./tests/runtests $(TESTS)
|
||||
./tests/runtests ./tests/lcthw
|
||||
tests: $(RUNTESTS) $(TESTS)
|
||||
$(RUNTESTS) ./tests/lcthw
|
||||
|
||||
valgrind:
|
||||
VALGRIND="valgrind --log-file=/tmp/valgrind-%p.log" $(MAKE)
|
||||
|
||||
# The Cleaner
|
||||
clean:
|
||||
rm -rf build $(OBJECTS) $(TESTS)
|
||||
rm -f tests/tests.log tests/runtests
|
||||
find . -name "*.gc*" -exec rm {} \;
|
||||
rm -rf `find . -name "*.dSYM" -print`
|
||||
$(RM) -r build $(OBJECTS) $(TESTS)
|
||||
$(RM) tests/tests.log tests/runtests
|
||||
$(FIND) . -name "*.gc*" -exec rm {} \;
|
||||
$(RM) -r `find . -name "*.dSYM" -print`
|
||||
|
||||
distclean: clean
|
||||
$(RM) src/lcthw/bstrlib.c src/lcthw/bstrlib.h
|
||||
|
||||
# The Install
|
||||
install: all
|
||||
install -d $(DESTDIR)/$(PREFIX)/lib/
|
||||
install $(TARGET) $(DESTDIR)/$(PREFIX)/lib/
|
||||
$(INSTALL) -d $(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_)'
|
||||
check:
|
||||
@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