-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile_legacy
123 lines (92 loc) · 5.46 KB
/
Makefile_legacy
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
FASTA_VECTOR_LIB_NAME = libfastavector
FASTA_VECTOR_MAJOR_VERSION = 1
FASTA_VECTOR_MINOR_VERSION = 0
FASTA_VECTOR_VERSION = $(FASTA_VECTOR_MAJOR).$(FASTA_VECTOR_MINOR_VERSION)
CC = gcc
CFLAGS = -std=c11 -Wall -mtune=native -O3 -fPIC
LDFLAGS_SHARED_LIB = -shared
STATIC_LIB_FILE_EXTENSION = .a
FASTA_VECTOR_PROJECT_DIR = $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
FASTA_VECTOR_BUILD_DIR = $(FASTA_VECTOR_PROJECT_DIR)/build
FASTA_VECTOR_SRC_DIR = $(FASTA_VECTOR_PROJECT_DIR)/src
ifeq ($(PREFIX),)
PREFIX := /usr/local
endif
#determine the current operating system
OS_NAME = $(shell uname -s)
ifeq ($(OS_NAME), Darwin)
FASTA_VECTOR_SHARED_LIB_FILENAME = $(FASTA_VECTOR_LIB_NAME).dylib
else
FASTA_VECTOR_SHARED_LIB_FILENAME = $(FASTA_VECTOR_LIB_NAME).so
endif
FASTA_VECTOR_STATIC_LIB_FILENAME = $(FASTA_VECTOR_LIB_NAME).a
FASTA_VECTOR_HEADER_FILENAME = FastaVector.h
FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME = FastaVectorMetadataVector.h
FASTA_VECTOR_STRING_HEADER_FILENAME = FastaVectorString.h
FASTA_VECTOR_BUILD_INCLUDE_DIR = $(FASTA_VECTOR_BUILD_DIR)/include
FASTA_VECTOR_BUILD_LIB_DIR = $(FASTA_VECTOR_BUILD_DIR)/lib
FASTA_VECTOR_PROJECT_HEADER_SRC = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_METADATA_VECTOR_PROJECT_HEADER_SRC = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_STRING_PROJECT_HEADER_SRC = $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
FASTA_VECTOR_BUILD_HEADER_SRC = $(FASTA_VECTOR_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_SHARED_LIB_BUILD_SRC = $(FASTA_VECTOR_BUILD_LIB_DIR)/$(FASTA_VECTOR_SHARED_LIB_FILENAME)
FASTA_VECTOR_STATIC_LIB_BUILD_SRC = $(FASTA_VECTOR_BUILD_LIB_DIR)/$(FASTA_VECTOR_STATIC_LIB_FILENAME)
FASTA_VECTOR_INSTALL_DIR = $(DESTDIR)$(PREFIX)
FASTA_VECTOR_INSTALL_LIB_DIR = $(FASTA_VECTOR_INSTALL_DIR)/lib
FASTA_VECTOR_INSTALL_INCLUDE_DIR = $(FASTA_VECTOR_INSTALL_DIR)/include
FASTA_VECTOR_INSTALL_HEADER_SRC = $(FASTA_VECTOR_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_METADATA_VECTOR_INSTALL_HEADER_SRC = $(FASTA_VECTOR_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME)
FASTA_VECTOR_STRING_INSTALL_HEADER_SRC = $(FASTA_VECTOR_INSTALL_INCLUDE_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
FASTA_VECTOR_INSTALL_STATIC_LIB_SRC = $(FASTA_VECTOR_INSTALL_LIB_DIR)/$(FASTA_VECTOR_STATIC_LIB_FILENAME)
FASTA_VECTOR_INSTALL_SHARED_LIB_SRC = $(FASTA_VECTOR_INSTALL_LIB_DIR)/$(FASTA_VECTOR_SHARED_LIB_FILENAME)
BUILD_LIB_TARGETS = $(FASTA_VECTOR_STATIC_LIB_BUILD_SRC) $(FASTA_VECTOR_SHARED_LIB_BUILD_SRC) $(FASTA_VECTOR_BUILD_HEADER_SRC)
SRCS := $(shell find $(FASTA_VECTOR_SRC_DIR) -name *.c)
OBJS := $(patsubst $(FASTA_VECTOR_SRC_DIR)/%, $(FASTA_VECTOR_BUILD_DIR)/%, $(SRCS:.c=.o))
$(FASTA_VECTOR_BUILD_DIR)/%.o: $(FASTA_VECTOR_SRC_DIR)/%.c
$(CC) $(CFLAGS) $(CFLAGS) -c $< -o $@
.PHONY: shared
shared: $(FASTA_VECTOR_BUILD_INCLUDE_DIR) $(FASTA_VECTOR_BUILD_LIB_DIR) $(OBJS)
$(CC) -o $(FASTA_VECTOR_SHARED_LIB_BUILD_SRC) $(LDFLAGS_SHARED_LIB) $(OBJS)
cp $(FASTA_VECTOR_PROJECT_HEADER_SRC) $(FASTA_VECTOR_BUILD_HEADER_SRC)
cp $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME) $(FASTA_VECTOR_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME)
cp $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME) $(FASTA_VECTOR_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
.PHONY: static
static: $(FASTA_VECTOR_BUILD_INCLUDE_DIR) $(FASTA_VECTOR_BUILD_LIB_DIR) $(OBJS)
ar rcs $(FASTA_VECTOR_STATIC_LIB_BUILD_SRC) $(OBJS)
cp $(FASTA_VECTOR_PROJECT_HEADER_SRC) $(FASTA_VECTOR_BUILD_HEADER_SRC)
cp $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME) $(FASTA_VECTOR_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_METADATA_VECTOR_HEADER_FILENAME)
cp $(FASTA_VECTOR_SRC_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME) $(FASTA_VECTOR_BUILD_INCLUDE_DIR)/$(FASTA_VECTOR_STRING_HEADER_FILENAME)
.PHONY: clean
clean:
rm -f $(BUILD_LIB_TARGETS) $(OBJS)
$(RM)
.PHONY: install
install:$(FASTA_VECTOR_INSTALL_LIB_DIR) $(FASTA_VECTOR_INSTALL_INCLUDE_DIR)
cp $(FASTA_VECTOR_PROJECT_HEADER_SRC) $(FASTA_VECTOR_INSTALL_HEADER_SRC)
cp $(FASTA_VECTOR_METADATA_VECTOR_PROJECT_HEADER_SRC) $(FASTA_VECTOR_METADATA_VECTOR_INSTALL_HEADER_SRC)
cp $(FASTA_VECTOR_STRING_PROJECT_HEADER_SRC) $(FASTA_VECTOR_STRING_INSTALL_HEADER_SRC)
#copy the library files to the install src if they exist
ifneq ("$(wildcard $(FASTA_VECTOR_STATIC_LIB_BUILD_SRC))","")
cp $(FASTA_VECTOR_STATIC_LIB_BUILD_SRC) $(FASTA_VECTOR_INSTALL_STATIC_LIB_SRC)
endif
ifneq ("$(wildcard $(FASTA_VECTOR_SHARED_LIB_BUILD_SRC))","")
cp $(FASTA_VECTOR_SHARED_LIB_BUILD_SRC) $(FASTA_VECTOR_INSTALL_SHARED_LIB_SRC)
endif
.PHONY: uninstall
uninstall:
rm -f $(FASTA_VECTOR_INSTALL_HEADER_SRC)
rm -f $(FASTA_VECTOR_METADATA_VECTOR_INSTALL_HEADER_SRC)
rm -f $(FASTA_VECTOR_STRING_INSTALL_HEADER_SRC)
rm -f $(FASTA_VECTOR_INSTALL_STATIC_LIB_SRC)
rm -f $(FASTA_VECTOR_INSTALL_SHARED_LIB_SRC)
#make the build directories if they do not exist.
$(FASTA_VECTOR_BUILD_DIR):
mkdir -p $(FASTA_VECTOR_BUILD_DIR)
$(FASTA_VECTOR_BUILD_INCLUDE_DIR): $(FASTA_VECTOR_BUILD_DIR)
mkdir -p $(FASTA_VECTOR_BUILD_INCLUDE_DIR)
$(FASTA_VECTOR_BUILD_LIB_DIR): $(FASTA_VECTOR_BUILD_DIR)
mkdir -p $(FASTA_VECTOR_BUILD_LIB_DIR)
$(FASTA_VECTOR_INSTALL_LIB_DIR):
mkdir -p $(FASTA_VECTOR_INSTALL_LIB_DIR)
$(FASTA_VECTOR_INSTALL_INCLUDE_DIR):
mkdir -p $(FASTA_VECTOR_INSTALL_INCLUDE_DIR)