Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
AMDmi3 committed Sep 11, 2016
1 parent d588bba commit 9345b07
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Makefile
@@ -1,26 +1,26 @@
DATADIR?=./

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

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

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

SOURCES=main.cpp text.cpp sound.cpp
OBJECTS=$(SOURCES:.c=.o)
OBJECTS=$(SOURCES:.cpp=.o)

EXECUTABLE=osgg

all: $(SOURCES) $(EXECUTABLE)

server: server.cpp
$(CC) $(LDFLAGS) server.cpp $(LIBS) -o $@
$(CXX) $(CXXFLAGS) $(LDFLAGS) server.cpp $(LIBS) -o $@

$(EXECUTABLE): $(OBJECTS)
$(CC) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@
$(CXX) $(LDFLAGS) $(OBJECTS) $(LIBS) -o $@

.cpp.o:
$(CC) $(CFLAGS) $< -o $@
$(CXX) $(CXXFLAGS) -c $< -o $@

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

0 comments on commit 9345b07

Please sign in to comment.