Skip to content

Commit bbf4b4a

Browse files
committed
Reorganize source layout to be a bit more modular.
1 parent 7ca09f0 commit bbf4b4a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+24
-18
lines changed

Makefile

+24-18
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ CFLAGS += -g
4141
#CFLAGS += -g -fprofile-arcs -ftest-coverage
4242
#LDFLAGS += -fprofile-arcs -ftest-coverage
4343

44+
CFLAGS += -Iinclude
45+
4446
#always use this: C99, and check source code carefully
4547
CFLAGS += -std=c99 -pedantic -Wall -Wextra -Wpointer-arith -Wstrict-prototypes
4648
#well, pretty carefully
@@ -61,7 +63,7 @@ CFLAGS += -Wno-sign-compare -Wno-overlength-strings
6163
#tell us when denying an inline request
6264
#CFLAGS += -Winline
6365

64-
LIBHDRS = \
66+
LIBHDR_FILES = \
6567
crm114_lib.h \
6668
crm114_sysincludes.h \
6769
crm114_config.h \
@@ -77,7 +79,9 @@ crm114_matrix_util.h \
7779
crm114_svm_quad_prog.h \
7880
crm114_datalib.h
7981

80-
LIBOBJS = \
82+
LIBHDRS = $(foreach hdr, $(LIBHDR_FILES), include/$(hdr))
83+
84+
LIBOBJ_FILES = \
8185
crm114_base.o \
8286
crm114_markov.o \
8387
crm114_markov_microgroom.o \
@@ -97,36 +101,38 @@ crm114_strnhash.o \
97101
crm114_util.o \
98102
crm114_regex_tre.o
99103

104+
LIBOBJS = $(foreach obj, $(LIBOBJ_FILES), lib/$(obj))
100105

101-
all: test simple_demo
106+
LIB = lib/libcrm114.a
102107

103-
test: test.o libcrm114.a
104-
$(CC) -o test $(LDFLAGS) -Wl,-M -Wl,--cref test.o libcrm114.a -ltre -lm >test.map
108+
all: $(LIB) tests/test tests/simple_demo
105109

106-
test.o: texts.h $(LIBHDRS)
110+
$(LIBOBJS): $(LIBHDRS) Makefile
107111

108-
simple_demo: simple_demo.o libcrm114.a
109-
$(CC) -o simple_demo $(LDFLAGS) -Wl,-M -Wl,--cref simple_demo.o libcrm114.a -ltre -lm >simple_demo.map
112+
# #ar cmd below has no s modifier (like ranlib). Not needed now, partly
113+
# #because LIBOBJS is in the right order.
114+
$(LIB): $(LIBOBJS) Makefile
115+
ar rc $@ $(LIBOBJS)
110116

111-
simple_demo.o: texts.h $(LIBHDRS)
117+
lib/%.o: lib/%.c
118+
$(CC) -c $(CFLAGS) -o $@ $<
112119

113-
#ar cmd below has no s modifier (like ranlib). Not needed now, partly
114-
#because LIBOBJS is in the right order.
115-
libcrm114.a: $(LIBOBJS) Makefile
116-
ar rc libcrm114.a $(LIBOBJS)
120+
tests/test: tests/test.c tests/texts.h $(LIBHDRS)
121+
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) -Wl,-M -Wl,--cref $< $(LIB) -ltre -lm >tests/test.map
117122

118-
$(LIBOBJS): $(LIBHDRS)
123+
tests/simple_demo: tests/simple_demo.c tests/texts.h
124+
$(CC) $(CFLAGS) -o $@ $(LDFLAGS) -Wl,-M -Wl,--cref $< $(LIB) -ltre -lm >tests/simple_demo.map
119125

120126
clean: clean_test clean_simple_demo clean_lib clean_profiling
121127

122128
clean_test:
123-
rm -f test test.map test.o
129+
rm -f tests/test tests/test.map tests/test.o
124130

125131
clean_simple_demo:
126-
rm -f simple_demo simple_demo.map simple_demo.o simple_demo_datablock.txt
132+
rm -f tests/simple_demo tests/simple_demo.map tests/simple_demo.o {,tests/}simple_demo_datablock.txt
127133

128134
clean_lib:
129-
rm -f libcrm114.a $(LIBOBJS)
135+
rm -f $(LIB) $(LIBOBJS)
130136

131137
clean_profiling:
132-
rm -f gmon.out *.gcov *.gcno *.gcda
138+
rm -f gmon.out *.gcov {,lib/}*.gcno {,lib/}*.gcda

HOWTO.txt doc/HOWTO.txt

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_lib.h include/crm114_lib.h

File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_pca.h include/crm114_pca.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_svm.h include/crm114_svm.h

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_base.c lib/crm114_base.c

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_pca.c lib/crm114_pca.c

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_svm.c lib/crm114_svm.c

File renamed without changes.
File renamed without changes.
File renamed without changes.

crm114_util.c lib/crm114_util.c

File renamed without changes.
File renamed without changes.
File renamed without changes.

simple_demo.c tests/simple_demo.c

File renamed without changes.

test.c tests/test.c

File renamed without changes.
File renamed without changes.
File renamed without changes.

texts.h tests/texts.h

File renamed without changes.

0 commit comments

Comments
 (0)