-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
65 lines (50 loc) · 1.85 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
65
# ##############################################################################
#
# Informática Gráfica (Grado Informática)
# Makefile (sirve para Linux y macOS)
#
# ##############################################################################
HOME = .
INCLUDE = $(HOME)/include
SRC = $(HOME)/src
OBJ = $(HOME)/obj
BIN = $(HOME)/bin
.SUFFIXES:
.PHONY: x
exe := $(BIN)/pracs_exe
units_cc := $(wildcard $(SRC)/*.cc) $(wildcard $(SRC)/*.cpp)
units_o := $(addsuffix .o, $(basename $(units_cc)))
units_o := $(notdir $(units_o))
units_o := $(addprefix $(OBJ)/, $(units_o))
headers := $(wildcard $(INCLUDE)/*.h*)
uname := $(shell uname -s)
en_macos := $(findstring Darwin,$(uname))
en_linux := $(findstring Linux,$(uname))
compiler := $(if $(en_linux), g++, clang++ )
sistoper := $(if $(en_macos), macOS, Linux )
cc_flags_common := -std=c++11 -g -I/usr/include -I$(INCLUDE)
cc_flags_linux := -DLINUX
cc_flags_macos := -DMACOS
cc_flags := $(cc_flags_common) $(if $(en_linux), $(cc_flags_linux), $(cc_flags_macos))
glu_flag_macos := /System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGLU.dylib
ld_libs_common := -ljpeg
ld_libs_linux := -lGLEW -lGLU -lglut -lGL
ld_libs_macos := -framework OpenGL -framework SDL2 -framework SDL2_mixer -framework GLUT $(glu_flag_macos)
ld_libs := $(ld_libs_common) $(if $(en_linux), $(ld_libs_linux), $(ld_libs_macos))
x: init $(exe)
@echo Enlazando para: $(sistoper)
$(exe)
init:
-mkdir $(OBJ)
-mkdir $(BIN)
$(exe): $(units_o) makefile
@echo $(units_o)
$(compiler) -o $(exe) $(units_o) $(ld_libs)
$(OBJ)/%.o : $(SRC)/%.cc
$(compiler) -c -o $@ $(cc_flags) $<
$(OBJ)/%.o : $(SRC)/%.cpp
$(compiler) -c -o $@ $(cc_flags) $<
$(units_cc) : $(headers)
touch $(units_cc)
clean:
-rm -f $(OBJ)/*.o $(BIN)/*_exe