Makefile 3.43 KB
Newer Older
Anders Blomdell's avatar
Anders Blomdell committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
## Macros
VERSION=2006
LIBVERSION=2006

include ../os_compat.mk

ALL_DEPS=../liblabcomm$(LIBVERSION).a ../liblabcomm$(LIBVERSION).so.1

# TODO: Support for Codesourcery ARM toolchain.

OBJS=labcomm$(VERSION).o \
     labcomm$(VERSION)_memory.o \
     labcomm$(VERSION)_error.o \
     labcomm$(VERSION)_default_error_handler.o \
     labcomm$(VERSION)_default_memory.o \
     labcomm$(VERSION)_default_scheduler.o \
     labcomm$(VERSION)_time.o \
     labcomm$(VERSION)_scheduler.o \
     labcomm$(VERSION)_encoder.o \
     labcomm$(VERSION)_decoder.o \
     labcomm$(VERSION)_dynamic_buffer_writer.o \
     labcomm$(VERSION)_fd_reader.o \
     labcomm$(VERSION)_fd_writer.o \
     labcomm$(VERSION)_pthread_scheduler.o 

Anders Blomdell's avatar
Anders Blomdell committed
26
LABCOMM_JAR=../../../compiler/labcomm$(LIBVERSION)_compiler.jar
Anders Blomdell's avatar
Anders Blomdell committed
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
LABCOMM=java -jar $(LABCOMM_JAR) 

TESTS=test_labcomm_basic_type_encoding \
      test_labcomm_generated_encoding \
      test_signature_numbers \
      test_labcomm \
      test_labcomm_pthread_scheduler \
      test_labcomm_copy
#FIXME: test_labcomm_errors

TEST_DIR=test

## Targets

.PHONY: all 
all: $(ALL_DEPS)

.PHONY: test 
test: all $(TESTS:%=run-test-%)

.PHONY: clean 
clean:
	$(RM) *.o
	$(RM) experimental/*.o 
	$(RM) experimental/ThrottleDrv/*.o
	$(RM) test/*.o
	$(RM) test/*.gch
	$(RM) test/test_labcomm_errors
	$(RM) test/testdata/gen/*.[cho]
	$(RM) test/gen/*.[cho]
	$(RM) -rf test/gen

.PHONY: distclean
distclean: clean
	$(RM) ../liblabcomm$(LIBVERSION).so.1
	$(RM) ../liblabcomm$(LIBVERSION).a

# rules invoked by 'all'
../liblabcomm$(LIBVERSION).so.1: $(OBJS:%.o=%.pic.o)
	$(call MAKESHARED,$@,$@,$^)

../liblabcomm$(LIBVERSION).a: $(OBJS)
	ar -r $@ $^

# compilation rules 
%.pic.o: %.c
	$(CC) -fPIC $(CFLAGS) -c -o $@ $<

%.o: %.c %.h
	$(CC) $(CFLAGS) -c -o $@ $<

# rules invoked by 'test'
.PHONY: run-test-%
run-test-%: $(TEST_DIR)/gen/% | $(TEST_DIR)/gen
	$<

Anders Blomdell's avatar
Anders Blomdell committed
83
84
.PRECIOUS: $(TEST_DIR)/gen/%

Anders Blomdell's avatar
Anders Blomdell committed
85
86
87
88
89
90
$(TEST_DIR)/gen/%: $(TEST_DIR)/gen/%.o | $(TEST_DIR)/gen
	$(LD) $(LDFLAGS) -o $@ $^ $(LDLIBS) 

$(TEST_DIR)/gen/%.o: $(TEST_DIR)/%.c | $(TEST_DIR)/gen
	$(CC) $(CFLAGS_TEST) -o $@ -c $<

Anders Blomdell's avatar
Anders Blomdell committed
91
92
93
94
95
$(TEST_DIR)/gen/%.c $(TEST_DIR)/gen/%.h: $(TEST_DIR)/%.lc | $(TEST_DIR)/gen
	$(LABCOMM) \
		--c=$(TEST_DIR)/gen/$*.c \
		--h=$(TEST_DIR)/gen/$*.h \
		$<
Anders Blomdell's avatar
Anders Blomdell committed
96

Anders Blomdell's avatar
Anders Blomdell committed
97
98
99
100
101
102
103
104
105
$(LABCOMM_JAR):
	@echo "======Building LabComm compiler======"
	cd $(shell dirname $(LABCOMM_JAR)); ant jar
	@echo "======End building LabComm compiler======"

$(TEST_DIR)/gen:
	mkdir -p $@

# Extra compilation dependencies
Anders Blomdell's avatar
Anders Blomdell committed
106
107
108
109
110
labcomm$(VERSION).o: \
	labcomm$(VERSION).c \
	labcomm$(VERSION).h \
	labcomm$(VERSION)_private.h

Anders Blomdell's avatar
Anders Blomdell committed
111
112
113
114
115
116
117
labcomm$(VERSION)_fd_reader.o: \
	labcomm$(VERSION)_private.h

labcomm$(VERSION)_fd_writer.o: \
	labcomm$(VERSION)_private.h

labcomm$(VERSION)_dynamic_buffer_writer.o: \
Anders Blomdell's avatar
Anders Blomdell committed
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
	labcomm$(VERSION)_private.h

$(TEST_DIR)/gen/test_labcomm_basic_type_encoding.o: \
	labcomm$(VERSION)_private.h

$(TEST_DIR)/gen/test_labcomm_generated_encoding.o: \
	labcomm$(VERSION)_private.h \
	$(TEST_DIR)/gen/generated_encoding.h

$(TEST_DIR)/gen/test_labcomm_generated_encoding: \
	$(TEST_DIR)/gen/generated_encoding.o

$(TEST_DIR)/gen/test_signature_numbers.c: \
	$(TEST_DIR)/gen/another_encoding.h \
	$(TEST_DIR)/gen/generated_encoding.h				

$(TEST_DIR)/gen/test_signature_numbers: \
	$(TEST_DIR)/gen/another_encoding.o \
	$(TEST_DIR)/gen/generated_encoding.o

$(TEST_DIR)/gen/test_labcomm:  \
	$(TEST_DIR)/gen/test_sample.o

$(TEST_DIR)/gen/test_labcomm_copy: \
	$(TEST_DIR)/gen/generated_encoding.o \
	$(TEST_DIR)/gen/test_sample.o \
	$(TEST_DIR)/gen/more_types.o