-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
94 lines (73 loc) · 2.57 KB
/
Makefile
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
26
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
83
84
85
86
87
88
89
90
91
92
93
94
#############################################################################
# Make file for AutoMix sampler
# Written by: David Hastie, University of Bristol
#
# If you use the AutoMix sampler please reference the author and work
# as instructed on the website http://www.davidhastie.me.uk/AutoMix
# Initially this reference is likely to be the Ph.D. thesis that introduces
# the AutoMix sampler. However, this will hopefully change to be a published
# paper in the not too distant future.
#
#############################################################################
# The file contains commands for compiling programs using optimisation and
# no debugging.
# If debug information is needed (-g compiler flag) call `make DEBUG=1`
# on the command line.
# Flags and compiler names should be changed as necessary
ifdef DEBUG
CFLAGS=-g
else
CFLAGS=-O3 -Wall
endif
ifdef PREFIX
LIB_INST_DIR=$(PREFIX)/lib
INC_INST_DIR=$(PREFIX)/include
else
LIB_INST_DIR=/usr/local/lib
INC_INST_DIR=/usr/local/include
endif
# Libraries
LIBS=-lm
LIBOBJS=automix.o
SRC_DIR=src
LIB_DIR=$(SRC_DIR)/libautomix
EXMP_DIR=$(SRC_DIR)/user_examples
INC_DIRS=$(EXMP_DIR) $(LIB_DIR)
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
all: libautomix.so
examples: amtoy1 amtoy2 amcpt amcptrs amrb9 amddi
libautomix.so: $(LIBOBJS)
$(CC) -shared -o libautomix.so $(LIBOBJS) $(LIBS)
###### Type "make test" or "make tutorial" to compile the test or the tutorial program
tutorial: $(EXMP_DIR)/tutorial.c libautomix.so
$(CC) $(CFLAGS) -o $@ $< -L./ -lautomix $(LIBS) $(INC_FLAGS)
test: tests/test_automix.c libautomix.so
$(CC) $< -L./ -lautomix -lm -I$(LIB_DIR) -o $@
###### EXAMPLE PROGRAMS ############
# Toy example 1
am%: user%.o logwrite.o $(EXMP_DIR)/main.c libautomix.so
$(CC) $(CFLAGS) -o $@ $< $(EXMP_DIR)/main.c logwrite.o -L./ -lautomix $(LIBS) $(INC_FLAGS)
### AutoMix dependencies
# Rule for all object files
%.o: $(LIB_DIR)/%.c $(LIB_DIR)/%.h
$(CC) $(CFLAGS) -fPIC -c $<
### User supplied functions
# Rule for all user* object files
user%.o: $(EXMP_DIR)/user%.c $(EXMP_DIR)/user.h
$(CC) $(CFLAGS) -c $<
# Rule for ddi (includes ddidata.h)
userddi.o: $(EXMP_DIR)/userddi.c $(EXMP_DIR)/user.h $(EXMP_DIR)/ddidata.h
$(CC) $(CFLAGS) -c $<
logwrite.o: $(EXMP_DIR)/logwrite.c $(EXMP_DIR)/logwrite.h
$(CC) $(CFLAGS) -c $< -I$(LIB_DIR)
###### Type "make clean" to remove all executables and object files ####
install:
- mkdir $(LIB_INST_DIR)/
- mkdir $(INC_INST_DIR)/
cp libautomix.so $(LIB_INST_DIR)/
cp $(LIB_DIR)/automix.h $(INC_INST_DIR)/
clean:
- rm *.o
- rm amtoy1 amtoy2 amcpt amcptrs amrb9 amddi
- rm test
- rm tutorial