-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
52 lines (47 loc) · 1.21 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
# application name
APPNAME := gtksolver
# compiler
CC := gcc
CCLD := $(CC)
# output/object/include/source directories
BINDIR := bin
OBJDIR := obj
INCLUDE := include
SRCDIR := src
# compiler and linker flags
CFLAGS := -Wall -Wextra -pedantic -finline-functions -std=c11 -Wshadow
CFLAGS += -I$(INCLUDE)
CFLAGS += `pkg-config --cflags --libs gtk+-2.0`
ifeq ($(debug),-DDEBUG)
CFLAGS += -g
else
CFLAGS += -Ofast
endif
LDFLAGS := `pkg-config --libs gtk+-2.0`
# libraries
LIBS :=
# source/include/object variables
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(INCLUDE)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
ifeq ($(os),windows)
APPNAME := $(APPNAME).exe
LIBS := -Wl,-subsystem,windows
endif
# debug printing variable contents
# $(info $$SOURCES is [${SOURCES}])
# $(info $$INCLUDES is [${INCLUDES}])
# $(info $$OBJECTS is [${OBJECTS}])
# $(APPNAME): $(OBJECTS)
all: $(OBJECTS)
@mkdir -p $(@D)/bin
$(CCLD) -o $(BINDIR)/$(APPNAME) $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(LIBS)
# strip only if -DDEBUG not set
ifneq ($(debug),-DDEBUG)
strip -s $(BINDIR)/$(APPNAME)
endif
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@mkdir -p $(OBJDIR)
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BINDIR) $(OBJDIR)