separate headers and src

This commit is contained in:
Jakub Sztandera 2016-07-26 12:00:54 +01:00
parent 1cc9e705f9
commit 6a23dbd54d
10 changed files with 20 additions and 12 deletions

4
.gitignore vendored
View file

@ -1,7 +1,5 @@
*
!.gitignore
!*.c
!*.h
!Makefile
!tests
!**/

View file

@ -16,15 +16,21 @@ LDLIBS =
TARGET_LIB = mulithash.a
TARGET_BIN = multihash
SRCS = errors.c hashes.c
MAIN = src/main.c
MAIN_O = $(MAIN:.c=.o)
SRCS = src/errors.c src/hashes.c
OBJS = $(SRCS:.c=.o)
src/%.o: src/%.c
$(CC) $(CFLAGS) -c -I include $^ -o $@
all: $(TARGET_LIB) $(TARGET_BIN)
$(TARGET_LIB): $(OBJS)
ar rcs $@ $^
$(TARGET_BIN): main.o $(TARGET_LIB)
$(TARGET_BIN): $(MAIN_O) $(TARGET_LIB)
$(CC) $(LDFLAGS) $^ -o $@
# Tests
@ -42,7 +48,7 @@ tests: $(TEST_BINS)
done
tests/c/test_%.o: tests/c/test_%.c
$(CC) -c -I. $^ -o $@
$(CC) $(CFLAGS) -c -I include $^ -o $@
tests/c/test_%: tests/c/test_%.o $(TARGET_LIB)
$(CC) $(LDFLAGS) $^ -o $@
@ -56,6 +62,7 @@ clean:
$(RM) $(TEST_BINS)
$(RM) $(TARGET_LIB)
$(RM) $(TARGET_BIN)
$(RM) $(MAIN_O)
dist-clean: clean

2
include/mh/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
!*.h

View file

@ -1,5 +1,5 @@
/* vim: set ts=8 sw=8 noexpandtab: */
#include "errors.h"
// list of avaliable hash functions.
typedef enum {
@ -28,7 +28,7 @@ typedef struct {
mh_hash hash;
int code;
int length;
} mh_hashinfo
} mh_hashinfo;
// decodes code info hash info, leaves length field zeroed
mh_error mh_hashinfo_from_code(int code, mh_hashinfo *hinfo);

1
src/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
!*.c

View file

@ -1,5 +1,5 @@
/* vim: set ts=8 sw=8 noexpandtab: */
#include "errors.h"
#include "mh/errors.h"
static const struct mh_error_desc {
int code;

View file

@ -1,2 +1,2 @@
/* vim: set ts=8 sw=8 noexpandtab: */
#include "mh/hashes.h"

View file

@ -2,7 +2,7 @@
#include <stdio.h>
#include "errors.h"
#include "mh/errors.h"
int main(void) {
printf("%s\n", mh_error_string(MH_E_TOO_LONG));

View file

@ -1,7 +1,7 @@
#include <string.h>
#include "minunit.h"
#include "errors.h"
#include "mh/errors.h"
char error_buf[256];