Last active
January 2, 2020 06:13
-
-
Save orazdow/45fbd69ac9ac36bf2a03d34b898a7512 to your computer and use it in GitHub Desktop.
useful makefiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
REM wavwrite - MSVC build bat file | |
REM run with vscmd: cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" | |
SET libdirs=/LIBPATH:D:\Libraries\portaudio\build\msvc /LIBPATH:D:\Libraries\glfw\lib-vc2015 | |
SET libs=portaudio_x86.lib glfw3.lib | |
SET includes=/ID:\Libraries\portaudio\include /ID:\Libraries\glfw\include | |
SET files=main.c | |
SET opts=/Feout.exe | |
cl %opts% %includes% %files% /link %libdirs% %libs% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@REM Build for Visual Studio compiler. Run your copy of vcvars32.bat or vcvarsall.bat to setup command-line compiler. | |
rem cl /nologo /Zi /MD /I ..\.. /I ..\libs\glfw\include /I ..\libs\gl3w *.cpp ..\..\imgui*.cpp ..\libs\gl3w\GL\gl3w.c /FeDebug/opengl_example3.exe /FoDebug/ /link /LIBPATH:..\libs\glfw\lib-vc2010-32 glfw3.lib opengl32.lib gdi32.lib shell32.lib | |
mkdir Debug | |
set dir=D:\Libraries | |
set opts=/nologo /Zi /MD | |
set includes=/I %dir%\imgui /I %dir%\glfw\include /I %dir%\gl3w\include | |
set sources=*.cpp %dir%\imgui\*.cpp %dir%\gl3w\src\gl3w.c | |
set out=/FeDebug/opengl_example3.exe /FoDebug/ | |
set libdirs=/LIBPATH:%dir%\glfw\lib-vc2015 | |
set libs=glfw3.lib opengl32.lib gdi32.lib shell32.lib | |
cl %opts% %includes% %sources% %out% /link %libdirs% %libs% |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET := out.exe | |
SRC := main.cpp | |
# INCLUDE = -ID:/Libraries/portaudio/include | |
# LIBS = -LD:/Libraries/portaudio/build | |
# LIBS += -lportaudio | |
CXX := g++ | |
FLAGS := -pthread -Wall | |
all: $(TARGET) | |
$(TARGET): $(SRC) | |
$(CXX) $(INCLUDE) $(FLAGS) $^ -o $@ $(LIBS) | |
clean: | |
rm -f $(TARGET) | |
run: | |
@./$(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET = out | |
SRC = main.cpp | |
SRC2 = D:/Libraries/glad/src | |
SRC += $(SRC2)/glad.c | |
INCLUDE = -I D:/Libraries/glad/include | |
INCLUDE += -I D:/Libraries/glfw/include | |
LIBS = -L D:/Libraries/glfw/lib-mingw | |
LIBS += -lglfw3 -lgdi32 -lopengl32 -lpthread | |
CXX = g++ | |
# FLAGS = -Wall | |
OBJ = $(notdir $(patsubst %.c, %.o, $(SRC))) | |
OBJ := $(notdir $(patsubst %.cpp, %.o, $(OBJ))) | |
DEPS = $(wildcard *.h) | |
%.o : $(SRC2)/%.c | |
$(CXX) -x c $(INCLUDE) $(FLAGS) -c $< -o $@ | |
%.o : %.cpp $(DEPS) | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ | |
all: $(TARGET) | |
$(TARGET): $(OBJ) | |
$(CXX) $(INCLUDE) $(FLAGS) $^ -o $@ $(LIBS) | |
clean: | |
rm -f $(TARGET) $(wildcard *.o) | |
run: | |
@./$(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imgui example | |
target = ok.exe | |
srcdir_2 = D:/Libraries/imgui | |
srcdir_3 = D:/Libraries/gl3w/src | |
src := main.cpp imgui_impl_glfw_gl3.cpp | |
src += $(srcdir_2)/imgui.cpp $(srcdir_2)/imgui_demo.cpp $(srcdir_2)/imgui_draw.cpp | |
src += $(srcdir_3)/gl3w.c | |
cxx := g++ | |
flags = -Wall | |
includes = -ID:/Libraries/imgui -ID:/Libraries/gl3w/include -ID:/Libraries/glfw/include | |
libs = -LD:/Libraries/glfw/lib-mingw | |
libs += -lglfw3 -lgdi32 -lopengl32 -limm32 | |
objects = $(addsuffix .o, $(basename $(notdir $(src)))) | |
# compile objects | |
%.o: %.cpp | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
%.o: $(srcdir_2)/%.cpp | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
%.o: $(srcdir_3)/%.c | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
all: $(target) | |
# build exe | |
$(target): $(objects) | |
$(cxx) $(flags) $^ -o $@ $(libs) | |
clean: | |
rm -f $(objects) $(target) | |
cleanexe: | |
rm -f $(target) | |
print: | |
@echo $(objects) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
appname =ok.exe | |
SOURCES =main.cpp imgui_impl_glfw_gl3.cpp | |
SOURCES2 = ../../imgui.cpp ../../imgui_demo.cpp ../../imgui_draw.cpp ../libs/gl3w/GL/gl3w.c | |
CXX =g++ | |
CXXFLAGS =-I../../ -ID:/Libraries/imgui/examples/libs/gl3w -I../../../glfw/include | |
CXXFLAGS += -Wall -Wformat | |
LIBS =-LD:/Libraries/glfw/lib-mingw | |
LIBS += -lglfw3 -lgdi32 -lopengl32 -limm32 | |
objects := $(addsuffix .o, $(basename $(notdir $(SOURCES)))) | |
%.o: %.cpp | |
$(CXX) $(CXXFLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
all: $(appname) | |
$(appname): $(objects) | |
$(CXX) $(CXXFLAGS) $(SOURCES) $(SOURCES2) -o $(appname) $(LIBS) | |
clean: | |
rm -f $(objects) $(appname) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# imgui example | |
target = ok.exe | |
# comment out to use basedir | |
builddir = build/ | |
srcdir_2 = D:/Libraries/imgui | |
srcdir_3 = D:/Libraries/gl3w/src | |
src = main.cpp imgui_impl_glfw_gl3.cpp | |
src += $(wildcard $(srcdir_2)/*.cpp) | |
src += $(srcdir_3)/gl3w.c | |
cxx = g++ | |
flags = -Wall | |
includes = -ID:/Libraries/imgui -ID:/Libraries/gl3w/include -ID:/Libraries/glfw/include | |
libs = -LD:/Libraries/glfw/lib-mingw | |
libs += -lglfw3 -lgdi32 -lopengl32 -limm32 | |
objects = $(addprefix $(builddir), $(addsuffix .o, $(basename $(notdir $(src))))) | |
target := $(addprefix $(builddir), $(target)) | |
# compile objects | |
$(builddir)%.o: %.cpp | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
$(builddir)%.o: $(srcdir_2)/%.cpp | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
$(builddir)%.o: $(srcdir_3)/%.c | |
$(cxx) $(includes) $(flags) -c $< -o $@ $(libs) | |
@echo $@ | |
all: make_dir $(target) | |
# build exe | |
$(target): $(objects) | |
$(cxx) $(flags) $^ -o $@ $(libs) | |
make_dir : $(builddir) | |
$(builddir): | |
mkdir -p $(builddir) | |
clean: | |
rm -f $(objects) $(target) | |
cleanexe: | |
rm -f $(target) | |
print: | |
@echo $(objects) | |
run: | |
@./$(target) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
APPNAME = wavwrite.exe | |
SRC = main.c | |
INCLUDE = -ID:/Libraries/portaudio/include | |
LIBS = -LD:/Libraries/portaudio/build | |
LIBS += -lportaudio | |
CXX = gcc | |
FLAGS = -Wall | |
# OBJ = $(patsubst %.c, %.o, $(SRC)) | |
# %.o : %.c | |
# $(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
# $(APPNAME): $(OBJ) | |
# $(CXX) $(FLAGS) $^ -o $@ $(LIBS) | |
$(APPNAME): $(SRC) | |
$(CXX) $(INCLUDE) $(FLAGS) $^ -o $@ $(LIBS) | |
clean: | |
rm -f $(APPNAME) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET = wavbuff.exe | |
# comment out to use basedir | |
builddir = build/ | |
SRC = main.cpp wavutil.c pa.cpp pa_ringbuffer.c rb.c | |
SRCDIR_2 = lib | |
INCLUDE = -Iportaudio_win/include | |
INCLUDE += -Ilib | |
LIBS = -Lportaudio_win/build | |
LIBS += -lportaudio | |
CXX = g++ | |
FLAGS = -g -Wall | |
OBJECTS = $(addprefix $(builddir), $(addsuffix .o, $(basename $(notdir $(SRC))))) | |
# uncomment to put exe in /build | |
# TARGET := $(addprefix $(builddir), $(TARGET)) | |
# compile objects | |
$(builddir)%.o: %.cpp | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
$(builddir)%.o: $(SRCDIR_2)/%.c | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
$(builddir)%.o: $(SRCDIR_2)/%.cpp | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
all: make_dir $(TARGET) | |
# build exe | |
$(TARGET): $(OBJECTS) | |
$(CXX) $(FLAGS) $^ -o $@ $(LIBS) | |
make_dir : $(builddir) | |
$(builddir): | |
mkdir -p $(builddir) | |
clean: | |
rm -f $(OBJECTS) $(TARGET) | |
print: | |
@echo $(OBJECTS) | |
@echo $(TARGET) | |
run: | |
@./$(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET := out.exe | |
SRC := $(wildcard *.cpp) | |
INCLUDE = -ID:/Libraries/portaudio/include | |
LIBS = -LD:/Libraries/portaudio/build | |
LIBS += -lportaudio | |
CXX := g++ | |
# FLAGS := -Wall | |
OBJECTS := $(addsuffix .o, $(basename $(notdir $(SRC)))) | |
DEPS = $(wildcard *.h) | |
%.o: %.cpp $(DEPS) | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
all: $(TARGET) | |
$(TARGET): $(OBJECTS) | |
$(CXX) $^ -o $@ $(LIBS) | |
clean: | |
rm -f $(OBJECTS) $(TARGET) | |
run: | |
@./$(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TARGET := out.exe | |
SRCDIR_2 = lib | |
SRC := $(wildcard *.cpp) | |
SRC += $(wildcard $(SRCDIR_2)/*.cpp) | |
# comment out to use basedir | |
builddir = build/ | |
INCLUDE = -ID:/Libraries/portaudio/include | |
LIBS = -LD:/Libraries/portaudio/build | |
LIBS += -lportaudio | |
CXX := g++ | |
# FLAGS := -Wall | |
OBJECTS := $(addprefix $(builddir), $(addsuffix .o, $(basename $(notdir $(SRC))))) | |
DEPS = $(wildcard *.h) | |
DEPS += $(wildcard $(SRCDIR_2)/*.h) | |
$(builddir)%.o: %.cpp $(DEPS) | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
$(builddir)%.o: $(SRCDIR_2)/%.cpp $(DEPS) | |
$(CXX) $(INCLUDE) $(FLAGS) -c $< -o $@ $(LIBS) | |
@echo $@ | |
all: make_dir $(TARGET) | |
$(TARGET): $(OBJECTS) | |
$(CXX) $^ -o $@ $(LIBS) | |
make_dir : $(builddir) | |
$(builddir): | |
mkdir -p $(builddir) | |
clean: | |
rm -f $(OBJECTS) $(TARGET) | |
run: | |
@./$(TARGET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
REM MSVC build bat file | |
REM run with vscmd: cmd /k "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\Tools\VsDevCmd.bat" | |
set target=wavbuff_w32.exe | |
set builddir=winbuild | |
IF not [%1]==[] (GOTO args) | |
mkdir %builddir% | |
SET libdirs=/LIBPATH:portaudio_win\build | |
SET libs=portaudio_x86.lib | |
SET includes=/Iportaudio_win\include /Ilib | |
rem set debug=/Zi /DEBUG | |
SET files=main.cpp lib\pa.cpp lib\pa_ringbuffer.c lib\wavutil.c lib\rb.c | |
SET opts=/Fe%target% /Fo%builddir%\ %debug% | |
rem SET opts=/Fe%builddir%/%target% /Fo%builddir%/ | |
cl %opts% %includes% %files% /link %libdirs% %libs% | |
GOTO end | |
:args | |
IF [%1]==[clean] (del %builddir%\* del %target%) | |
IF [%1]==[run] (%target%) | |
:end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment