-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
52 lines (42 loc) · 1.14 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
# Standard Makefile
CXX := gcc
WARNINGFLAGS := -Wall -Wextra
CXXFLAGS := $(WARNINGFLAGS) -g --pedantic
# Executable name
EXEC = theDude
# Directories
OBJDIR = obj
SRCDIR = src
INCLUDEDIR := include
# OpenGL?
UNAME = $(shell uname)
ifeq ($(UNAME), Darwin)
OPENGL_FLAGS = -framework OpenGL -framework GLUT
else
OPENGL_FLAGS = -lGL -lglut
endif
# Use as: make USE_GTK=1
ifdef USE_GTK
OPENGL_FLAGS = $(shell pkg-config --libs gtk+-2.0 gtkglext-1.0 gtkglext-x11-1.0)
CXXFLAGS += $(shell pkg-config --cflags gtk+-2.0 gtkglext-1.0 gtkglext-x11-1.0)
SRCS = $(SRCDIR)/window_system_gtk.c
else
SRCS = $(SRCDIR)/window_system_glut.c
endif
# Libraries
LIBS := -lm $(OPENGL_FLAGS)
# Files and folders
SRCS += $(SRCDIR)/dude.c
SRCDIRS = $(shell find . -name '*.c' | dirname {} | sort | uniq | sed 's/\/$(SRCDIR)//g' )
OBJS = $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o,$(SRCS))
# Targets
$(EXEC): build-obj-store $(OBJS)
$(CXX) $(OBJS) $(LIBS) -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CXX) $(OPTS) $(CXXFLAGS) $(COMPILE_FLAGS) -I$(INCLUDEDIR) -c $< -o $@
clean:
rm -rf $(EXEC) $(OBJDIR)
distclean:
rm -rf *~ */*~ $(EXEC) $(OBJDIR)
build-obj-store:
-mkdir -p $(OBJDIR)