Last active
February 14, 2018 15:23
-
-
Save gvanem/004f7a6254ad897b5bc3ae694575eab7 to your computer and use it in GitHub Desktop.
GNU-makefile for CubicSDR (MSVC): https://github.com/cjcliffe/CubicSDR.git
This file contains 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
# | |
# GNU Makefile CubicSDR (MSVC). | |
# | |
THIS_FILE = Makefile.MSVC | |
VER_MAJOR = 0 | |
VER_MINOR = 2 | |
VER_PATCH = 3 | |
VERSION = $(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) | |
DATE = $(shell date +%d-%B-%Y) | |
VPATH = audio demod panel process sdr ui util visual \ | |
forms forms/Bookmark forms/Dialog forms/SDRDevices \ | |
modules modules/modem modules/modem/analog \ | |
../external/tinyxml \ | |
../external/lodepng \ | |
../external/rtaudio | |
# | |
# Choose your weapons. | |
# | |
USE_DEBUG = 0 | |
USE_CLANG = 0 | |
USE_HAMLIB = 1 | |
USE_DIGITAL = 0 | |
USE_WX_DLLS = 0 | |
USE_MP_COMPILE = 0 | |
PROGRAM = ../bin/CubicSDR.exe | |
# | |
# Location of required packages | |
# | |
WXWIN_ROOT = $(realpath $(WXWIN)) | |
FFTW_ROOT ?= f:/MingW32/src/Sound/FFTW-3.x | |
SOAPY_SDR_ROOT ?= f:/gv/dx-radio/SoapySDR | |
ifeq ($(USE_CLANG),1) | |
CC = clang-cl | |
else | |
CC = cl | |
endif | |
CFLAGS = -nologo -W3 -Zi -TP -EHsc -FI./config.h | |
CFLAGS += -wd4251 -wd4800 | |
LDFLAGS = -nologo -debug -incremental:no -verbose -subsystem:windows | |
OBJ_DIR = MSVC_obj | |
ifeq ($(USE_DEBUG),1) | |
CFLAGS += -GF -GS -RTCs -RTCu -RTCc | |
D = d | |
else | |
CFLAGS += -GR -O2 | |
D = | |
endif | |
ifeq ($(USE_WX_DLLS),1) | |
CFLAGS += -DWXUSINGDLL | |
WX_LIB_DIR = $(WXWIN_ROOT)/lib/vc_dll | |
else | |
WX_LIB_DIR = $(WXWIN_ROOT)/lib/vc_lib | |
endif | |
CFLAGS += -MD$(D) | |
EX_LIBS = ../external/liquid-dsp/msvc/32/libliquid.lib | |
# | |
# Seems not to be required? | |
# | |
# EX_LIBS += $(FFTW_ROOT)/fftw3-5.lib | |
# EX_LIBS += $(WX_LIB_DIR)/wxpng$(D).lib \ | |
# $(WX_LIB_DIR)/wxzlib$(D).lib | |
EX_LIBS += $(SOAPY_SDR_ROOT)/SoapySDR$(D).lib \ | |
advapi32.lib comdlg32.lib comctl32.lib \ | |
ole32.lib user32.lib shell32.lib \ | |
WinSpool.Lib oleaut32.lib rpcrt4.lib \ | |
dsound.lib gdi32.lib | |
CFLAGS += -I. -I./util -I./audio -I./sdr \ | |
-I./demod -I./process -I./panel \ | |
-I./ui -I./visual \ | |
-I./forms/Bookmark -I./forms/Dialog \ | |
-I./forms/SDRDevices \ | |
-I./modules/modem -I./modules/modem/analog \ | |
-I../external/tinyxml \ | |
-I../external/wglext \ | |
-I../external/lodepng \ | |
-I../external/hamlib \ | |
-I../external/liquid-dsp/include \ | |
-I../external/rtaudio \ | |
-I../external/cubicvr2/math | |
CFLAGS += -I$(WXWIN_ROOT)/include \ | |
-I$(SOAPY_SDR_ROOT)/include | |
SOURCES = AppConfig.cpp \ | |
AppFrame.cpp \ | |
BookmarkMgr.cpp \ | |
CubicSDR.cpp \ | |
DemodLabelDialog.cpp \ | |
FrequencyDialog.cpp \ | |
IOThread.cpp \ | |
ModemProperties.cpp | |
SOURCES += $(addprefix audio/, \ | |
AudioThread.cpp \ | |
AudioSinkThread.cpp \ | |
AudioSinkFileThread.cpp \ | |
AudioFile.cpp \ | |
AudioFileWAV.cpp) | |
SOURCES += $(addprefix demod/, \ | |
DemodulatorInstance.cpp \ | |
DemodulatorMgr.cpp \ | |
DemodulatorPreThread.cpp \ | |
DemodulatorThread.cpp \ | |
DemodulatorWorkerThread.cpp) | |
SOURCES += $(addprefix forms/Bookmark/, \ | |
BookmarkPanel.cpp \ | |
BookmarkView.cpp) | |
SOURCES += $(addprefix forms/Dialog/, \ | |
AboutDialog.cpp \ | |
AboutDialogBase.cpp \ | |
ActionDialog.cpp \ | |
ActionDialogBase.cpp \ | |
PortSelectorDialog.cpp \ | |
PortSelectorDialogBase.cpp) | |
SOURCES += $(addprefix forms/SDRDevices/, \ | |
SDRDeviceAdd.cpp \ | |
SDRDeviceAddForm.cpp \ | |
SDRDevices.cpp \ | |
SDRDevicesForm.cpp) | |
SOURCES += $(addprefix modules/modem/, \ | |
Modem.cpp \ | |
ModemAnalog.cpp \ | |
ModemDigital.cpp) | |
SOURCES += $(addprefix modules/modem/analog/, \ | |
ModemAM.cpp \ | |
ModemDSB.cpp \ | |
ModemFM.cpp \ | |
ModemFMStereo.cpp \ | |
ModemIQ.cpp \ | |
ModemLSB.cpp \ | |
ModemNBFM.cpp \ | |
ModemUSB.cpp) | |
SOURCES += $(addprefix panel/, \ | |
MeterPanel.cpp \ | |
ScopePanel.cpp \ | |
SpectrumPanel.cpp \ | |
WaterfallPanel.cpp) | |
SOURCES += $(addprefix process/, \ | |
FFTDataDistributor.cpp \ | |
FFTVisualDataThread.cpp \ | |
ScopeVisualProcessor.cpp \ | |
SpectrumVisualDataThread.cpp \ | |
SpectrumVisualProcessor.cpp \ | |
VisualProcessor.cpp) | |
SOURCES += $(addprefix sdr/, \ | |
SDRDeviceInfo.cpp \ | |
SDREnumerator.cpp \ | |
SDRPostThread.cpp \ | |
SoapySDRThread.cpp) | |
SOURCES += $(addprefix ui/, \ | |
GLPanel.cpp \ | |
UITestCanvas.cpp \ | |
UITestContext.cpp) | |
SOURCES += $(addprefix util/, \ | |
DataTree.cpp \ | |
GLExt.cpp \ | |
GLFont.cpp \ | |
Gradient.cpp \ | |
MouseTracker.cpp \ | |
ThreadBlockingQueue.cpp \ | |
Timer.cpp) | |
SOURCES += $(addprefix visual/, \ | |
ColorTheme.cpp \ | |
GainCanvas.cpp \ | |
ImagePanel.cpp \ | |
InteractiveCanvas.cpp \ | |
MeterCanvas.cpp \ | |
MeterContext.cpp \ | |
ModeSelectorCanvas.cpp \ | |
ModeSelectorContext.cpp \ | |
PrimaryGLContext.cpp \ | |
ScopeCanvas.cpp \ | |
ScopeContext.cpp \ | |
SpectrumCanvas.cpp \ | |
TuningCanvas.cpp \ | |
TuningContext.cpp \ | |
WaterfallCanvas.cpp) | |
SOURCES += $(addprefix ../external/, \ | |
tinyxml/tinystr.cpp \ | |
tinyxml/tinyxml.cpp \ | |
tinyxml/tinyxmlerror.cpp \ | |
tinyxml/tinyxmlparser.cpp \ | |
lodepng/lodepng.cpp \ | |
rtaudio/RtAudio.cpp) | |
ifeq ($(USE_HAMLIB),1) | |
VPATH += rig ../external/rs232 | |
SOURCES += rig/RigThread.cpp \ | |
../external/rs232/rs232-win.cpp | |
CFLAGS += -DUSE_HAMLIB \ | |
-I./rig \ | |
-I../external/rs232 | |
EX_LIBS += ../external/hamlib/32/libhamlib-2.lib | |
endif | |
ifeq ($(USE_DIGITAL),1) | |
VPATH += forms/DigitalConsole modules/modem/digital | |
CFLAGS += -DENABLE_DIGITAL_LAB=1 -I./modules/modem/digital -I./forms/DigitalConsole | |
SOURCES += $(addprefix forms/DigitalConsole/, \ | |
DigitalConsole.cpp \ | |
DigitalConsoleFrame.cpp) \ | |
$(addprefix modules/modem/digital/, \ | |
ModemASK.cpp \ | |
ModemAPSK.cpp \ | |
ModemBPSK.cpp \ | |
ModemDPSK.cpp \ | |
ModemFSK.cpp \ | |
ModemGMSK.cpp \ | |
ModemPSK.cpp \ | |
ModemOOK.cpp \ | |
ModemST.cpp \ | |
ModemSQAM.cpp \ | |
ModemQAM.cpp \ | |
ModemQPSK.cpp) | |
endif | |
OBJECTS = $(addprefix $(OBJ_DIR)/, $(notdir $(SOURCES:.cpp=.obj))) | |
GENERATED = config.h | |
EXT_DLLS = ../external/liquid-dsp/msvc/32/libliquid.dll \ | |
$(SOAPY_SDR_ROOT)/SoapySDR$(D).dll | |
ifeq ($(USE_HAMLIB),1) | |
EXT_DLLS += ../external/hamlib/32/libhamlib-2.dll | |
endif | |
MODULE_DLLS = $(SOAPY_SDR_ROOT)/SoapyRTLSDR/modules/rtlsdrSupport$(D).dll | |
all: $(GENERATED) $(OBJ_DIR) ../bin $(PROGRAM) copy_to_bin | |
@echo 'Welcome to $(PROGRAM).' | |
$(OBJ_DIR) ../bin ../bin/modules ../bin/share ../bin/share/fonts: | |
- mkdir $@ | |
$(PROGRAM): $(OBJECTS) $(OBJ_DIR)/CubicSDR.res | |
$(call link_EXE, $@, $^) | |
.PHONY: copy_to_bin delete_bin | |
copy_to_bin: ../bin ../bin/modules ../bin/share ../bin/share/fonts | |
cp --update $(EXT_DLLS) ../bin | |
cp --update $(MODULE_DLLS) ../bin/modules | |
cp --update CubicSDR.png ../bin/share | |
cp --update ../font/*.png ../font/*.fnt ../bin/share/fonts | |
delete_bin: | |
rm -fR ../bin/* | |
- rmdir ../bin | |
ifeq ($(USE_MP_COMPILE),1) | |
$(OBJECTS): $(SOURCES) | |
$(CC) -MP -c $(CFLAGS) -Fo./$(OBJ_DIR)\\ $(filter %.cpp, $^) | |
@echo | |
endif | |
$(OBJ_DIR)/%.obj: %.cpp | |
$(CC) -c $(CFLAGS) -Fo./$@ $< | |
@echo | |
clean: | |
rm -f $(OBJ_DIR)/* $(GENERATED) cpp_filter.py | |
vclean realclean: clean delete_bin | |
rm -f .depend.MSVC | |
- rmdir $(OBJ_DIR) | |
# | |
# GNU-make macros: | |
# (not all may be needed) | |
# | |
define link_EXE | |
$(info Linking $(strip $(1))) | |
link $(LDFLAGS) -out:$(strip $(1)) $(2) $(EX_LIBS) > link.tmp | |
cat link.tmp >> $(1:.exe=.map) | |
rm -f link.tmp | |
@echo | |
endef | |
define make_res | |
$(info Creating $(strip $(1))) | |
rc -D_MSC_VER -nologo -Fo./$(strip $(1)) $(2) | |
@echo | |
endef | |
define WARNING | |
/* | |
* DO NOT EDIT! This file was automatically generated | |
* from $(realpath $(THIS_FILE)) at $(DATE). Edit that file instead. | |
*/ | |
endef | |
# | |
# 'clang-cl' may not like stuff in '%CL'. | |
# Just remove it. | |
# | |
export CL= | |
define CONFIG_H | |
#if defined(DOING_GCC_DEPEND) | |
#define _WX_CHKCONF_H_ 1 | |
#define wxUSE_GLCANVAS 1 | |
#define WIN32 1 | |
#endif | |
#if !defined(WIN32) | |
#define WIN32 1 | |
#endif | |
#define _WIN32_WINNT 0x0501 | |
#define _WINDOWS | |
#define _UNICODE | |
#define UNICODE | |
//#define WIN32_LEAN_AND_MEAN /* RtAudio.cpp cannot have this! */ | |
#define NOMINMAX /* Do not define min()/max() in <windows.h> */ | |
#define _CRT_SECURE_NO_WARNINGS | |
#define _CRT_NONSTDC_NO_WARNINGS | |
#define CUBICSDR_VERSION "$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH)" | |
#define CUBICSDR_BUILD_TITLE "CubicSDR v" ## CUBICSDR_VERSION " by Charles J. Cliffe (@ccliffe) :: www.cubicsdr.com" | |
#define CUBICSDR_INSTALL_NAME "CubicSDR" | |
#define CUBICSDR_ENABLE_VIEW_DEMOD 1 | |
#define CUBICSDR_ENABLE_VIEW_SCOPE 1 | |
#define CUBICSDR_ENABLE_ABOUT_DIALOG 1 | |
#define USE_SOAPY_SDR 1 | |
#define RES_FOLDER "./share" | |
#define BUNDLE_SOAPY_MODS 1 | |
#define BUNDLED_MODS_ONLY 1 | |
/* For ../external/rtaudio/RtAudio.cpp | |
*/ | |
#define __WINDOWS_DS__ 1 /* DirectSound */ | |
#define __WINDOWS_WASAPI__ 1 /* Windows Audio Session API */ | |
endef | |
config.h: $(THIS_FILE) | |
$(info Generating $@) | |
$(file > $@,$(WARNING)) | |
$(file >> $@,#ifndef _CONFIG_H) | |
$(file >> $@,$(CONFIG_H)) | |
$(file >> $@,#endif /* _CONFIG_H */) | |
define CUBICSDR_RC | |
#include <winver.h> | |
#define RC_VERSION $(VER_MAJOR),$(VER_MINOR),$(VER_PATCH),0 | |
#define VER_STRING "$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH).0" | |
APPICON ICON "../icon/CubicSDR.ico" | |
FRAME_ICON ICON "../icon/CubicSDR.ico" | |
VS_VERSION_INFO VERSIONINFO | |
FILEVERSION RC_VERSION | |
PRODUCTVERSION RC_VERSION | |
FILEFLAGSMASK 0x3fL | |
FILEOS VOS__WINDOWS32 | |
FILETYPE VFT_APP | |
FILEFLAGS 0x0L | |
FILESUBTYPE 0x0L | |
BEGIN | |
BLOCK "StringFileInfo" | |
BEGIN | |
BLOCK "040904b0" | |
BEGIN | |
VALUE "CompanyName", "http://cubicsdr.com/" | |
VALUE "FileDescription", "Cross-Platform Software-Defined Radio Application." | |
VALUE "FileVersion", VER_STRING " (MSVC release)" | |
VALUE "InternalName", "CubicSDR" | |
VALUE "LegalCopyright", "GNU General Public License v2.0" | |
VALUE "LegalTrademarks", "https://github.com/cjcliffe/CubicSDR/blob/master/LICENSE" | |
VALUE "OriginalFilename", "CubicSDR.exe" | |
VALUE "ProductName", "CubicSDR" | |
VALUE "ProductVersion", VER_STRING " (MSVC release)" | |
VALUE "PrivateBuild", "The privat build of <gvanem@yahoo.no>." | |
VALUE "SpecialBuild", "" | |
VALUE "Comments", "Built on $(DATE)" | |
END | |
END | |
BLOCK "VarFileInfo" | |
BEGIN | |
VALUE "Translation", 0x409, 1200 | |
END | |
END | |
endef | |
$(OBJ_DIR)/CubicSDR.rc: $(THIS_FILE) | |
$(info Generating $@) | |
$(file > $@,$(WARNING)) | |
$(file >> $@,$(CUBICSDR_RC)) | |
$(OBJ_DIR)/CubicSDR.res: $(OBJ_DIR)/CubicSDR.rc | |
$(call make_res, $@, $<) | |
%.i: %.cpp FORCE $(GENERATED) cpp_filter.py | |
$(CC) -E $(CFLAGS) $< | python cpp_filter.py > $@ | |
@echo | |
FORCE: | |
define CPP_FILTER_PY | |
import sys, os | |
try: | |
import ntpath | |
except ImportError as e: | |
print ("Failed to import ntpath: %s" % e) | |
sys.exit(1) | |
def _win32_abspath (path): | |
path = ntpath.abspath (path) | |
return path.replace ('\\', '/') | |
def skip_cwd (s1, s2): | |
''' Skip the leading part that is in common with s1 and s2 | |
''' | |
i = 0 | |
while i < len(s1) and s1[i] == s2[i]: | |
i += 1 | |
return s2[i:] | |
cwd = _win32_abspath (os.getcwd()) + '/' | |
last_line = '??' | |
last_fname = '??' | |
empty_lines = 0 | |
while True: | |
line = sys.stdin.readline() | |
if not line: | |
break | |
if line.startswith('\n') or line.startswith('\r'): | |
empty_lines += 1 | |
continue | |
line = line.replace ("\\\\", "/") | |
fname = None | |
quote = line.find ('\"') | |
if line.startswith ("#line ") and quote > 0: | |
fname = _win32_abspath (line[quote:]) | |
last_fname = fname | |
if line.strip() != '' and last_line != '': | |
if fname is None or fname != last_fname: | |
print (line, end="") | |
if line.strip() == '}': # Print a newline after a function | |
print ("") | |
last_line = line | |
if empty_lines > 0: | |
sys.stderr.write ("Removed %d empty lines." % empty_lines) | |
endef | |
cpp_filter.py: $(THIS_FILE) | |
@echo 'Generating $@...' | |
$(file > $@,#!/usr/env/python) | |
$(file >> $@,#) | |
$(file >> $@,# DO NOT EDIT! This file was generated automatically) | |
$(file >> $@,# from $(realpath $<). Edit that file instead.) | |
$(file >> $@,#) | |
$(file >> $@,from __future__ import print_function) | |
$(file >> $@,if 1:) | |
$(file >> $@,$(CPP_FILTER_PY)) | |
DEP_REPLACE = sed -e 's/\(.*\)\.o: /\n$$(OBJ_DIR)\/\1.obj: /' | |
DEP_CFLAGS = --include ./config.h -DDOING_GCC_DEPEND -std=c++11 $(filter -I% -D%, $(CFLAGS)) | |
depend: $(GENERATED) | |
gcc -MM $(DEP_CFLAGS) $(SOURCES) | $(DEP_REPLACE) > .depend.MSVC | |
-include .depend.MSVC | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment