-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (37 loc) · 1.25 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
# Exe. file name
TARGET = run
CC=gcc
# compiling flags here
CFLAGS= -g -Wall
IDIR = ./libs/btree/inc
# define any directories containing header file other then /usr/include
INCLUDES = -I $(IDIR)
# define any libraries to link into executable:
# if I want to link in libraries
# (libx.so or libx.a) I use the -llibname (-lx -lx) = (-lx)
# libfdr => -lfdr
LIBS = -lbt
# LIBS = -lm
# define any directories containing implementation of the file in INCLUDES
# ../..lib means up 2 level then search for /lib
LDIR = libs/btree/lib
LFLAGS = -L $(LDIR)
GTKFLAGS= -export -rdynamic `pkg-config --cflags --libs gtk+-3.0`
# This uses Suffix Replacement within a macro:
# $(name:string1=string2)
# For each word in 'name' replace 'string1' with 'string2'
# Below we are replacing the suffix .c of all words in the macro SRCS
# with the .o suffix
SRCS = $(wildcard *.c)
ODIR = obj
_OBJS = $(SRCS:.c=.o)
OBJS = $(patsubst %,$(ODIR)/%,$(_OBJS))
$(TARGET): $(OBJS)
$(CC) $(CFLAGS) $(INCLUDES) -g -rdynamic -o $@ $^ $(LFLAGS) $(LIBS) $(GTKFLAGS)
@echo "Linking complete!"
$(ODIR)/%.o: %.c $(DEPS)
$(CC) $(CFLAG S) $(INCLUDES) -rdynamic -c $< -o $@ $(LFLAGS) $(LIBS) $(GTKFLAGS)
@echo "Compiled "$<" successfully!"
clean:
rm -f $(ODIR)/*.o *~ $(TARGET)
@echo "Cleanup complete!"