-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
64 lines (49 loc) · 1.56 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
# makefile for filterfasta program.
# CC - compiler to use
CC=gcc
# LDFLAGS - linker options
LDFLAGS=
# CFLAGS - compiler options
# -Wall = turn on most warnings
# -Wextra = warn about type limits
# -g = compiles with debug info
# -pg = create gmon.out for gprof
CFLAGS=-Wall -Wextra -g
# INCLUDES - define directories containing header files in addition to /usr/include
# Example: INCLUDES=-I/dir1 -I/dir2
INCLUDES=
# LFLAGS - define library paths in addition to /usr/lib
# Example: LFLAGS=-L/dir1 -L/dir2
LFLAGS=
# LIBS - define libraries to link into executable
# -lm = math library
LIBS=-lm
# SOURCES - source files to compile
SOURCES=src/filterfasta.c
# OBJECTS - object files to link
# This uses a suffix replacement rule within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
OBJECTS=$(SOURCES:.c=.o)
# TARGETDIR - target directory to place executable file
TARGETDIR=bin/
# EXE - executable file
EXE=filterfasta
all: $(EXE)
@echo "Build complete: $(TARGETDIR)$(EXE)"
# $@ - name of target rule (in this case, $(EXE))
$(EXE): $(TARGETDIR)
$(CC) $(CFLAGS) $(LDFLAGS) $(INCLUDES) $(LFLAGS) $(SOURCES) $(LIBS) -o $(TARGETDIR)$@
@echo "Compilation and linking complete"
# This is a suffix replacement rule for building .o's from .c's
# It uses automatic variables
# $< - name of the first prerequisite of the rule (.c file)
# $@ - name of target rule (.o file)
.c.o:
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
@echo "Compilation complete"
$(TARGETDIR):
@mkdir $(TARGETDIR)
clean:
@rm $(OBJECTS) $(TARGETDIR)$(EXE)
rebuild: clean all