diff options
author | Clyne Sullivan <tullivan99@gmail.com> | 2016-03-02 10:14:01 -0500 |
---|---|---|
committer | Clyne Sullivan <tullivan99@gmail.com> | 2016-03-02 10:14:01 -0500 |
commit | e879b257b9512816f2ff579a7444fe600a74ed91 (patch) | |
tree | 0db242513a0851e0985f7d55ae4cd75e14a91b4e /Makefile | |
parent | 47f8aa5b312a5ef671e83322bcbe201a034f84c0 (diff) |
better make system
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 70 |
1 files changed, 38 insertions, 32 deletions
@@ -1,32 +1,38 @@ -LIBS = -lpthread -lGL -lGLEW -lSDL2 -lfreetype -lSDL2_image -lSDL2_mixer
-
-WIN_LIBS = -lopengl32 -lglew32 -lmingw32 -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype
-
-FLAGS = -std=c++11 -Iinclude -Iinclude/freetype2 -Wall -Wextra -Werror
-
-MFLAGS64 = 64
-
-all:
- @echo "Building for 32-bit target"
- @rm -f out/*.o
- @cd src; $(MAKE) $(MFLAGS)
- @echo " CXX main.cpp"
- @g++ $(FLAGS) -m32 -o main main.cpp out/*.o $(LIBS) -lSDL2main
-
-64:
- @echo "Building for 64-bit target"
- @rm -f out64/*.o
- @cd src; $(MAKE) $(MFLAGS64)
- @echo " CXX main.cpp"
- @g++ $(FLAGS) -m64 -o main main.cpp out64/*.o $(LIBS)
-
-win32:
- @g++ $(FLAGS) -o main main.cpp src/*.cpp $(WIN_LIBS)
-
-clean:
- @echo " RM main"
- @-rm -f main
- @echo " RM out/*.o"
- @-rm -f out/*.o
- @echo " RM out64/*.o"
- @-rm -f out64/*.o
+include setup.mk + +CC = gcc +CXX = g++ + +ifeq ($(TARGET_OS),linux) + LIBS = -lpthread -lGL -lGLEW -lfreetype \ + -lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2main +endif +ifeq ($(TARGET_OS),win32) + LIBS = -lopengl32 -lglew32 -lmingw32 \ + -lSDL2main -lSDL2 -lSDL2_image -lSDL2_mixer -lfreetype +endif + +CXXFLAGS = -m$(TARGET_BITS) -std=c++11 +CXXINC = -Iinclude -Iinclude/freetype2 +CXXWARN = -Wall -Wextra -Werror + +CXXSRCDIR = src +CXXOUTDIR = out +CXXSRC = $(wildcard $(CXXSRCDIR)/*.cpp) +CXXOBJ = $(patsubst $(CXXSRCDIR)/%.cpp, $(CXXOUTDIR)/%.o, $(CXXSRC)) + +EXEC = main + +all: $(EXEC) + +clean: + rm -f $(EXEC) + rm -f out/*.o + +$(EXEC): $(CXXOUTDIR)/$(CXXOBJ) + @echo " CXX/LD main" + @$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) -o $(EXEC) main.cpp out/*.o $(LIBS) + +$(CXXOUTDIR)/%.o: $(CXXSRCDIR)/%.cpp + @echo " CXX " $< + @$(CXX) $(CXXFLAGS) $(CXXINC) $(CXXWARN) $(LIBS) -c $< -o $@ |