MakeFile almost working need rule to build .\build%.o
This commit is contained in:
parent
0c8ec81b74
commit
5f018e24cf
BIN
.Makefile.un~
Normal file
BIN
.Makefile.un~
Normal file
Binary file not shown.
41
Makefile
41
Makefile
@ -1,24 +1,29 @@
|
|||||||
# Special Thanks to Job Vranish at Atomic Object for the base Makefile that was modified slightly to work with this project's needs
|
# Special Thanks to Job Vranish at Atomic Object for the base Makefile that was modified slightly to work with this project's needs
|
||||||
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
|
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
|
||||||
TARGET_EXEC ?= BeagleRescue
|
TARGET_EXEC ?= BeagleRescue.exe
|
||||||
|
|
||||||
BUILD_DIR ?= ./build
|
BUILD_DIR ?= .\build
|
||||||
SRC_DIRS ?= ./src
|
SRC_DIRS ?= .\src
|
||||||
|
|
||||||
SRCS := $(shell find $(SRC_DIRS) -name *.cpp -or -name *.c -or -name *.s)
|
#SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
|
||||||
OBJS := $(SRCS:%=$(BUILD_DIR)/%.o)
|
SRCS := $(shell dir .\*.cpp /s /b)
|
||||||
|
OBJS := $(SRCS:%=$(BUILD_DIR)\%.o)
|
||||||
DEPS := $(OBJS:.o=.d)
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
#LIBXML_ROOT ?= /usr/include/libxml2
|
#INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||||
#LIBRARY_PATH=. ./lib/
|
INC_DIRS := $(dir .\src /ad /b /s )
|
||||||
|
|
||||||
INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
|
||||||
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||||
#-I$(LIBXML_ROOT) -Ilibsdl2_image -Ilibsdl2_mixer
|
|
||||||
|
INCLUDE_PATHS = -IC:\mingw_dev_lib\sdl2\include\SDL2 -IC:\mingw_dev_lib\sdl_image\include\SDL2 -IC:\mingw_dev_lib\sdl_mixer\include\SDL2
|
||||||
|
|
||||||
|
LIBRARY_PATHS = -LC:\mingw_dev_lib\sdl2\lib -LC:\mingw_dev_lib\sdl2_image\lib -LC:\mingw_dev_lib\sdl2_mixer\lib
|
||||||
|
|
||||||
CPPFLAGS ?= $(INC_FLAGS) -Ilibsdl2/include -Ilibtmx-parser/src -Ilibtmx-parser/libs/tinyxml2 -MMD -MP -w
|
CPPFLAGS ?= $(INC_FLAGS) -Ilibsdl2/include -Ilibtmx-parser/src -Ilibtmx-parser/libs/tinyxml2 -MMD -MP -w
|
||||||
# libxml2/.libs/libxml2.a -lSDL2_image -lSDL2_mixer -lSDL2
|
COMPILER_FLAGS = -w "-Wl,-subsystem,windows" #Quotes used to force Powershell to parse correctly
|
||||||
LINKER_FLAGS = libsdl2/build/.libs/libSDL2.a libsdl2_image/.libs/libSDL2_image.a libsdl2_mixer/build/.libs/libSDL2_mixer.a libtmx-parser/libtmxparser.a
|
|
||||||
$(BUILD_DIR)/$(TARGET_EXEC): $(OBJS)
|
#LINKER_FLAGS = libsdl2/build/.libs/libSDL2.a libsdl2_image/.libs/libSDL2_image.a libsdl2_mixer/build/.libs/libSDL2_mixer.a libtmx-parser/libtmxparser.a
|
||||||
|
$(BUILD_DIR)\$(TARGET_EXEC): $(OBJS)
|
||||||
|
|
||||||
# $(CC) $(OBJS) -o $@ $(LDFLAGS)
|
# $(CC) $(OBJS) -o $@ $(LDFLAGS)
|
||||||
$(CXX) $(OBJS) $(LINKER_FLAGS) -o $@
|
$(CXX) $(OBJS) $(LINKER_FLAGS) -o $@
|
||||||
|
|
||||||
@ -30,21 +35,17 @@ $(BUILD_DIR)/%.s.o: %.s
|
|||||||
# c source
|
# c source
|
||||||
$(BUILD_DIR)/%.c.o: %.c
|
$(BUILD_DIR)/%.c.o: %.c
|
||||||
$(MKDIR_P) $(dir $@)
|
$(MKDIR_P) $(dir $@)
|
||||||
$(CXX) $(CPPFLAGS) $(CFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
$(CXX) $(CPPFLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(CFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||||
|
|
||||||
# c++ source
|
# c++ source
|
||||||
$(BUILD_DIR)/%.cpp.o: %.cpp
|
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||||
$(MKDIR_P) $(dir $@)
|
$(MKDIR_P) $(dir $@)
|
||||||
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
$(CXX) $(CPPFLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(CXXFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||||
|
|
||||||
# build and archive static libraries
|
|
||||||
# libtmxparser.a:
|
|
||||||
# ar rcs libtmxparser.a .o
|
|
||||||
|
|
||||||
.PHONY: clean
|
.PHONY: clean
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
$(RM) -r $(BUILD_DIR)
|
-del -fR $(BUILD_DIR)
|
||||||
|
|
||||||
-include $(DEPS)
|
-include $(DEPS)
|
||||||
|
|
||||||
|
53
Makefile~
Normal file
53
Makefile~
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
# Special Thanks to Job Vranish at Atomic Object for the base Makefile that was modified slightly to work with this project's needs
|
||||||
|
# https://spin.atomicobject.com/2016/08/26/makefile-c-projects/
|
||||||
|
TARGET_EXEC ?= BeagleRescue.exe
|
||||||
|
|
||||||
|
BUILD_DIR ?= .\build
|
||||||
|
SRC_DIRS ?= .\src
|
||||||
|
|
||||||
|
#SRCS := $(shell find $(SRC_DIRS) -name '*.cpp' -or -name '*.c' -or -name '*.s')
|
||||||
|
SRCS := $(shell dir .\*.cpp /s /b)
|
||||||
|
OBJS := $(SRCS:%=$(BUILD_DIR)\%.o)
|
||||||
|
DEPS := $(OBJS:.o=.d)
|
||||||
|
|
||||||
|
#INC_DIRS := $(shell find $(SRC_DIRS) -type d)
|
||||||
|
INC_DIRS := $(dir .\src /ad /b /s )
|
||||||
|
INC_FLAGS := $(addprefix -I,$(INC_DIRS))
|
||||||
|
|
||||||
|
INCLUDE_PATHS = -IC:\mingw_dev_lib\sdl2\include\SDL2 -IC:\mingw_dev_lib\sdl_image\include\SDL2 -IC:\mingw_dev_lib\sdl_mixer\include\SDL2
|
||||||
|
|
||||||
|
LIBRARY_PATHS = -LC:\mingw_dev_lib\sdl2\lib -LC:\mingw_dev_lib\sdl2_image\lib -LC:\mingw_dev_lib\sdl2_mixer\lib
|
||||||
|
|
||||||
|
CPPFLAGS ?= $(INC_FLAGS) -Ilibsdl2/include -Ilibtmx-parser/src -Ilibtmx-parser/libs/tinyxml2 -MMD -MP -w
|
||||||
|
COMPILER_FLAGS = -w "-Wl,-subsystem,windows" #Quotes used to force Powershell to parse correctly
|
||||||
|
|
||||||
|
all:
|
||||||
|
#LINKER_FLAGS = libsdl2/build/.libs/libSDL2.a libsdl2_image/.libs/libSDL2_image.a libsdl2_mixer/build/.libs/libSDL2_mixer.a libtmx-parser/libtmxparser.a
|
||||||
|
$(BUILD_DIR)\$(TARGET_EXEC): $(OBJS)
|
||||||
|
|
||||||
|
# $(CC) $(OBJS) -o $@ $(LDFLAGS)
|
||||||
|
$(CXX) $(OBJS) $(LINKER_FLAGS) -o $@
|
||||||
|
|
||||||
|
# assembly
|
||||||
|
$(BUILD_DIR)/%.s.o: %.s
|
||||||
|
$(MKDIR_P) $(dir $@)
|
||||||
|
$(AS) $(ASFLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# c source
|
||||||
|
$(BUILD_DIR)/%.c.o: %.c
|
||||||
|
$(MKDIR_P) $(dir $@)
|
||||||
|
$(CXX) $(CPPFLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(CFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
# c++ source
|
||||||
|
$(BUILD_DIR)/%.cpp.o: %.cpp
|
||||||
|
$(MKDIR_P) $(dir $@)
|
||||||
|
$(CXX) $(CPPFLAGS) $(INCLUDE_PATHS) $(LIBRARY_PATHS) $(COMPILER_FLAGS) $(CXXFLAGS) $(LINKER_FLAGS) -c $< -o $@
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
|
||||||
|
clean:
|
||||||
|
-del -fR $(BUILD_DIR)
|
||||||
|
|
||||||
|
-include $(DEPS)
|
||||||
|
|
||||||
|
MKDIR_P ?= mkdir -p
|
Binary file not shown.
Loading…
Reference in New Issue
Block a user