-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile-opengl
134 lines (108 loc) · 4.83 KB
/
Makefile-opengl
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
123
124
125
126
127
128
129
130
131
132
133
134
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
#-------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# INCLUDES is a list of directories containing extra header files
# DOXY is the command to generate documentation
# DOCDIR is the path where documentation will be stored
# DOXYFILE is the file with settings for documentation the generator
#-------------------------------------------------------------------------------
TARGET := $(shell basename "$(CURDIR)")
SOURCES := assets src data
INCLUDES := include build
DOXY := doxygen
DOCDIR := doc
DOXYFILE := $(DOCDIR)/Doxyfile
#-------------------------------------------------------------------------------
# options for code generation
#-------------------------------------------------------------------------------
ARCH :=
CFLAGS := -g -Wall -O2\
-std=gnu++0x \
-DOPENGL \
$(ARCH)
CFLAGS += $(INCLUDE)
CXXFLAGS := $(CFLAGS) -fno-rtti -fexceptions
LDFLAGS_WIN := -L"C:\GL\lib" -lfreeglut -lglut32 -lglaux -lglew32 -lglui32 -lglui32d -lopengl32
LDFLAGS_LNX :=
LDFLAGS_MAC := -framework GLUT -framework OpenGL -framework Cocoa
ASFLAGS := -g $(ARCH)
#-------------------------------------------------------------------------------
# any extra libraries we wish to link with the project
#-------------------------------------------------------------------------------
LIBS :=
#-------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level
# containing include and lib
#-------------------------------------------------------------------------------
LIBDIRS_WIN := "C:\GL\include"
LIBDIRS_LNX :=
LIBDIRS_MAC := /usr/local/lib /usr/local/include
#-------------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
LDFLAGS := $(LDFLAGS_WIN)
LIBDIRS := $(LIBDIRS_WIN)
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
LDFLAGS := $(LDFLAGS_LNX)
LIBDIRS := $(LIBDIRS_LNX)
endif
ifeq ($(UNAME_S),Darwin)
LDFLAGS := $(LDFLAGS_MAC)
LIBDIRS := $(LIBDIRS_MAC)
CXXFLAGS += -D__APPLE__
endif
endif
#-------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add
# additional rules for different file extensions
#-------------------------------------------------------------------------------
export OUTPUT := $(CURDIR)/$(TARGET)
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
PNGFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.png)))
#-------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#-------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#-------------------------------------------------------------------------------
export LD := $(CC)
#-------------------------------------------------------------------------------
else
#-------------------------------------------------------------------------------
export LD := $(CXX)
#-------------------------------------------------------------------------------
endif
#-------------------------------------------------------------------------------
export OFILES := $(CPPFILES:.cpp=.o)
export INCLUDE := $(foreach dir,$(LIBDIRS),-I$(dir)) \
$(foreach dir,$(INCLUDES),-I$(dir))
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
.PHONY: all clean doc build
#-------------------------------------------------------------------------------
all: clean common build
#-------------------------------------------------------------------------------
common:
rm -rf _assets_
mkdir _assets_
$(foreach image,$(PNGFILES),cp assets/$(image) _assets_/$(image);)
#-------------------------------------------------------------------------------
build:
g++ src/main_opengl.cpp src/FMAW.cpp src/fmaw_*.cpp $(INCLUDE) $(LDFLAGS) $(CXXFLAGS) -o$(TARGET).exe
#-------------------------------------------------------------------------------
clean:
#@echo clean ...
@rm -fr $(BUILD) $(TARGET).exe _assets_ $(TARGET).test $(TARGET).exe.dSYM
#-------------------------------------------------------------------------------
doc:
$(DOXY) $(DOXYFILE)
doc-%:
$(DOXY) $(DOXYFILE).$*
#-------------------------------------------------------------------------------
test:
g++ src/tests.cpp -std=gnu++0x -o$(TARGET).test -fexceptions -DTEST
./$(TARGET).test
#-------------------------------------------------------------------------------