ex28 extra credit
This commit is contained in:
parent
1aafac69cb
commit
d8c63c261d
1
lcthw-remnants-2/.gitignore
vendored
1
lcthw-remnants-2/.gitignore
vendored
@ -2,3 +2,4 @@
|
||||
ex*
|
||||
!ex*.c
|
||||
devpkgzed
|
||||
*.log
|
||||
|
1
lcthw-remnants-2/c-skeleton/.gitignore
vendored
Normal file
1
lcthw-remnants-2/c-skeleton/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
tests/your_library_tests
|
@ -1,5 +1,6 @@
|
||||
CFLAGS = -g -O2 -Wall -Wextra -Isrc -rdynamic -DNDEBUG $(OPTFLAGS)
|
||||
LIBS = -ldl $(OPTLIBS)
|
||||
CFLAGS = -g -O2 -Wall -Wextra -Isrc -Lbuild -rdynamic -DNDEBUG $(OPTFLAGS)
|
||||
LDLIBS = -ldl $(OPTLIBS)
|
||||
|
||||
PREFIX ?= /usr/local
|
||||
|
||||
SOURCES = $(wildcard src/**/*.c src/*.c)
|
||||
@ -8,7 +9,8 @@ OBJECTS = $(patsubst %.c,%.o,$(SOURCES))
|
||||
TEST_SRC = $(wildcard tests/*_tests.c)
|
||||
TESTS = $(patsubst %.c,%,$(TEST_SRC))
|
||||
|
||||
TARGET = build/libYOUR_LIBRARY.a
|
||||
LIBNAME = YOUR_LIBRARY
|
||||
TARGET = build/lib$(LIBNAME).a
|
||||
SO_TARGET = $(patsubst %.a,%.so,$(TARGET))
|
||||
|
||||
# The Target Build
|
||||
@ -19,7 +21,7 @@ dev: all
|
||||
|
||||
$(TARGET): CFLAGS += -fPIC
|
||||
$(TARGET): build $(OBJECTS)
|
||||
ar rcs $@ $(OBJECTS)
|
||||
$(AR) rcs $@ $(OBJECTS)
|
||||
ranlib $@
|
||||
|
||||
$(SO_TARGET): $(TARGET) $(OBJECTS)
|
||||
@ -31,7 +33,7 @@ build:
|
||||
|
||||
# The Unit Tests
|
||||
.PHONY: tests
|
||||
tests: CFLAGS += $(TARGET)
|
||||
tests: LDLIBS += -static -l$(LIBNAME)
|
||||
tests: $(TESTS)
|
||||
sh ./tests/runtests.sh
|
||||
|
||||
|
6
lcthw-remnants-2/c-skeleton/src/your_library.c
Normal file
6
lcthw-remnants-2/c-skeleton/src/your_library.c
Normal file
@ -0,0 +1,6 @@
|
||||
#include "your_library.h"
|
||||
|
||||
int howmanyweasels()
|
||||
{
|
||||
return WEASELS;
|
||||
}
|
8
lcthw-remnants-2/c-skeleton/src/your_library.h
Normal file
8
lcthw-remnants-2/c-skeleton/src/your_library.h
Normal file
@ -0,0 +1,8 @@
|
||||
#ifndef _your_library_h
|
||||
#define _your_library_h
|
||||
|
||||
#define WEASELS 23
|
||||
|
||||
int howmanyweasels();
|
||||
|
||||
#endif
|
8
lcthw-remnants-2/c-skeleton/tests/your_library_tests.c
Normal file
8
lcthw-remnants-2/c-skeleton/tests/your_library_tests.c
Normal file
@ -0,0 +1,8 @@
|
||||
#include <stdio.h>
|
||||
#include "your_library.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("WEASELS: %d\n", howmanyweasels());
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user