Skip to content

Commit 9345b07

Browse files
committed
Fix Makefile
- Use CXX for C++ code compilation and linking - Properly allow CXX to be overridden - Fix file extension in OBJECTS - Add -c to compilation command - Link with libm (for cos() and other trigonometry)
1 parent d588bba commit 9345b07

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Makefile

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
DATADIR?=./
22

3-
CC=g++ -DDATADIR="\"$(DATADIR)\""
3+
CXX?=g++
44

5-
CFLAGS+=-Wall `sdl-config --cflags`
5+
CXXFLAGS+=-Wall `sdl-config --cflags` -DDATADIR="\"$(DATADIR)\""
66

7-
LIBS+=-lGL `sdl-config --libs` -lSDL_ttf -lSDL_image -lSDL_mixer
7+
LIBS+=`sdl-config --libs` -lSDL_ttf -lSDL_image -lSDL_mixer -lGL -lm
88

99
SOURCES=main.cpp text.cpp sound.cpp
10-
OBJECTS=$(SOURCES:.c=.o)
10+
OBJECTS=$(SOURCES:.cpp=.o)
1111

1212
EXECUTABLE=osgg
1313

1414
all: $(SOURCES) $(EXECUTABLE)
1515

1616
server: server.cpp
17-
$(CC) $(LDFLAGS) server.cpp $(LIBS) -o $@
18-
17+
$(CXX) $(CXXFLAGS) $(LDFLAGS) server.cpp $(LIBS) -o $@
18+
1919
$(EXECUTABLE): $(OBJECTS)
20-
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
20+
$(CXX) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
2121

2222
.cpp.o:
23-
$(CC) $(CFLAGS) $< -o $@
23+
$(CXX) $(CXXFLAGS) -c $< -o $@
2424

2525
clean:
2626
rm -f *.o $(EXECUTABLE)

0 commit comments

Comments
 (0)