Last active
December 10, 2023 00:14
-
-
Save gvanem/f54eefad9e84954d390c8bd939ec34ae to your computer and use it in GitHub Desktop.
GNU-makefile for Hamlib (MSVC+clang-cl)
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 for Hamlib (MSVC / clang-cl). | |
# | |
# G. Vanem <[email protected]> 2019 - 2023. | |
# | |
THIS_FILE := Makefile.Windows | |
DATE := $(shell date +%d-%B-%Y) | |
ABI_VER := 4 | |
comma := , | |
# | |
# From 'configure.ac' and 'AC_INIT()': | |
# | |
MAJOR_VER = 4 | |
MINOR_VER = 6 | |
VERSION = $(MAJOR_VER).$(MINOR_VER) | |
# | |
# Options: | |
# Do a 'make vclean' after changing any of these. | |
# | |
USE_LIBGD ?= 1 | |
USE_LIBINDI ?= 0 | |
USE_LIBREADLINE ?= 0 | |
USE_LIBUSB ?= 1 | |
USE_LIBUSRP ?= 1 | |
USE_LIBXML2 ?= 1 | |
USE_LUAJIT ?= 1 | |
USE_GV_DEBUG ?= 1 | |
USE_MP_COMPILE ?= 1 | |
USE_VERBOSE_DEBUG ?= 0 | |
# | |
# Add support for a 'GnuRadio' device. | |
# Impossible as it is not up-to-date with current GnuRadio 3.9+ API. | |
# | |
USE_GNURADIO ?= 0 | |
# | |
# Use the Winsock tracing library: | |
# https://github.com/gvanem/wsock-trace | |
# | |
USE_WSOCK_TRACE ?= 1 | |
# | |
# Set to 0 for no Python module. | |
# Set to 2 to create a Python 2.x module. | |
# Set to 3 to create a Python 3.x module. | |
# | |
USE_PY_BINDING ?= 3 | |
# | |
# Show all warning using 'clang-cl'. | |
# There are LOTS! | |
# | |
USE_MAX_WARNINGS ?= 0 | |
# | |
# Use 'astyle' in the "%.i: %.c" preprocess rules below? | |
# | |
USE_ASTYLE ?= 1 | |
# | |
# For some packages, one could do: | |
# 'vcpkg install libgd:x86-windows --debug' or | |
# 'vcpkg install libgd:x64-windows --debug' | |
# | |
VCPKG_ROOT := $(realpath $(VCPKG_ROOT)) | |
# | |
# Change these as needed: | |
# (or create env-vars like 'LIBXML2_ROOT=c:/whatever/xml2'). | |
# | |
BOOST_ROOT ?= f:/MinGW32/src/CPP/Boost_1_82_0 | |
GNURADIO_ROOT ?= f:/gv/dx-radio/GnuRadio/gv-build | |
LIBXML2_ROOT ?= f:/MinGW32/src/Parsers/libxml2 | |
LIBICONV_ROOT ?= f:/MinGW32/src/libiconv-1.15 | |
LUAJIT_ROOT ?= f:/MinGW32/src/LUA/LuaJIT | |
LUA5_ROOT ?= f:/MinGW32/src/LUA/Lua-5.4 | |
LIBUSB_ROOT ?= f:/MinGW32/src/USB/libusb | |
LIBUSRP_ROOT ?= f:/gv/dx-radio/Osmocom-SDR/libusrp/host | |
LIBINDI_ROOT ?= f:/ProgramFiler/Stellarium/src/src/external/libindi | |
LIBGD_ROOT ?= $(VCPKG_ROOT)/installed/$(CPU)-windows | |
LIBREADLINE_ROOT ?= $(VCPKG_ROOT)/installed/$(CPU)-windows-static | |
PTHREAD_ROOT ?= f:/MinGW32/src/pthreads-w32-3-0/PTHREADS-BUILT-$(CPU) | |
# | |
# For Python stuff besides the '$(Hamlib_PYD)' target: | |
# | |
PYTHON ?= py -3 | |
ifeq ($(USE_LUAJIT),1) | |
LUA_ROOT = $(realpath $(LUAJIT_ROOT)) | |
LUA_LIB = $(LUA_ROOT)/lib/luajit-$(CPU).lib | |
else | |
LUA_ROOT = $(realpath $(LUA5_ROOT)) | |
LUA_LIB = $(LUA_ROOT)/lib/lua54-$(CPU).lib | |
endif | |
MKDIR = mkdir | |
RMDIR = rmdir --parents | |
MOVE = mv --force | |
COPY = cp --preserve=timestamps --update | |
# | |
# Warn on undefined variables in GNU-make. | |
# | |
MAKEFLAGS += ---warn-undefined-variables | |
# | |
# 'clang-cl' may not like stuff in '%CL'. | |
# Just remove it. | |
# | |
export CL= | |
define Usage | |
Usage: "$(MAKE) -f $(THIS_FILE) CC=[cl | clang-cl] [CPU=x86 | x64] [all | clean | vclean | realclean | depend | doxy_docs | py_module | lua_module]" | |
Specify CC=cl - use MSVC | |
Specify CC=clang-cl - use clang-cl | |
endef | |
ifeq ($(USER),gv) | |
RC_PRIVATE = "The privat build of <[email protected]>." | |
else ifneq ($(APPVEYOR_PROJECT_NAME),) | |
RC_PRIVATE = "Built on Appveyor." | |
else | |
RC_PRIVATE = "" | |
endif | |
OBJ_DIR = objects | |
ifneq ($(CC),clang-cl) | |
ifneq ($(CC),cl) | |
$(error $(Usage)) | |
endif | |
endif | |
CFLAGS = -nologo -MD -Zi -O2 \ | |
-FI./include/hamlib/config.h \ | |
-I. \ | |
-I./include \ | |
-I./include/hamlib \ | |
-I./lib \ | |
-I./src \ | |
-I./security \ | |
-I./tests \ | |
-I$(PTHREAD_ROOT)/include | |
LDFLAGS = -nologo -debug -incremental:no -verbose -machine:$(CPU) -nodefaultlib:uuid.lib | |
RCFLAGS = -nologo -I. | |
CXXFLAGS = -EHsc -std:c++17 | |
ifeq ($(CC),clang-cl) | |
RCFLAGS += -D__clang__ | |
CFLAGS += -fms-compatibility \ | |
-ferror-limit=5 \ | |
-Wall \ | |
-DUSE_MAX_WARNINGS=$(USE_MAX_WARNINGS) | |
else | |
CFLAGS += -W3 -diagnostics:caret | |
CXXFLAGS += -Zc:__cplusplus | |
RCFLAGS += -D_MSC_VER | |
endif | |
ifeq ($(USE_WSOCK_TRACE),1) | |
WS2_32_LIB = wsock_trace-$(CPU).lib | |
else | |
WS2_32_LIB = ws2_32.lib | |
endif | |
# | |
# External libraries for '$(Hamlib_DLL)': | |
# | |
PTHREAD_LIB = $(PTHREAD_ROOT)/lib/libpthreadVC3.lib | |
Hamlib_EX_LIBS = $(PTHREAD_LIB) | |
Hamlib_OS_LIBS = advapi32.lib iphlpapi.lib kernel32.lib winmm.lib $(WS2_32_LIB) | |
# | |
# The DLL and library names: | |
# | |
Hamlib_DLL = bin/Hamlib-$(ABI_VER).dll | |
Hamlib_LUA_DLL = bin/HamlibLua.dll | |
Hamlib_PYD = bin/_Hamlib.pyd | |
Hamlib_IMP_LIB = lib/Hamlib-$(ABI_VER)_imp.lib | |
Hamlib_STAT_LIB = lib/Hamlib-$(ABI_VER).lib | |
# | |
# The C++ library | |
# | |
Hamlibpp_DLL = bin/Hamlib-$(ABI_VER)++.dll | |
Hamlibpp_IMP_LIB = lib/Hamlib-$(ABI_VER)++_imp.lib | |
# | |
# The internal utility library; '$(hamlib_misc_SRC)'. | |
# | |
misc_LIB = lib/misc.lib | |
# | |
# Foreign .DLLs needed: | |
# | |
COPY_DLLs = | |
# | |
# What to build: | |
# | |
TARGETS = $(Hamlib_STAT_LIB) $(Hamlib_DLL) \ | |
$(Hamlib_IMP_LIB) $(misc_LIB) | |
# | |
# The C++ interface is dynamic only. | |
# | |
TARGETS += $(Hamlibpp_DLL) $(Hamlibpp_IMP_LIB) | |
# | |
# Untested: | |
# | |
ifeq ($(USE_LIBREADLINE),1) | |
CFLAGS += -DHAVE_LIBREADLINE \ | |
-DHAVE_READLINE_READLINE_H \ | |
-DREADLINE_STATIC \ | |
-I$(LIBREADLINE_ROOT)/include | |
READLINE_LIB = $(LIBREADLINE_ROOT)/lib/readline.lib | |
else | |
READLINE_LIB = | |
endif | |
Hamlib_EX_LIBS += $(READLINE_LIB) | |
# | |
# Use '$(Hamlib_DLL)' for all C programs. | |
# | |
C_PROG_LIBS = $(misc_LIB) $(Hamlib_IMP_LIB) $(PTHREAD_LIB) $(READLINE_LIB) | |
# | |
# Use '$(HAMLIBpp_DLL) and '$(Hamlib_DLL)' for all C++ programs. | |
# | |
CPP_PROG_LIBS = $(Hamlib_IMP_LIB) $(Hamlibpp_IMP_LIB) | |
# | |
# For 'rigs/kit/usrp.c' and 'rigs/kit/usrp_impl.cc'. | |
# This needs Boost too. | |
# | |
ifeq ($(USE_LIBUSRP),1) | |
CFLAGS += -DHAVE_USRP \ | |
-I$(BOOST_ROOT) \ | |
-I$(LIBUSRP_ROOT)/include \ | |
-I$(LIBUSRP_ROOT)/include/usrp | |
Hamlib_EX_LIBS += $(LIBUSRP_ROOT)/lib/libUSRP_imp-$(CPU).lib | |
COPY_DLLs += $(LIBUSRP_ROOT)/bin/libUSRP-$(CPU).dll \ | |
$(LIBUSRP_ROOT)/bin/libUSRP-$(CPU).pdb | |
vpath %.cc rigs/kit | |
hamlib_CC_SRC = rigs/kit/usrp_impl.cc | |
endif | |
ifeq ($(USE_LIBUSB),1) | |
CFLAGS += -DHAVE_LIBUSB \ | |
-DHAVE_LIBUSB_H \ | |
-I$(LIBUSB_ROOT)/libusb | |
Hamlib_EX_LIBS += $(LIBUSB_ROOT)/libusb-1.0_imp-$(CPU).lib | |
endif | |
ifeq ($(USE_VERBOSE_DEBUG),1) | |
CFLAGS += -DDEBUG_HOSED -DDEBUG_VERBOSE -DHASH_BLOOM | |
endif | |
CFLAGS += -I./$(OBJ_DIR) | |
c_to_obj = $(addprefix $(OBJ_DIR)/, \ | |
$(notdir $(1:.c=.obj))) | |
cc_to_obj = $(addprefix $(OBJ_DIR)/, \ | |
$(notdir $(1:.cc=.obj))) | |
cpp_to_obj = $(addprefix $(OBJ_DIR)/, \ | |
$(notdir $(1:.cpp=.obj))) | |
c_to_i = $(notdir $(1:.c=.i)) | |
cc_to_i = $(notdir $(1:.cc=.i)) | |
c_to_exe = $(addprefix bin/, $(notdir $(1:.c=.exe))) | |
cc_to_exe = $(addprefix bin/, $(notdir $(1:.cc=.exe))) | |
cpp_to_exe = $(addprefix bin/, $(notdir $(1:.cpp=.exe))) | |
vpath %.cc c++ | |
vpath %.c src \ | |
security \ | |
tests \ | |
amplifiers/elecraft \ | |
amplifiers/expert \ | |
amplifiers/gemini \ | |
scripts/MSVC/2022/$(CPU)/hamlibTest | |
vpath %.c $(addprefix rigs/, \ | |
adat \ | |
alinco \ | |
anytone \ | |
aor \ | |
barrett \ | |
codan \ | |
dorji \ | |
drake \ | |
dummy \ | |
elad \ | |
flexradio \ | |
gomspace \ | |
icmarine \ | |
icom \ | |
jrc \ | |
kachina \ | |
kenwood \ | |
kit \ | |
lowe \ | |
mds \ | |
pcr \ | |
prm80 \ | |
racal \ | |
rft \ | |
rs \ | |
skanti \ | |
tapr \ | |
tentec \ | |
tuner \ | |
uniden \ | |
winradio \ | |
wj \ | |
yaesu) | |
vpath %.c $(addprefix rotators/, \ | |
amsat \ | |
apex \ | |
ars \ | |
celestron \ | |
cnctrk \ | |
easycomm \ | |
ether6 \ | |
flir \ | |
fodtrack \ | |
grbltrk \ | |
gs232a \ | |
heathkit \ | |
indi \ | |
ioptron \ | |
m2 \ | |
meade \ | |
prosistel \ | |
radant \ | |
rotorez \ | |
saebrtrack \ | |
sartek \ | |
satel \ | |
spid \ | |
ts7400) | |
# | |
# For compiling: | |
# HamlibPy2_wrap.c | |
# HamlibPy3_wrap. | |
# HamlibLua_wrap.c | |
# Hamlibpp.rc | |
# Hamlib.rc | |
# | |
vpath %.c $(OBJ_DIR) | |
vpath %.rc $(OBJ_DIR) | |
# | |
# For compiling 'scripts/MSVC/2022/$(CPU)/hamlibTest/hamlibTest.* | |
# | |
vpath %.cpp scripts/MSVC/2022/$(CPU)/hamlibTest | |
vpath %.rc scripts/MSVC/2022/$(CPU)/hamlibTest | |
# | |
# All of these use '$(Hamlib_DLL)': | |
# | |
TEST_PROGS = $(addprefix bin/, \ | |
ampctl.exe \ | |
ampctld.exe \ | |
dumpmem.exe \ | |
example.exe \ | |
hamlibmodels.exe \ | |
hamlibTest.exe \ | |
listrigs.exe \ | |
rigctl.exe \ | |
rigctld.exe \ | |
rigctlcom.exe \ | |
rigctlsync.exe \ | |
rigctltcp.exe \ | |
rigfreqwalk.exe \ | |
rigsmtr.exe \ | |
rigswr.exe \ | |
rigtestmcast.exe \ | |
rigtestmcastrx.exe \ | |
rig_bench.exe \ | |
rotctl.exe \ | |
rotctld.exe \ | |
simple.exe \ | |
testbcd.exe \ | |
testcache.exe \ | |
testcookie.exe \ | |
testfreq.exe \ | |
testloc.exe \ | |
testmW2power.exe \ | |
testrig.exe \ | |
testrigcaps.exe \ | |
testrigopen.exe \ | |
testsecurity.exe \ | |
testtrn.exe \ | |
sctest.exe) | |
vpath %.c simulators | |
simulators_SRC = $(addprefix simulators/, \ | |
simatd578.c \ | |
simelecraft.c \ | |
simft736.c \ | |
simft747gx.c \ | |
simft817.c \ | |
simft818.c \ | |
simft847.c \ | |
simft897.c \ | |
simft990.c \ | |
simft991.c \ | |
simft1000.c \ | |
simftdx101.c \ | |
simftdx1200.c \ | |
simftdx3000.c \ | |
simftdx5000.c \ | |
simic275.c \ | |
simic705.c \ | |
simic905.c \ | |
simic7000.c \ | |
simic7100.c \ | |
simic7200.c \ | |
simic7300.c \ | |
simic7600.c \ | |
simic7610.c \ | |
simic7851.c \ | |
simic9100.c \ | |
simic9700.c \ | |
simicgeneric.c \ | |
simid5100.c \ | |
simjupiter.c \ | |
simkenwood.c \ | |
simpowersdr.c \ | |
simqrplabs.c \ | |
simrotorez.c \ | |
simspid.c \ | |
simtmd700.c \ | |
simtrusdx.c \ | |
simts450.c \ | |
simts590.c \ | |
simts950.c \ | |
simts990.c \ | |
simxiegug90.c \ | |
simyaesu.c) | |
simulators_OBJ = $(call c_to_obj, $(simulators_SRC)) | |
# | |
# Various simulator programs: | |
# | |
TEST_PROGS += $(call c_to_exe. $(simulators_SRC)) | |
ifneq ($(APPVEYOR_PROJECT_NAME),) | |
# | |
# TODO: | |
# build with 'LIBUSB_ROOT = ./CI/libusb', 'LIBXML2_ROOT = ./CI/libxml2' etc. | |
# when running via 'appveyor.yml' | |
# | |
endif | |
ifeq ($(USE_GV_DEBUG),1) | |
CFLAGS += -DUSE_GV_DEBUG | |
endif | |
ifeq ($(USE_LIBXML2),1) | |
TEST_PROGS += bin/rigmem.exe | |
CFLAGS += -I$(LIBXML2_ROOT)/include \ | |
-I$(LIBICONV_ROOT)/include \ | |
-DHAVE_XML2 | |
# | |
# Use the dynamic version of 'libxml2'. | |
# I.e. do not set 'CFLAGS += -DLIBXML_STATIC'. | |
# Otherwise we could need to link to a static 'Iconv', 'Zlib' and | |
# a 'liblzma' too (depending on how 'libxml2' was built). | |
# | |
XML2_LIB = $(LIBXML2_ROOT)/lib/xml2_imp-$(CPU).lib | |
endif | |
ifeq ($(USE_LIBGD),1) | |
TEST_PROGS += bin/rigmatrix.exe | |
CFLAGS += -I$(LIBGD_ROOT)/include \ | |
-I$(LIBGD_ROOT)/src | |
# | |
# The 'libgd' import-library. | |
# | |
LIBGD_LIB = $(LIBGD_ROOT)/lib/libgd.lib | |
# | |
# Copy the needed .DLLs here to avoid another DLL-hell. | |
# | |
LIBGD_DLLs = $(LIBGD_ROOT)/bin/libgd.dll \ | |
$(LIBGD_ROOT)/bin/libpng16.dll \ | |
$(LIBGD_ROOT)/bin/jpeg62.dll \ | |
$(LIBGD_ROOT)/bin/freetype.dll \ | |
$(LIBGD_ROOT)/bin/fontconfig-1.dll \ | |
$(LIBGD_ROOT)/bin/tiff.dll \ | |
$(LIBGD_ROOT)/bin/bz2.dll \ | |
$(LIBGD_ROOT)/bin/brotlicommon.dll \ | |
$(LIBGD_ROOT)/bin/brotlidec.dll \ | |
$(LIBGD_ROOT)/bin/libexpat.dll \ | |
$(LIBGD_ROOT)/bin/libsharpyuv.dll \ | |
$(LIBGD_ROOT)/bin/zlib1.dll \ | |
$(LIBGD_ROOT)/bin/liblzma.dll \ | |
$(LIBGD_ROOT)/bin/libwebp.dll | |
# | |
# Copy the respective .PDB files too. | |
# | |
COPY_DLLs += $(LIBGD_DLLs) $(LIBGD_DLLs:.dll=.pdb) | |
# | |
# Except for this that is named 'zlib.pdb'! | |
# | |
COPY_DLLs := $(filter-out $(LIBGD_ROOT)/bin/zlib1.pdb, $(COPY_DLLs)) | |
endif | |
# | |
# These always uses '$(Hamlibpp_DLL)'. | |
# | |
TEST_PROGS += bin/testcpp.exe \ | |
bin/throw-test.exe | |
# | |
# All .c-files for '$(Hamlib_DLL)'. | |
# Except for those in '$(hamlib_misc_SRC)' which do not need to be exported. | |
# | |
hamlib_C_SRC = $(addprefix src/, \ | |
amp_conf.c \ | |
amp_reg.c \ | |
amp_settings.c \ | |
amplifier.c \ | |
cal.c \ | |
cache.c \ | |
cm108.c \ | |
conf.c \ | |
debug.c \ | |
event.c \ | |
ext.c \ | |
extamp.c \ | |
fifo.c \ | |
gpio.c \ | |
locator.c \ | |
iofunc.c \ | |
mem.c \ | |
misc.c \ | |
microham.c \ | |
multicast.c \ | |
network.c \ | |
parallel.c \ | |
register.c \ | |
rig.c \ | |
rot_conf.c \ | |
rot_ext.c \ | |
rot_reg.c \ | |
rot_settings.c \ | |
rotator.c \ | |
serial.c \ | |
settings.c \ | |
sleep.c \ | |
snapshot_data.c \ | |
sprintflst.c \ | |
tones.c \ | |
usb_port.c) | |
hamlib_C_SRC += $(addprefix security/, \ | |
aes.c \ | |
AESStringCrypt.c \ | |
md5.c \ | |
password.c \ | |
sha256.c) | |
hamlib_C_SRC += $(addprefix rigs/dummy/, \ | |
aclog.c \ | |
amp_dummy.c \ | |
dummy.c \ | |
dummy_common.c \ | |
flrig.c \ | |
netampctl.c \ | |
netrigctl.c \ | |
netrotctl.c \ | |
quisk.c \ | |
rot_dummy.c \ | |
sdrsharp.c \ | |
tci1x.c \ | |
trxmanager.c) | |
hamlib_C_SRC += $(addprefix rigs/adat/, \ | |
adat.c \ | |
adt_200a.c) | |
hamlib_C_SRC += $(addprefix rigs/alinco/, \ | |
alinco.c \ | |
dx77.c \ | |
dxsr8.c) | |
hamlib_C_SRC += $(addprefix rigs/anytone/, \ | |
anytone.c \ | |
d578.c) | |
hamlib_C_SRC += $(addprefix rigs/aor/, \ | |
aor.c \ | |
ar2700.c \ | |
ar3000.c \ | |
ar3030.c \ | |
ar5000.c \ | |
ar7030.c \ | |
ar7030p.c \ | |
ar7030p_utils.c \ | |
ar8000.c \ | |
ar8200.c \ | |
ar8600.c \ | |
sr2200.c) | |
hamlib_C_SRC += $(addprefix rigs/barrett/, \ | |
4050.c \ | |
950.c \ | |
barrett.c) | |
hamlib_C_SRC += $(addprefix rigs/codan/, \ | |
codan.c) | |
hamlib_C_SRC += $(addprefix rigs/dorji/, \ | |
dorji.c \ | |
dra818.c) | |
hamlib_C_SRC += $(addprefix rigs/drake/, \ | |
drake.c \ | |
r8a.c \ | |
r8b.c) | |
hamlib_C_SRC += $(addprefix rigs/elad/, \ | |
elad.c \ | |
fdm_duo.c) | |
hamlib_C_SRC += $(addprefix rigs/flexradio/, \ | |
dttsp.c \ | |
flexradio.c \ | |
sdr1k.c) | |
hamlib_C_SRC += $(addprefix rigs/gomspace/, \ | |
gs100.c) | |
hamlib_C_SRC += $(addprefix rigs/icmarine/, \ | |
icm700pro.c \ | |
icm710.c \ | |
icm802.c \ | |
icm803.c \ | |
icmarine.c) | |
hamlib_C_SRC += $(addprefix rigs/icom/, \ | |
delta2.c \ | |
frame.c \ | |
ic78.c \ | |
ic92d.c \ | |
ic271.c \ | |
ic275.c \ | |
ic471.c \ | |
ic475.c \ | |
ic703.c \ | |
ic706.c \ | |
ic707.c \ | |
ic718.c \ | |
ic725.c \ | |
ic726.c \ | |
ic728.c \ | |
ic735.c \ | |
ic736.c \ | |
ic737.c \ | |
ic738.c \ | |
ic746.c \ | |
ic751.c \ | |
ic756.c \ | |
ic761.c \ | |
ic765.c \ | |
ic775.c \ | |
ic781.c \ | |
ic785x.c \ | |
ic820h.c \ | |
ic821h.c \ | |
ic910.c \ | |
ic970.c \ | |
ic1275.c \ | |
ic2730.c \ | |
ic7000.c \ | |
ic7100.c \ | |
ic7200.c \ | |
ic7300.c \ | |
ic7410.c \ | |
ic7600.c \ | |
ic7610.c \ | |
ic7700.c \ | |
ic7800.c \ | |
ic9100.c \ | |
icf8101.c \ | |
icom.c \ | |
icr6.c \ | |
icr10.c \ | |
icr20.c \ | |
icr30.c \ | |
icr71.c \ | |
icr72.c \ | |
icr75.c \ | |
icr7000.c \ | |
icr8500.c \ | |
icr8600.c \ | |
icr9000.c \ | |
icr9500.c \ | |
icrx7.c \ | |
id1.c \ | |
id31.c \ | |
id4100.c \ | |
id51.c \ | |
id5100.c \ | |
omni.c \ | |
optoscan.c \ | |
os456.c \ | |
os535.c \ | |
perseus.c \ | |
xiegu.c) | |
hamlib_C_SRC += $(addprefix rigs/jrc/, \ | |
jrc.c \ | |
jst145.c \ | |
nrd525.c \ | |
nrd535.c \ | |
nrd545.c) | |
hamlib_C_SRC += $(addprefix rigs/kachina/, \ | |
505dsp.c \ | |
kachina.c) | |
hamlib_C_SRC += $(addprefix rigs/kenwood/, \ | |
elecraft.c \ | |
flex.c \ | |
flex6xxx.c \ | |
ic10.c \ | |
k2.c \ | |
k3.c \ | |
kenwood.c \ | |
pihpsdr.c \ | |
r5000.c \ | |
th.c \ | |
thd7.c \ | |
thd72.c \ | |
thd74.c \ | |
thf6a.c \ | |
thf7.c \ | |
thg71.c \ | |
tmd700.c \ | |
tmd710.c \ | |
tmv7.c \ | |
transfox.c \ | |
trc80.c \ | |
ts50s.c \ | |
ts140.c \ | |
ts440.c \ | |
ts450s.c \ | |
ts480.c \ | |
ts570.c \ | |
ts590.c \ | |
ts680.c \ | |
ts690.c \ | |
ts711.c \ | |
ts790.c \ | |
ts811.c \ | |
ts850.c \ | |
ts870s.c \ | |
ts890s.c \ | |
ts930.c \ | |
ts940.c \ | |
ts950.c \ | |
ts990s.c \ | |
ts2000.c \ | |
tx500.c \ | |
xg3.c) | |
hamlib_C_SRC += $(addprefix rigs/kit/, \ | |
dds60.c \ | |
drt1.c \ | |
dwt.c \ | |
elektor304.c \ | |
elektor507.c \ | |
fifisdr.c \ | |
funcube.c \ | |
hiqsdr.c \ | |
kit.c \ | |
miniVNA.c \ | |
pcrotor.c \ | |
rs_hfiq.c \ | |
si570avrusb.c \ | |
usrp.c) | |
hamlib_C_SRC += $(addprefix rigs/lowe/, \ | |
hf235.c \ | |
lowe.c) | |
hamlib_C_SRC += $(addprefix rigs/mds/, \ | |
4710.c \ | |
9710.c \ | |
mds.c) | |
hamlib_C_SRC += $(addprefix rigs/pcr/, \ | |
pcr.c \ | |
pcr100.c \ | |
pcr1000.c \ | |
pcr1500.c \ | |
pcr2500.c) | |
hamlib_C_SRC += $(addprefix rigs/prm80/, \ | |
prm80.c \ | |
prm8060.c) | |
hamlib_C_SRC += $(addprefix rigs/racal/, \ | |
ra37xx.c \ | |
ra3702.c \ | |
ra6790.c \ | |
racal.c) | |
hamlib_C_SRC += $(addprefix rigs/rft/, \ | |
ekd500.c \ | |
rft.c) | |
hamlib_C_SRC += $(addprefix rigs/rs/, \ | |
eb200.c \ | |
ek89x.c \ | |
esmc.c \ | |
gp2000.c \ | |
rs.c \ | |
xk2100.c) | |
hamlib_C_SRC += $(addprefix rigs/skanti/, \ | |
skanti.c \ | |
trp8000.c \ | |
trp8255.c) | |
hamlib_C_SRC += $(addprefix rigs/tapr/, \ | |
dsp10.c \ | |
tapr.c) | |
hamlib_C_SRC += $(addprefix rigs/tentec/, \ | |
argonaut.c \ | |
jupiter.c \ | |
omnivii.c \ | |
orion.c \ | |
paragon.c \ | |
pegasus.c \ | |
rx320.c \ | |
rx331.c \ | |
rx340.c \ | |
rx350.c \ | |
tentec.c \ | |
tentec2.c \ | |
tt550.c) | |
# | |
# 'v4l*.c' == "Video For Linux", and not for Windows. | |
# | |
hamlib_C_SRC += $(addprefix rigs/tuner/, \ | |
tuner.c \ | |
v4l.c \ | |
v4l2.c) | |
hamlib_C_SRC += $(addprefix rigs/uniden/, \ | |
bc245.c \ | |
bc250.c \ | |
bc780.c \ | |
bc895.c \ | |
bc898.c \ | |
bcd396t.c \ | |
bcd996t.c \ | |
pro2052.c \ | |
uniden.c \ | |
uniden_digital.c) | |
hamlib_C_SRC += $(addprefix rigs/winradio/, \ | |
g303.c \ | |
g305.c \ | |
g313-win.c \ | |
winradio.c \ | |
wr1000.c \ | |
wr1500.c \ | |
wr1550.c \ | |
wr3100.c \ | |
wr3150.c \ | |
wr3500.c \ | |
wr3700.c) | |
hamlib_C_SRC += $(addprefix rigs/wj/, \ | |
wj.c \ | |
wj8888.c) | |
hamlib_C_SRC += $(addprefix rigs/yaesu/, \ | |
frg100.c \ | |
frg8800.c \ | |
frg9600.c \ | |
ft100.c \ | |
ft450.c \ | |
ft600.c \ | |
ft710.c \ | |
ft736.c \ | |
ft747.c \ | |
ft757gx.c \ | |
ft767gx.c \ | |
ft817.c \ | |
ft840.c \ | |
ft847.c \ | |
ft857.c \ | |
ft890.c \ | |
ft891.c \ | |
ft897.c \ | |
ft900.c \ | |
ft920.c \ | |
ft950.c \ | |
ft980.c \ | |
ft990.c \ | |
ft991.c \ | |
ft990v12.c \ | |
ft1000d.c \ | |
ft1000mp.c \ | |
ft1200.c \ | |
ft2000.c \ | |
ft3000.c \ | |
ft5000.c \ | |
ft9000.c \ | |
ftdx10.c \ | |
ftdx101.c \ | |
ftdx101mp.c \ | |
newcat.c \ | |
vr5000.c \ | |
vx1700.c \ | |
yaesu.c) | |
# | |
# Code for Antenna Rotators: | |
# | |
hamlib_C_SRC += $(addprefix rotators/, \ | |
amsat/if100.c \ | |
apex/apex.c \ | |
apex/sharedloop.c \ | |
ars/ars.c \ | |
celestron/celestron.c \ | |
cnctrk/cnctrk.c \ | |
easycomm/easycomm.c \ | |
ether6/ether6.c \ | |
flir/flir.c \ | |
fodtrack/fodtrack.c \ | |
heathkit/hd1780.c \ | |
ioptron/rot_ioptron.c \ | |
m2/rc2800.c \ | |
meade/meade.c \ | |
prosistel/prosistel.c \ | |
radant/radant.c \ | |
rotorez/rotorez.c \ | |
saebrtrack/saebrtrack.c \ | |
sartek/sartek.c \ | |
satel/satel.c \ | |
spid/spid.c \ | |
ts7400/ts7400.c) | |
hamlib_C_SRC += $(addprefix rotators/grbltrk/, \ | |
grbltrk.c) | |
hamlib_C_SRC += $(addprefix rotators/gs232a/, \ | |
gs232.c \ | |
gs232a.c \ | |
gs232b.c) | |
hamlib_C_SRC += $(addprefix amplifiers/elecraft/, \ | |
kpa.c \ | |
kpa1500.c) | |
hamlib_C_SRC += $(addprefix amplifiers/expert/, \ | |
expert.c) | |
hamlib_C_SRC += $(addprefix amplifiers/gemini/, \ | |
dx1200.c \ | |
gemini.c) | |
hamlib_CPP_SRC = scripts/MSVC/2022/$(CPU)/hamlibTest/hamlibTest.cpp | |
# | |
# Untested. | |
# | |
ifeq ($(USE_LIBINDI),1) | |
vpath %.c $(LIBINDI_ROOT)/libs/indibase | |
CFLAGS += -DHAVE_LIBINDI=1 \ | |
-DHAVE_INDIBASE_LAYOUT=1 \ | |
-I$(LIBINDI_ROOT) \ | |
-I$(LIBINDI_ROOT)/libs \ | |
-I$(LIBINDI_ROOT)/../zlib | |
hamlib_C_SRC += rotators/indi/indi.c | |
hamlib_CPP_SRC += rotators/indi/indi_wrapper.cpp \ | |
$(addprefix $(LIBINDI_ROOT)/libs/indibase/, \ | |
basedevice.cpp \ | |
indiproperty.cpp) | |
endif | |
ifeq ($(USE_GNURADIO),1) | |
vpath %.c extra/gnuradio | |
vpath %.cc extra/gnuradio | |
CFLAGS += -I./extra/gnuradio -I$(GNURADIO_ROOT)/include | |
hamlib_C_SRC += $(addprefix extra/gnuradio/, \ | |
gr.c \ | |
graudio.c \ | |
mc4020.c) | |
hamlib_CC_SRC += gnuradio/gnuradio.cc | |
endif | |
# | |
# Various support code for Hamlib's internal use: | |
# | |
hamlib_misc_SRC = $(addprefix lib/, \ | |
asyncpipe.c \ | |
cJSON.c \ | |
precise_time.c \ | |
termios.c \ | |
win-misc.c) | |
hamlib_misc_SRC += $(addprefix lib/, \ | |
getopt_long.c \ | |
usleep.c) | |
# | |
# .cc sources for $(Hamlibpp_DLL)': | |
# | |
hamlibpp_SRC = $(addprefix c++/, \ | |
ampclass.cc \ | |
rigclass.cc \ | |
rotclass.cc) | |
# | |
# .c sources for various programs: | |
# | |
ampctl_SRC = $(addprefix tests/, \ | |
ampctl.c \ | |
ampctl_parse.c \ | |
dumpcaps_amp.c) | |
ampctld_SRC = $(addprefix tests/, \ | |
ampctld.c \ | |
ampctl_parse.c \ | |
dumpcaps_amp.c) | |
rigctlcom_SRC = $(addprefix tests/, \ | |
dumpcaps.c \ | |
dumpstate.c \ | |
rigctlcom.c \ | |
rigctl_parse.c \ | |
rig_tests.c) | |
rigctl_SRC = $(addprefix tests/, \ | |
dumpcaps.c \ | |
dumpstate.c \ | |
rigctl.c \ | |
rigctl_parse.c \ | |
rig_tests.c) | |
rigctld_SRC = $(addprefix tests/, \ | |
dumpcaps.c \ | |
dumpstate.c \ | |
rigctld.c \ | |
rigctl_parse.c \ | |
rig_tests.c) | |
rigctlsync_SRC = $(addprefix tests/, \ | |
dumpcaps.c \ | |
dumpstate.c \ | |
rigctlsync.c \ | |
rigctl_parse.c \ | |
rig_tests.c) | |
rigctltcp_SRC = $(addprefix tests/, \ | |
dumpcaps.c \ | |
dumpstate.c \ | |
rigctltcp.c \ | |
rigctl_parse.c \ | |
rig_tests.c) | |
rigmem_SRC = $(addprefix tests/, \ | |
rigmem.c \ | |
memcsv.c \ | |
memload.c \ | |
memsave.c) | |
rotctl_SRC = $(addprefix tests/, \ | |
rotctl.c \ | |
rotctl_parse.c \ | |
dumpcaps_rot.c) | |
rotctld_SRC = $(addprefix tests/, \ | |
rotctld.c \ | |
rotctl_parse.c \ | |
dumpcaps_rot.c) | |
hamlib_C_OBJ = $(call c_to_obj, $(hamlib_C_SRC)) | |
hamlib_CC_OBJ = $(call cc_to_obj, $(hamlib_CC_SRC)) | |
hamlib_CPP_OBJ = $(call cpp_to_obj, $(hamlib_CPP_SRC)) | |
hamlibpp_OBJ = $(call cc_to_obj, $(hamlibpp_SRC)) | |
hamlib_misc_OBJ = $(call c_to_obj, $(hamlib_misc_SRC)) | |
ampctl_OBJ = $(call c_to_obj, $(ampctl_SRC)) | |
ampctld_OBJ = $(call c_to_obj, $(ampctld_SRC)) | |
dumpstate_OBJ = $(call c_to_obj, $(dumpstate_SRC)) | |
rigctlcom_OBJ = $(call c_to_obj, $(rigctlcom_SRC)) | |
rigctl_OBJ = $(call c_to_obj, $(rigctl_SRC)) | |
rigctld_OBJ = $(call c_to_obj, $(rigctld_SRC)) | |
rigctlsync_OBJ = $(call c_to_obj, $(rigctlsync_SRC)) | |
rigctltcp_OBJ = $(call c_to_obj, $(rigctltcp_SRC)) | |
rigmatrix_OBJ = $(call c_to_obj, tests/rigmatrix.c) | |
rigmem_OBJ = $(call c_to_obj, $(rigmem_SRC)) | |
rotctl_OBJ = $(call c_to_obj, $(rotctl_SRC)) | |
rotctld_OBJ = $(call c_to_obj, $(rotctld_SRC)) | |
hamlib_i = $(call c_to_i, $(hamlib_C_SRC)) | |
hamlib_CC_i = $(call cc_to_i, $(hamlib_CC_SRC)) | |
hamlibpp_i = $(call cc_to_i, $(hamlibpp_SRC)) | |
$(hamlib_C_OBJ) \ | |
$(hamlib_CC_OBJ) \ | |
$(hamlib_CPP_OBJ) \ | |
$(hamlibpp_OBJ) \ | |
$(hamlib_i) \ | |
$(hamlib_CC_i) \ | |
$(hamlibpp_i): EXTRA_CFLAGS = -DIN_HAMLIB | |
$(hamlibpp_OBJ) \ | |
$(hamlibpp_i): EXTRA_CFLAGS += -DDLL_EXPORT | |
all_test_OBJ = $(addprefix $(OBJ_DIR)/, \ | |
dumpmem.obj \ | |
example.obj \ | |
hamlibmodels.obj \ | |
listrigs.obj \ | |
rig_bench.obj \ | |
rigfreqwalk.obj \ | |
rigsmtr.obj \ | |
rigswr.obj \ | |
rigtestmcast.obj \ | |
sctest.obj \ | |
simple.obj \ | |
testcache.obj \ | |
testcookie.obj \ | |
testcpp.obj \ | |
testbcd.obj \ | |
testfreq.obj \ | |
testloc.obj \ | |
testmW2power.obj \ | |
testrig.obj \ | |
testrigcaps.obj \ | |
testrigopen.obj \ | |
testsecurity.obj \ | |
testtrn.obj) | |
all_test_OBJ += $(ampctl_OBJ) \ | |
$(ampctld_OBJ) \ | |
$(rigctlcom_OBJ) \ | |
$(rigctl_OBJ) \ | |
$(rigctld_OBJ) \ | |
$(rigmatrix_OBJ) \ | |
$(rigctlsync_OBJ) \ | |
$(rigctltcp_OBJ) \ | |
$(rigmem_OBJ) \ | |
$(rotctl_OBJ) \ | |
$(rotctld_OBJ) \ | |
$(simulators_OBJ) | |
all_test_I = $(notdir $(all_test_OBJ:.obj=.i)) | |
# | |
# A strangely named macro ('-DUSE_Hamlib_DLL' would be better), but | |
# defining 'DLL_EXPORT' lets all .c and .cc programs use '$(Hamlib_DLL)'. | |
# | |
# It boils down to adding a '__declspec(dllimport)' for all code/data | |
# in '$(Hamlib_DLL)'. | |
# | |
$(all_test_OBJ) $(all_test_I): EXTRA_CFLAGS = -DDLL_EXPORT | |
.SECONDARY: $(all_test_OBJ) | |
# $(simulators_OBJ): EXTRA_CFLAGS += -DHAMLIB_need_ip_mreq_hack | |
GENERATED = include/hamlib/config.h \ | |
src/hamlibdatetime.h | |
GENERATED += $(addprefix $(OBJ_DIR)/, \ | |
unistd.h \ | |
termios.h \ | |
strings.h \ | |
sys/time.h \ | |
sys/ioctl.h) | |
all: $(GENERATED) bin install_colorama $(TARGETS) programs copy_DLLs epilogue | |
bin tmp $(OBJ_DIR) $(OBJ_DIR)/sys: | |
- $(MKDIR) $@ | |
# | |
# Install the Python 'colorama' package when running on AppVeyor: | |
# | |
install_colorama: | |
ifneq ($(APPVEYOR_PROJECT_NAME),) | |
$(call green_msg, Installing 'colorama' ...) | |
$(PYTHON) -m pip install colorama | |
endif | |
epilogue: | |
$(call green_msg, Welcome to $(BRIGHT_WHITE)$(Hamlib_DLL) + $(Hamlibpp_DLL) $(BRIGHT_GREEN)(CC=$(CC)$(comma) CPU=$(CPU)).) | |
$(call green_msg, You could also do a $(BRIGHT_WHITE)make -f $(THIS_FILE) [doxy_docs | rigmatrix_table]\n) | |
ifeq ($(USER),gv) | |
TEST_PROGS += py_module lua_module | |
endif | |
programs: $(GENERATED) $(TEST_PROGS) | |
$(hamlib_misc_OBJ): EXTRA_CFLAGS += -DIN_HAMLIB_MISC_LIB | |
$(misc_LIB): $(hamlib_misc_OBJ) | |
$(call create_static_lib, $@, $^) | |
$(Hamlib_STAT_LIB): $(hamlib_C_OBJ) $(hamlib_CC_OBJ) $(hamlib_CPP_OBJ) | |
$(call create_static_lib, $@, $^) | |
$(Hamlib_IMP_LIB): $(Hamlib_DLL) | |
$(Hamlibpp_IMP_LIB): $(Hamlibpp_DLL) | |
$(Hamlib_DLL): $(OBJ_DIR)/Hamlib.def $(Hamlib_STAT_LIB) $(misc_LIB) $(Hamlib_EX_LIBS) $(OBJ_DIR)/Hamlib.res | check-for-unused-libs.py | |
$(call link_DLL, $@, -def:$^ $(Hamlib_OS_LIBS), $(Hamlib_IMP_LIB)) | |
$(Hamlibpp_DLL): $(hamlibpp_OBJ) $(Hamlib_IMP_LIB) $(OBJ_DIR)/Hamlibpp.res | check-for-unused-libs.py | |
$(call link_DLL, $@, $^ $(Hamlibpp_EX_LIBS), $(Hamlibpp_IMP_LIB)) | |
# | |
# For MSVC only. | |
# | |
ifeq ($(CC)-$(USE_MP_COMPILE),cl-1) | |
SRC_chunk_1 = $(wordlist 1, 80, $(hamlib_C_SRC)) | |
SRC_chunk_2 = $(wordlist 81, 160, $(hamlib_C_SRC)) | |
SRC_chunk_3 = $(wordlist 161, 240, $(hamlib_C_SRC)) | |
SRC_chunk_4 = $(wordlist 241, 320, $(hamlib_C_SRC)) | |
SRC_chunk_5 = $(wordlist 321, 400, $(hamlib_C_SRC)) | |
OBJ_chunk_1 = $(call c_to_obj, $(SRC_chunk_1)) | |
OBJ_chunk_2 = $(call c_to_obj, $(SRC_chunk_2)) | |
OBJ_chunk_3 = $(call c_to_obj, $(SRC_chunk_3)) | |
OBJ_chunk_4 = $(call c_to_obj, $(SRC_chunk_4)) | |
OBJ_chunk_5 = $(call c_to_obj, $(SRC_chunk_5)) | |
$(OBJ_chunk_1): $(SRC_chunk_1) | $(CC).args | |
$(call C_compile_MP, -DIN_HAMLIB $(SRC_chunk_1)) | |
$(OBJ_chunk_2): $(SRC_chunk_2) | $(CC).args | |
$(call C_compile_MP, -DIN_HAMLIB $(SRC_chunk_2)) | |
$(OBJ_chunk_3): $(SRC_chunk_3) | $(CC).args | |
$(call C_compile_MP, -DIN_HAMLIB $(SRC_chunk_3)) | |
$(OBJ_chunk_4): $(SRC_chunk_4) | $(CC).args | |
$(call C_compile_MP, -DIN_HAMLIB $(SRC_chunk_4)) | |
$(OBJ_chunk_5): $(SRC_chunk_5) | $(CC).args | |
$(call C_compile_MP, -DIN_HAMLIB $(SRC_chunk_5)) | |
endif | |
# | |
# Put the '-Dxx' arguments from the 'CFLAGS' and sort them first in result. | |
# | |
filter_D_args_first = $(sort $(filter -D%, $(1))) $(filter-out -D%, $(1)) | |
$(CC).args: $(THIS_FILE) | |
$(call green_msg, Creating $@) | |
$(call create_resp_file, $@, -c $(call filter_D_args_first, $(CFLAGS))) | |
# | |
# C++ test programs: | |
# | |
bin/hamlibTest.exe: $(OBJ_DIR)/hamlibTest.obj $(OBJ_DIR)/hamlibTest.res $(CPP_PROG_LIBS) | |
$(call link_EXE, $@, $^ user32.lib) | |
bin/testcpp.exe: $(OBJ_DIR)/testcpp.obj $(CPP_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
bin/throw-test.exe: $(OBJ_DIR)/throw-test.obj $(CPP_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
# | |
# Plain C test programs: | |
# | |
$(OBJ_DIR)/%.obj: tests/%.c | $(CC).args $(OBJ_DIR) | |
$(call C_compile, $@, $<) | |
bin/ampctl.exe: $(ampctl_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ advapi32.lib user32.lib) | |
bin/ampctld.exe: $(ampctld_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ $(WS2_32_LIB)) | |
bin/rigctlcom.exe: $(rigctlcom_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
bin/rigctl.exe: $(rigctl_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
bin/rigctld.exe: $(rigctld_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ $(WS2_32_LIB)) | |
bin/rigctlsync.exe: $(rigctlsync_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
bin/rigctltcp.exe: $(rigctltcp_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ $(WS2_32_LIB)) | |
bin/rigtestmcastrx.exe: $(OBJ_DIR)/rigtestmcastrx.obj $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ $(WS2_32_LIB)) | |
bin/rigmem.exe: $(rigmem_OBJ) $(C_PROG_LIBS) $(XML2_LIB) | |
$(call link_EXE, $@, $^) | |
bin/rotctl.exe: $(rotctl_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
bin/rotctld.exe: $(rotctld_OBJ) $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^ $(WS2_32_LIB)) | |
bin/rigmatrix.exe: $(rigmatrix_OBJ) $(C_PROG_LIBS) $(LIBGD_LIB) copy_DLLs | |
$(call link_EXE, $@, $(rigmatrix_OBJ) $(C_PROG_LIBS) $(LIBGD_LIB)) | |
copy_DLLs: | bin | |
$(call green_msg, Copying foreign .DLLs to './bin') | |
$(call copy_files, $(COPY_DLLs), bin/) | |
# | |
# For all other simple plain C test-programs. | |
# Not all may need '$(misc_LIB)'. | |
# | |
bin/%.exe: $(OBJ_DIR)/%.obj $(C_PROG_LIBS) | |
$(call link_EXE, $@, $^) | |
# | |
# For '$(hamlib_C_SRC)' and '$(hamlib_CC_SRC)': | |
# | |
$(OBJ_DIR)/%.obj: %.c | $(CC).args $(OBJ_DIR) | |
$(call C_compile, $@, $<) | |
$(OBJ_DIR)/%.obj: %.cc | $(CC).args $(OBJ_DIR) | |
$(call CXX_compile, $@, $<) | |
$(OBJ_DIR)/%.obj: %.cpp | $(CC).args $(OBJ_DIR) | |
$(call CXX_compile, $@, $<) | |
# | |
# For '$(hamlib_misc_SRC)' since 'lib' is not in 'vpath' due to 'lib/dummy.c'. | |
# | |
$(OBJ_DIR)/%.obj: lib/%.c | $(CC).args $(OBJ_DIR) | |
$(call C_compile, $@, $<) | |
clean: clean_docs clean_rigmatrix | |
rm -fr $(OBJ_DIR) | |
rm -f bin/*.{map,pdb,lib,exp} $(GENERATED) \ | |
vc1*.pdb cl.args clang-cl.args \ | |
lib.args link.args link.tmp depend_c.args \ | |
depend_cc.args cpp-filter.py check-for-unused-libs.py | |
vclean realclean: clean | |
rm -fr bin | |
rm -f $(Hamlib_STAT_LIB) \ | |
$(Hamlib_IMP_LIB) \ | |
$(Hamlibpp_IMP_LIB) \ | |
$(misc_LIB) \ | |
lib/HamlibLua.lib \ | |
.depend.Windows | |
include/hamlib/config.h: $(THIS_FILE) | |
$(call generate_c, $@) | |
$(file >> $@,#ifndef HAMLIB_CONFIG_H) | |
$(file >> $@,#define HAMLIB_CONFIG_H) | |
$(file >> $@,$(hamlib_config_h)) | |
$(file >> $@,#endif /* HAMLIB_CONFIG_H */) | |
src/hamlibdatetime.h: $(THIS_FILE) | |
$(call generate_c, $@) | |
$(file >> $@, #define HAMLIBDATETIME "__DATE__") | |
$(OBJ_DIR)/unistd.h: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_fake, $@, #include "lib/getopt.h") | |
$(OBJ_DIR)/sys/time.h: $(THIS_FILE) | $(OBJ_DIR)/sys | |
$(call generate_fake, $@, #include <time.h>) | |
$(OBJ_DIR)/strings.h: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_fake, $@, #include <string.h>) | |
$(OBJ_DIR)/termios.h: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_fake, $@) | |
$(OBJ_DIR)/sys/ioctl.h: $(THIS_FILE) | $(OBJ_DIR)/sys | |
$(call generate_fake, $@) | |
%.i: %.c FORCE $(GENERATED) cpp-filter.py $(CC).args | |
$(call cxx_preprocess, $@, $<) | |
%.i: lib/%.c FORCE $(GENERATED) cpp-filter.py $(CC).args | |
$(call cxx_preprocess, $@, $<) | |
%.i: $(OBJ_DIR)/%.c FORCE $(GENERATED) cpp-filter.py $(CC).args | |
$(call cxx_preprocess, $@, $<) | |
%.i: %.cc FORCE $(GENERATED) cpp-filter.py $(CC).args | |
$(call cxx_preprocess, $@, $<) | |
%.i: %.cpp FORCE $(GENERATED) cpp-filter.py $(CC).args | |
$(call cxx_preprocess, $@, $<) | |
FORCE: | |
cpp-filter.py: $(THIS_FILE) | |
$(call generate_py, $@) | |
$(file >> $@,$(cpp_filter_PY)) | |
check-for-unused-libs.py: $(THIS_FILE) | |
$(call generate_py, $@) | |
$(file >> $@,$(check_for_unused_libs_PY)) | |
# | |
# Create API documentation in 'doc/html/index.html': | |
# | |
doxy_docs: doc/hamlib.cfg | |
cd doc ; \ | |
doxygen hamlib.cfg 2> doxygen.log ; \ | |
cd html ; \ | |
hhc index.hhp ; \ | |
mv -f Hamlib.chm .. | |
@echo 'Doxygen done. Look in "doc/doxygen.log" for messages.' | |
doc/hamlib.cfg: $(THIS_FILE) | |
$(call generate, $@, #) | |
$(file >> $@,$(hamlib_CFG)) | |
clean_docs: | |
rm -f doc/doxygen.log doc/hamlib.cfg doc/Hamlib.chm doc/Hamlib.chw | |
rm -fr doc/html | |
# | |
# Python 2/3 module stuff. | |
# | |
# Get the Python prefix via the 'py -x' launcher. | |
# The Python major version (2 or 3) is simply '$(USE_PY_BINDING)'. | |
# | |
PY_ROOT = $(subst \,/,$(shell py -$(USE_PY_BINDING) -c "import sys; print(sys.prefix)")) | |
ifneq ($(USE_PY_BINDING),0) | |
PY_WRAPPER_C = $(OBJ_DIR)/HamlibPy$(USE_PY_BINDING)_wrap.c | |
PY_WRAPPER_O = $(OBJ_DIR)/HamlibPy$(USE_PY_BINDING)_wrap.obj | |
ifeq ($(USE_PY_BINDING),2) | |
PY_INIT_FUNC = init_Hamlib | |
else | |
PY_INIT_FUNC = PyInit__Hamlib | |
endif | |
endif | |
Hamlib_PYD_deps = $(PY_WRAPPER_O) \ | |
$(OBJ_DIR)/HamlibPy.res \ | |
$(Hamlib_IMP_LIB) | |
PY_CFLAGS = -I$(PY_ROOT)/include -DNO_SSIZE_T -DDLL_EXPORT -DIN_HAMLIB_PYTHON | |
ifeq ($(CC),cl) | |
PY_CFLAGS += -wd4197 | |
endif | |
ifeq ($(USE_PY_BINDING),0) | |
py_module: | |
$(error Use 'USE_PY_BINDING=[2|3]'.) | |
else | |
py_module: $(Hamlib_PYD) $(OBJ_DIR)/Hamlib.py $(Hamlib_DLL) | |
$(COPY) $^ $(Hamlib_PYD:.pyd=.pdb) $(PY_ROOT)/Lib/site-packages | |
endif | |
$(OBJ_DIR)/Hamlib.py: $(PY_WRAPPER_C) | |
SWIG_FLAGS = -I./include -I./bindings -D_WIN32 | |
# | |
# Wrapper depndencies: | |
# | |
WRAP_DEPS = bindings/Hamlib.swg \ | |
bindings/ignore.swg \ | |
bindings/rig.swg \ | |
bindings/rotator.swg \ | |
bindings/amplifier.swg \ | |
include/hamlib/rig.h | |
$(PY_WRAPPER_C): $(WRAP_DEPS) | |
$(call green_msg, Generating $@ and $(OBJ_DIR)/Hamlib.py) | |
swig -python $(SWIG_FLAGS) -o $@ bindings/Hamlib.swg | |
$(PY_WRAPPER_O) $(PY_WRAPPER_C:.c=.i): EXTRA_CFLAGS += $(PY_CFLAGS) | |
ifneq ($(USE_PY_BINDING),0) | |
$(Hamlib_PYD): $(Hamlib_PYD_deps) | check-for-unused-libs.py | |
$(call link_PYD, $@, $^, $(PY_INIT_FUNC)) | |
endif | |
# | |
# Lua module stuff. Only LuaJIT seems to be stable. | |
# | |
# The '$(Hamlib_LUA_DLL)' exports only 'luaopen_Hamliblua()' | |
# | |
lua_module: $(Hamlib_LUA_DLL) lua_epilogue | |
lua_epilogue: | |
$(call green_msg, \ | |
Remember to update your $(BRIGHT_WHITE)LUA_CPATH $(BRIGHT_GREEN) \ | |
for $(BRIGHT_WHITE)$(Hamlib_LUA_DLL). \ | |
\n$(BRIGHT_GREEN)And your $(BRIGHT_WHITE)PATH $(BRIGHT_GREEN)for the needed $(BRIGHT_WHITE)$(Hamlib_DLL).\n) | |
# $(COPY) $(Hamlib_LUA_DLL) $(some_where_on_PATH_and_LUA_CPATH) | |
$(OBJ_DIR)/HamlibLua_wrap.c: $(WRAP_DEPS) | $(OBJ_DIR) | |
$(call green_msg, Generating $@) | |
swig -lua $(SWIG_FLAGS) -o $@ bindings/Hamlib.swg | |
# | |
# Extra CFLAGS for compiling the Lua wrapper: | |
# | |
LUA_CFLAGS = -I$(LUA_ROOT)/src -DDLL_EXPORT -DIN_HAMLIB_LUA | |
# | |
# While compiling '$(OBJ_DIR)/HamlibLua_wrap.c', there are a bunching of these warnings: | |
# MSVC_obj/HamlibLua_wrap.c(3380): warning C4293: '<<': shift count negative or too big, undefined behavior | |
# MSVC_obj/HamlibLua_wrap.c(31981): warning C4197: 'volatile unsigned int': top-level volatile in cast is ignored | |
# | |
# Turn them off. | |
# | |
ifeq ($(CC),cl) | |
LUA_CFLAGS += -wd4197 -wd4293 | |
endif | |
$(OBJ_DIR)/HamlibLua_wrap.obj HamlibLua_wrap.i: EXTRA_CFLAGS = $(LUA_CFLAGS) | |
# | |
# The imp-lib 'lib/HamlibLua.lib' is not needed for anything. | |
# | |
$(Hamlib_LUA_DLL): $(OBJ_DIR)/HamlibLua_wrap.obj $(Hamlib_IMP_LIB) $(OBJ_DIR)/HamlibLua.res | check-for-unused-libs.py | |
$(call link_DLL, $@, $^ $(LUA_LIB), lib/HamlibLua.lib) | |
rigmatrix_table: tmp/rigmatrix.html | |
ifeq ($(USE_LIBGD),1) | |
tmp/rigmatrix.html: bin/rigmatrix.exe | tmp | |
$(call green_msg, Generating $@) | |
@cat tests/rigmatrix_head.html > $@ | |
export WSOCK_TRACE_LEVEL=0 ; \ | |
cd tmp ; ../$< >> rigmatrix.html | |
@echo | |
else | |
tmp/rigmatrix.html: | |
$(call red_msg, The target '$@' needs 'USE_LIBGD=1') | |
endif | |
clean_rigmatrix: | |
rm -fr tmp | |
$(OBJ_DIR)/Hamlib.rc: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_dll_rc, $@, $(Hamlib_DLL), "Ham Radio Control Library for C") | |
$(OBJ_DIR)/Hamlibpp.rc: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_dll_rc, $@, $(Hamlibpp_DLL), "Ham Radio Control Library for C++") | |
$(OBJ_DIR)/HamlibPy.rc: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_dll_rc, $@, $(Hamlib_PYD), "Hamlib module for Python v$(USE_PY_BINDING).x") | |
$(OBJ_DIR)/HamlibLua.rc: $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate_dll_rc, $@, $(Hamlib_LUA_DLL), "Hamlib module for LuaJIT") | |
$(OBJ_DIR)/%.res: %.rc include/hamlib/config.h | $(OBJ_DIR) | |
$(call create_res_file, $@, $<) | |
# | |
# Create an export definition file by using 'nm $(Hamlib_STAT_LIB)' to | |
# extract all the public functions; | |
# i.e. ' T ' symbols are "Text symbol, global". See 'man nm' for details. | |
# | |
# On 'CPU=x86', all symbols have a leading '_'. Drop these. | |
# | |
# Ignore symbols matching ' Wspiapi.*' and ' _.*'. | |
# | |
# Append the DATA symbols manually. | |
# | |
ifeq ($(CPU),x86) | |
uscore := _ | |
else | |
uscore := | |
endif | |
# | |
# Export 'rig_', 'rot_' and 'amp_' and the '$(Hamlib_extra_symbols)'. | |
# | |
main_symbols = -e ' T $(uscore)rig_*' -e ' T $(uscore)rot_*' -e ' T $(uscore)amp_*' | |
# | |
# And remove 'Wspiapi.*' symbols. | |
# | |
extract_code_symbols = nm $(2) | grep $(main_symbols) | \ | |
sed -e 's@^.* $(uscore)@ @g' \ | |
-e 's@ Wspiapi.*@@g' \ | |
-e 's@ _.*@@g' | sort | uniq >> $(1) | |
# | |
# We export stuff using this generated .def-file: | |
# | |
$(OBJ_DIR)/Hamlib.def: $(Hamlib_STAT_LIB) $(THIS_FILE) | $(OBJ_DIR) | |
$(call generate, $@, ;) | |
$(file >> $@, LIBRARY $(Hamlib_DLL)) | |
$(file >> $@, EXPORTS) | |
$(file >> $@,$(Hamlib_extra_symbols)) | |
$(file >> $@,$(Hamlib_extras_pthreads)) | |
$(file >> $@,$(Hamlib_DATA_symbols)) | |
$(call extract_code_symbols, $@, $<) | |
# | |
# GNU-make macros. | |
# | |
# This assumes you have a Cygwin/Msys 'echo' with colour support. | |
# | |
BRIGHT_RED = \e[1;31m | |
BRIGHT_GREEN = \e[1;32m | |
BRIGHT_WHITE = \e[1;37m | |
red_msg = @echo -e "$(BRIGHT_RED)$(strip $(1))\e[0m" | |
green_msg = @echo -e "$(BRIGHT_GREEN)$(strip $(1))\e[0m" | |
white_msg = @echo -e "$(BRIGHT_WHITE)$(strip $(1))\e[0m" | |
define C_compile | |
$(strip $(CC) @$(CC).args $(EXTRA_CFLAGS) -Fo./$(strip $(1)) $(2)) | |
@echo | |
endef | |
define C_compile_MP | |
$(call green_msg, Compiling $(words $(filter %.c, $(1))) files in one go...) | |
$(CC) -MP @$(CC).args -Fo./$(OBJ_DIR)\\ $(1) | |
@echo | |
endef | |
CXX_compile = $(call C_compile, $(1), $(CXXFLAGS) $(2)) | |
define link_EXE | |
$(call green_msg, Linking $(1)) | |
$(call create_resp_file, link.args, $(LDFLAGS) $(2)) | |
link -out:$(strip $(1)) @link.args > link.tmp | |
@cat link.tmp >> $(1:.exe=.map) | |
@rm -f $(1:.exe=.exp) | |
@$(PYTHON) check-for-unused-libs.py link.tmp $(notdir $(PTHREAD_LIB) $(misc_lib)) | |
endef | |
define link_DLL | |
$(call green_msg, Linking $(1)) | |
$(call create_resp_file, link.args, -dll $(LDFLAGS) -implib:$(strip $(3)) $(2)) | |
link -out:$(strip $(1)) @link.args > link.tmp | |
@cat link.tmp >> $(1:.dll=.map) | |
@rm -f $(3:.lib=.exp) | |
@$(PYTHON) check-for-unused-libs.py link.tmp | |
endef | |
# | |
# Create a Python .PYD-module from objects. | |
# arg1, $(1): The .pyd file. | |
# arg2, $(2): The .obj file(s), extra args and libs. | |
# arg3, $(3): The name of the Python init function. | |
# | |
define link_PYD | |
$(call green_msg, Linking $(1)) | |
$(call create_resp_file, link.args, -dll $(LDFLAGS) -libpath:$(PY_ROOT)/libs -export:$(strip $(3)) $(2)) | |
link -out:$(strip $(1)) @link.args > link.tmp | |
@cat link.tmp >> $(1:.pyd=.map) | |
@rm -f $(1:.pyd=.exp) $(1:.pyd=.lib) | |
@$(PYTHON) check-for-unused-libs.py link.tmp | |
endef | |
define create_resp_file | |
$(file > $(1)) | |
$(foreach f, $(2), $(file >> $(1),$(strip $(f))) ) | |
endef | |
define create_res_file | |
$(call green_msg, Creating $(2)) | |
rc $(RCFLAGS) -Fo./$(strip $(1) $(2)) | |
@echo | |
endef | |
define create_static_lib | |
@rm -f $(1) | |
$(call green_msg, Creating $(1)) | |
$(call create_resp_file, lib.args, $(2)) | |
lib -nologo -out:$(strip $(1)) -machine:$(CPU) @lib.args | |
@echo | |
endef | |
define Warning | |
$(1) | |
$(1) DO NOT EDIT! This file was automatically generated | |
$(1) from $(realpath $(THIS_FILE)) at $(DATE). | |
$(1) Edit that file instead. | |
$(1) | |
endef | |
define generate | |
$(call green_msg, Generating $(1)) | |
$(file > $(1),$(call Warning,$(strip $(2)))) | |
endef | |
define generate_c | |
$(call generate,$(1),//) | |
endef | |
define generate_fake | |
$(call generate_c, $(1)) | |
$(file >> $(1), // fake <$(notdir $(1))> for MSVC/clang-cl) | |
$(file >> $(1), $(2)) | |
endef | |
define generate_py | |
$(call green_msg, Generating $(1)) | |
$(file > $(1),#!/usr/bin/env python) | |
$(file >> $(1),#) | |
$(file >> $(1),# DO NOT EDIT! This file was generated automatically) | |
$(file >> $(1),# from $(realpath $(THIS_FILE)). Edit that file instead.) | |
$(file >> $(1),#) | |
$(file >> $(1),from __future__ import print_function) | |
$(file >> $(1),if 1:) | |
endef | |
define generate_dll_rc | |
$(call generate_c, $(1)) | |
$(file >> $@, #define RC_FILENAME "$(notdir $(2))") | |
$(file >> $@, #define RC_DESCRIPTION $(3)) | |
$(file >> $@, $(RC_COMMON)) | |
endef | |
# | |
# $(empty) is not a space. It marks a boundary for something else. | |
# So '$(empty) $(empty)' becomes a single space. | |
# | |
empty := | |
# | |
# space: | |
# | |
space := $(empty) $(empty) | |
# | |
# copy file(s) macro: | |
# $(1): files. A $(sort $(1)) will make a unique list. | |
# $(2): directory | |
# | |
define copy_files | |
@$(foreach f, $(1), echo '$(space) $(f)' ; ) | |
@$(COPY) $(1) $(2) | |
@echo | |
endef | |
ifeq ($(USE_ASTYLE),1) | |
pp_filter = | astyle | |
pp_comment = The preprocessed and AStyle formatted output of '$(strip $(1)) | |
else | |
pp_filter = | |
pp_comment = The raw preprocessed output of '$(strip $(1))' | |
endif | |
define cxx_preprocess | |
$(file > $(1),/* $(call pp_comment, $(2)):) | |
$(file >> $(1), * $(CC) -E) | |
@$(foreach f, $(CFLAGS), $(file >> $(1), * $(f))) | |
$(file >> $(1), * And these 'EXTRA_CFLAGS':) | |
@$(foreach f, $(EXTRA_CFLAGS), $(file >> $(1), * $(f))) | |
$(file >> $(1), *---------------------------------------------------------) | |
$(file >> $(1), */) | |
$(CC) -E @$(CC).args $(EXTRA_CFLAGS) $(2) | $(PYTHON) cpp-filter.py $(pp_filter) >> $(1) | |
endef | |
# | |
# This large blob creates 'include/hamlib/config.h': | |
# | |
define hamlib_config_h | |
/* | |
* Warning control. | |
* While building with 'clang-cl' and 'USE_MAX_WARNINGS=1' there are lots of warnings! | |
*/ | |
#if defined(__clang__) | |
#if defined(USE_MAX_WARNINGS) && (USE_MAX_WARNINGS == 0) | |
#pragma clang diagnostic ignored "-Wundef" | |
#pragma clang diagnostic ignored "-Wunused-function" | |
#pragma clang diagnostic ignored "-Wunused-macros" | |
#pragma clang diagnostic ignored "-Wunused-parameter" | |
#pragma clang diagnostic ignored "-Wunused-variable" | |
#pragma clang diagnostic ignored "-Wunused-but-set-variable" | |
#pragma clang diagnostic ignored "-Wcomma" | |
#pragma clang diagnostic ignored "-Wparentheses" | |
#pragma clang diagnostic ignored "-Winitializer-overrides" | |
#pragma clang diagnostic ignored "-Wvisibility" | |
#pragma clang diagnostic ignored "-Wunknown-pragmas" | |
#pragma clang diagnostic ignored "-Wextra-semi-stmt" | |
#pragma clang diagnostic ignored "-Wdeclaration-after-statement" | |
#pragma clang diagnostic ignored "-Wimplicit-function-declaration" | |
#pragma clang diagnostic ignored "-Wconditional-uninitialized" | |
#pragma clang diagnostic ignored "-Wunsafe-buffer-usage" | |
#pragma clang diagnostic ignored "-Wignored-attributes" | |
#pragma clang diagnostic ignored "-Wstrict-prototypes" | |
#pragma clang diagnostic ignored "-Wreserved-id-macro" | |
#pragma clang diagnostic ignored "-Wused-but-marked-unused" | |
#pragma clang diagnostic ignored "-Wshadow" | |
#pragma clang diagnostic ignored "-Wcast-align" | |
#pragma clang diagnostic ignored "-Wcast-qual" | |
#pragma clang diagnostic ignored "-Wshorten-64-to-32" | |
#pragma clang diagnostic ignored "-Wpedantic" | |
#pragma clang diagnostic ignored "-Wformat-pedantic" | |
#pragma clang diagnostic ignored "-Wformat-nonliteral" | |
#pragma clang diagnostic ignored "-Wswitch-enum" | |
#pragma clang diagnostic ignored "-Wcovered-switch-default" | |
#pragma clang diagnostic ignored "-Wsign-conversion" | |
#pragma clang diagnostic ignored "-Wreserved-user-defined-literal" | |
#pragma clang diagnostic ignored "-Wsign-compare" | |
#pragma clang diagnostic ignored "-Wdouble-promotion" | |
#pragma clang diagnostic ignored "-Wassign-enum" | |
#pragma clang diagnostic ignored "-Wunreachable-code" | |
#pragma clang diagnostic ignored "-Wnonportable-include-path" | |
#pragma clang diagnostic ignored "-Wunreachable-code-return" | |
#pragma clang diagnostic ignored "-Wunreachable-code-break" | |
#pragma clang diagnostic ignored "-Wc++98-compat-pedantic" | |
#pragma clang diagnostic ignored "-Wold-style-cast" | |
#pragma clang diagnostic ignored "-Wreserved-identifier" | |
#pragma clang diagnostic ignored "-Wcast-function-type" | |
#pragma clang diagnostic ignored "-Wmissing-field-initializers" | |
#pragma clang diagnostic ignored "-Wmissing-noreturn" | |
#pragma clang diagnostic ignored "-Wmissing-prototypes" | |
#pragma clang diagnostic ignored "-Wmissing-variable-declarations" | |
#pragma clang diagnostic ignored "-Wbad-function-cast" | |
#pragma clang diagnostic ignored "-Wredundant-parens" | |
#pragma clang diagnostic ignored "-Wtautological-unsigned-zero-compare" | |
#pragma clang diagnostic ignored "-Wnonportable-system-include-path" | |
#pragma clang diagnostic ignored "-Wimplicit-int-conversion" | |
#pragma clang diagnostic ignored "-Wfloat-conversion" | |
#pragma clang diagnostic ignored "-Wfloat-equal" | |
#pragma clang diagnostic ignored "-Wimplicit-float-conversion" | |
#pragma clang diagnostic ignored "-Wimplicit-fallthrough" | |
#pragma clang diagnostic ignored "-Wshift-count-overflow" | |
#pragma clang diagnostic ignored "-Wdocumentation" | |
#pragma clang diagnostic ignored "-Wdocumentation-unknown-command" | |
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" | |
#pragma clang diagnostic ignored "-Wzero-as-null-pointer-constant" | |
#pragma clang diagnostic ignored "-Wdeprecated" | |
#pragma clang diagnostic ignored "-Wsuggest-override" | |
#pragma clang diagnostic ignored "-Wsuggest-destructor-override" | |
/* | |
* Since on AppVeyor etc. they could have an old 'clang-cl'. | |
*/ | |
#pragma clang diagnostic ignored "-Wunknown-warning-option" | |
/* | |
* This warning is rather important: | |
* | |
* rigs/dummy/dummy.h(46,5): warning: 'netrigctl_get_vfo_mode' redeclared without 'dllimport' attribute: previous | |
* 'dllimport' ignored [-Winconsistent-dllimport] | |
* int netrigctl_get_vfo_mode(RIG *); | |
* ^ | |
* Hence do not add *#pragma clang diagnostic ignored "-Winconsistent-dllimport"'. | |
* | |
* And things like this that break MSVC: | |
* rigs/kenwood/kenwood.c(2850,19): warning: variable length array used [-Wvla] | |
* 2850 | char levelbuf[expected_length + 1]; | |
* | ^~~~~~~~~~~~~~~~~~~ | |
*/ | |
/* | |
* And even more warnings in C++ | |
*/ | |
#if defined(__cplusplus) | |
#pragma clang diagnostic ignored "-Wc++98-compat" | |
#pragma clang diagnostic ignored "-Wreserved-identifier" | |
#pragma clang diagnostic ignored "-Wreserved-macro-identifier" | |
#endif | |
#endif /* USE_MAX_WARNINGS */ | |
#elif defined(_MSC_VER) | |
#pragma warning (disable: 4018 4090 4101 4142 4146 4244 4251 4267 4275 4305 4700 4800) | |
#endif | |
#define ABI_VERSION $(ABI_VER) | |
#if defined(IN_HAMLIB) | |
#if defined(DLL_EXPORT) && !defined(__cplusplus) | |
#error "Do not use '-DDLL_EXPORT' since we use a .def-file to control the exports." | |
#endif | |
#else | |
/* | |
* Since there may be an incompatible '$$(VCPKG_ROOT)/installed/$(CPU)-windows/include/getopt.h' | |
* breaking 'lib/getopt.h'. | |
*/ | |
#define __GETOPT_H_ | |
#include "lib/getopt.h" | |
#endif | |
/* | |
* Since most files here needs 'src/misc.h'. | |
*/ | |
#define BUILDING_HAMLIB | |
#define WIN32 1 | |
#define __WIN32__ 1 | |
#if !defined(_WIN32_WINNT) || (_WIN32_WINNT < 0x0602) | |
#undef _WIN32_WINNT | |
#define _WIN32_WINNT 0x0602 /* Windows-8+ API */ | |
#endif | |
#ifndef WIN32_LEAN_AND_MEAN | |
#define WIN32_LEAN_AND_MEAN | |
#endif | |
#ifdef __cplusplus | |
#define HAMLIB_C_EXTERN extern "C" | |
#else | |
#define HAMLIB_C_EXTERN extern | |
#endif | |
#define _CRT_SECURE_NO_WARNINGS | |
#define _CRT_NONSTDC_NO_WARNINGS | |
#define _WINSOCK_DEPRECATED_NO_WARNINGS | |
struct timeval; /* Forward */ | |
struct timezone; /* Forward */ | |
HAMLIB_C_EXTERN int gettimeofday (struct timeval *, struct timezone *); | |
#include <windows.h> | |
#include <winsock2.h> /* 'struct timeval' etc. */ | |
#include <ws2tcpip.h> /* 'gai_strerror()' etc. */ | |
#include <time.h> /* 'struct timespec' etc. */ | |
#include <io.h> /* 'open()', 'close()' etc. */ | |
#include <stdint.h> /* 'int64_t' etc. */ | |
#include <stdlib.h> /* 'atoi()' etc. */ | |
#include <process.h> /* 'getpid()' etc. */ | |
#include <malloc.h> /* 'alloca()' etc. */ | |
#include <direct.h> /* 'getcwd()' */ | |
#include <assert.h> /* 'assert()' */ | |
#include <inttypes.h> /* 'PRId64' etc. */ | |
#if defined(HAMLIB_need_ip_mreq_hack) | |
/* | |
* Because of this POSIX crap in many 'simulators/ .c-files: | |
* | |
* struct ip_mreq | |
* { | |
* int dummy; | |
* }; | |
* | |
* causes this compile error: | |
* simulators/simelecraft.c(6): error C2011: 'ip_mreq': 'struct' type redefinition | |
* <WinKit>\Include\10.0.22621.0\shared\ws2ipdef.h(741): note: see declaration of 'ip_mreq' | |
*/ | |
#undef ip_mreq | |
#define ip_mreq Hamlib_fake_Posix_junk_ip_mreq | |
#endif | |
#define HAVE_SYS_TYPES_H 1 | |
#define HAVE_INTTYPES_H 1 | |
#define HAVE_WINRADIO 1 | |
#define HAVE_WINDOWS_H 1 | |
#define HAVE_WINBASE_H 1 | |
#define HAVE_WS2TCPIP_H 1 | |
#define HAVE_WSPIAPI_H 1 | |
#define HAVE_GETADDRINFO 1 | |
#define HAVE_DECL_GAI_STRERROR 1 | |
#define HAVE_PTHREAD 1 | |
#define HAVE_SELECT 1 | |
#define HAVE_SSLEEP 1 | |
#define HAVE_SLEEP 1 | |
#if defined(_MSC_VER) && !defined(__clang__) | |
#define __attribute__(x) | |
#endif | |
#define PRIll PRId64 | |
#define F_OK 0 /* Check for file existance */ | |
#define X_OK 1 /* Check for execute permission. */ | |
#define W_OK 2 /* Check for write permission */ | |
#define strcasecmp(s1, s2) _stricmp (s1, s2) | |
#define strncasecmp(s1, s2, n) _strnicmp (s1, s2, n) | |
#define sleep(s) Sleep (1000*(s)) | |
HAMLIB_C_EXTERN int usleep (unsigned long usec); | |
/** | |
* Since 'WIN32_LEAN_AND_MEAN' is defined, this header is | |
* not included in <windows.h>. So do it explicitly, but it is | |
* only needed in 'rigs/winradio/g313-win.c'. | |
*/ | |
#include <mmsystem.h> | |
#ifndef _TIMEVAL_DEFINED | |
#define _TIMEVAL_DEFINED | |
#endif | |
#ifndef _TIMESPEC_DEFINED | |
#define _TIMESPEC_DEFINED | |
#endif | |
#ifndef _USE_MATH_DEFINES | |
#define _USE_MATH_DEFINES /* 'M_PI' etc. */ | |
#endif | |
#if !defined(_SSIZE_T_DEFINED) && !defined(NO_SSIZE_T) | |
#include <basetsd.h> | |
typedef SSIZE_T ssize_t; | |
#define _SSIZE_T_DEFINED | |
#endif | |
#if !defined(_UINT_DEFINED) | |
typedef unsigned int uint; | |
#define _UINT_DEFINED | |
#endif | |
#if !defined(_MODE_T_DEFINED) | |
typedef unsigned short mode_t; | |
#define _MODE_T_DEFINED | |
#endif | |
#if !defined(timersub) | |
#define timersub(a, b, result) do { \ | |
(result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ | |
(result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ | |
if ((result)->tv_usec < 0) { \ | |
--(result)->tv_sec; \ | |
(result)->tv_usec += 1000000; \ | |
} \ | |
} while (0) | |
#endif | |
/** | |
* Hack for using libusrp dynamically (untested) | |
*/ | |
#ifdef HAVE_USRP | |
#define LIBUSRP_SPEC __declspec(dllimport) | |
#endif | |
#define PACKAGE_NAME "Hamlib" | |
#define PACKAGE_VERSION "$(VERSION)" | |
/** | |
* Functions in 'lib/win-misc.c': | |
*/ | |
#ifndef CLOCK_REALTIME | |
#define CLOCK_REALTIME 0 | |
#endif | |
HAMLIB_C_EXTERN int nanosleep (const struct timespec *ts, struct timespec *remain); | |
HAMLIB_C_EXTERN int clock_gettime (int clock_id, struct timespec *ts); | |
HAMLIB_C_EXTERN char *strtok_r (char *s, const char *delim, char **ptrptr); | |
endef | |
# | |
# The contents of 'doc/hamlib.cfg' used by Doxygen. | |
# | |
define hamlib_CFG | |
# | |
# All paths are relative to './doc'. | |
# | |
PROJECT_NAME = "Hamlib" | |
PROJECT_NUMBER = $(VERSION) | |
PROJECT_LOGO = hamlib.png | |
OUTPUT_DIRECTORY = . | |
PREDEFINED = __GNUC__ DOXYGEN DOC_HIDDEN | |
OUTPUT_LANGUAGE = English | |
GENERATE_HTML = YES | |
GENERATE_LATEX = NO | |
GENERATE_RTF = NO | |
GENERATE_MAN = NO | |
MAN_EXTENSION = .3 | |
TAB_SIZE = 4 | |
CASE_SENSE_NAMES = NO | |
FULL_PATH_NAMES = NO | |
STRIP_FROM_PATH = $(realpath .) | |
ALIASES = \RETURNFUNC{1}="\retval RETURNFUNC(\1)" | |
INPUT = index.doxygen ../src/ ../security/ ../lib/ ../include/hamlib/ | |
INCLUDE_PATH = ../include/ | |
EXAMPLE_PATH = .. \ | |
../tests/testrig.c \ | |
../scripts/README.build-Windows \ | |
../scripts/build-w32.sh \ | |
../scripts/build-w64.sh \ | |
../scripts | |
EXCLUDE = ../src/amp_conf.h \ | |
../include/hamlib/ampclass.h \ | |
../include/hamlib/rotclass.h | |
QUIET = YES | |
HTML_EXTRA_STYLESHEET = hamlib.css | |
HTML_FOOTER = footer.html | |
EXTRACT_ALL = NO | |
EXTRACT_STATIC = NO | |
HIDE_UNDOC_MEMBERS = NO | |
SHOW_INCLUDE_FILES = YES | |
INHERIT_DOCS = YES | |
ENABLED_SECTIONS = "" | |
JAVADOC_AUTOBRIEF = NO | |
OPTIMIZE_OUTPUT_FOR_C = YES | |
MAN_LINKS = NO | |
MACRO_EXPANSION = YES | |
SOURCE_BROWSER = YES | |
STRIP_CODE_COMMENTS = NO | |
GENERATE_HTMLHELP = YES | |
CHM_FILE = Hamlib.chm | |
SEARCHENGINE = NO | |
endef | |
define RC_COMMON | |
#include <winver.h> | |
#if defined(__clang__) | |
#define RC_BUILDER "clang-cl" | |
#elif defined(_MSC_VER) | |
#define RC_BUILDER "MSVC" | |
#else | |
#error "Who are you?" | |
#endif | |
#ifndef RC_DESCRIPTION | |
#error "Add a #define RC_DESCRIPTION .." | |
#endif | |
#ifndef RC_FILENAME | |
#error "Add a #define RC_FILENAME .." | |
#endif | |
#define RC_VERSION $(MAJOR_VER),$(MINOR_VER),0,0 | |
#define RC_VER_STRING "$(VERSION).0.0 (" RC_BUILDER ", $(CPU))" | |
VS_VERSION_INFO VERSIONINFO | |
FILEVERSION RC_VERSION | |
PRODUCTVERSION RC_VERSION | |
FILEFLAGSMASK 0x3fL | |
FILEOS VOS__WINDOWS32 | |
FILETYPE VFT_DLL | |
FILEFLAGS 0x0L | |
FILESUBTYPE 0x0L | |
BEGIN | |
BLOCK "StringFileInfo" | |
BEGIN | |
BLOCK "040904b0" | |
BEGIN | |
VALUE "CompanyName", "https://github.com/Hamlib/Hamlib" | |
VALUE "FileDescription", RC_DESCRIPTION | |
VALUE "FileVersion", RC_VER_STRING | |
VALUE "InternalName", "Hamlib, ABI ver. $(ABI_VER)" | |
VALUE "LegalCopyright", "GNU General Public License v2.0" | |
VALUE "OriginalFilename", RC_FILENAME | |
VALUE "ProductName", RC_FILENAME | |
VALUE "ProductVersion", RC_VER_STRING | |
VALUE "PrivateBuild", $(RC_PRIVATE) | |
VALUE "SpecialBuild", "" | |
VALUE "Comments", "Built on $(DATE)" | |
END | |
END | |
BLOCK "VarFileInfo" | |
BEGIN | |
VALUE "Translation", 0x409, 1200 | |
END | |
END | |
endef | |
# | |
# These are needed by many programs: | |
# | |
define Hamlib_extra_symbols | |
AESStringCrypt | |
AESStringDecrypt | |
add2debugmsgsave | |
azimuth_long_path | |
date_strget | |
dec2dmmm | |
dec2dms | |
distance_long_path | |
dmmm2dec | |
dms2dec | |
dump_hex | |
elapsed_ms | |
flrig_cat_string | |
from_bcd | |
from_bcd_be | |
hl_usleep | |
locator2longlat | |
longlat2locator | |
multicast_init | |
multicast_send | |
netrigctl_get_vfo_mode | |
port_open | |
print_ext_param | |
qrb | |
read_string | |
spaces | |
sprintf_freq | |
sprintf_level_ext | |
to_bcd | |
to_bcd_be | |
vfo_fixup2a | |
write_block | |
endef | |
ifeq ($(USE_PTHREADS),1) | |
define Hamlib_extras_pthreads | |
network_multicast_publisher_start | |
network_multicast_publisher_stop | |
endef | |
else | |
Hamlib_extras_pthreads = | |
endif | |
define Hamlib_DATA_symbols | |
cookie_use DATA | |
debugmsgsave DATA | |
debugmsgsave2 DATA | |
debugmsgsave3 DATA | |
hamlib_copyright DATA | |
hamlib_copyright2 DATA | |
hamlib_version DATA | |
hamlib_version2 DATA | |
lock_mode DATA | |
rig_powerstat DATA | |
; | |
; Exported functions: | |
; | |
endef | |
define cpp_filter_PY | |
import sys, os | |
empty_lines = 0 | |
while True: | |
line = sys.stdin.readline() | |
if not line: | |
break | |
if line.startswith('\r') or line.startswith('\n'): | |
empty_lines += 1 | |
continue | |
if line.strip() != "": | |
print (line, end="") | |
# Print a newline after functions and classes | |
if line.strip() == '}': | |
print ("") | |
if empty_lines > 0: | |
print ("Removed %d empty lines.\n" % empty_lines, file=sys.stderr) | |
endef | |
define check_for_unused_libs_PY | |
# | |
# Check for unused libraries in a MSVC link .map file. | |
# Prints with colours using 'colorama' (if available). | |
# | |
import os, sys | |
map_file = sys.argv[1] | |
ignore_libs = [ "oldnames.lib", "libcmt.lib" ] | |
class State(): | |
IDLE = 0 | |
UNUSED = 1 | |
class Colour(): | |
RED = WHITE = RESET = "" | |
try: | |
from colorama import init, Fore, Style | |
init() | |
Colour.RED = Fore.RED + Style.BRIGHT | |
Colour.WHITE = Fore.WHITE + Style.BRIGHT | |
Colour.RESET = Style.RESET_ALL | |
except: | |
pass | |
def cprint (color, s): | |
print ("%s%s%s" % (color, s, Colour.RESET)) | |
def report (unused): | |
num = len(unused) | |
if num > 0: | |
cprint (Colour.RED, "%d unused %s in %s:" % (num, ["library", "libraries"][num > 1], map_file)) | |
for u in unused: | |
print (" " + u) | |
cprint (Colour.WHITE, "Done.\n") | |
def process_map (state): | |
unused_libs = [] | |
f = open (map_file, "rt") | |
lines = f.readlines() | |
f.close() | |
for l in lines: | |
l = l.strip() | |
if l == "Unused libraries:": | |
state = State.UNUSED | |
continue | |
if state == State.UNUSED: | |
if l == "": | |
break | |
if os.path.basename (l).lower() not in ignore_libs: | |
unused_libs.append (l) | |
return unused_libs | |
for i in range(2, len(sys.argv)): | |
ignore_libs.append (sys.argv[i].lower()) | |
report (process_map(State.IDLE)) | |
endef | |
# | |
# Use gcc to create a '.depend.Windows' | |
# | |
DEP_CFLAGS = -MM --include include/hamlib/config.h $(filter -I% -D%, $(CFLAGS)) | |
DEP_REPLACE = sed -e 's@\(.*\)\.o: @\n$$(OBJ_DIR)\/\1.$$(O): @' \ | |
-e 's@$(OBJ_DIR)/[a-z]*\.h@@g' \ | |
-e 's@$(OBJ_DIR)/sys/[a-z]*\.h@@g' \ | |
-e 's@$(BOOST_ROOT)@$$(BOOST_ROOT)@' \ | |
-e 's@$(GNURADIO_ROOT)@$$(GNURADIO_ROOT)@' \ | |
-e 's@$(LIBICONV_ROOT)@$$(LIBICONV_ROOT)@' \ | |
-e 's@$(LIBINDI_ROOT)@$$(LIBINDI_ROOT)@' \ | |
-e 's@$(LIBGD_ROOT)@$$(LIBGD_ROOT)@' \ | |
-e 's@$(LIBREADLINE_ROOT)@$$(LIBREADLINE_ROOT)@' \ | |
-e 's@$(LIBUSB_ROOT)@$$(LIBUSB_ROOT)@' \ | |
-e 's@$(LIBUSRP_ROOT)@$$(LIBUSRP_ROOT)@' \ | |
-e 's@$(LIBXML2_ROOT)@$$(LIBXML2_ROOT)@' \ | |
-e 's@$(LUAJIT_ROOT)@$$(LUAJIT_ROOT)@' \ | |
-e 's@$(LUA5_ROOT)@$$(LUA5_ROOT)@' | |
ALL_C_SRC = $(hamlib_C_SRC) $(hamlib_misc_SRC) $(wildcard tests/*.c) | |
ALL_CC_SRC = $(hamlib_CC_SRC) $(hamlibpp_SRC) $(hamlib_CPP_SRC) | |
depend_c.args: FORCE | |
$(call green_msg, Creating $@) | |
$(call create_resp_file, $@, $(DEP_CFLAGS) $(ALL_C_SRC)) | |
depend_cc.args: FORCE | |
$(call green_msg, Creating $@) | |
$(call create_resp_file, $@, $(DEP_CFLAGS) -std=c++11 $(ALL_CC_SRC)) | |
depend: $(OBJ_DIR) $(OBJ_DIR)/sys $(GENERATED) depend_c.args depend_cc.args | |
$(call generate, .depend.Windows, #) | |
@echo -e '#\n# Dependencies for $$(ALL_C_SRC):\n#' >> .depend.Windows | |
gcc @depend_c.args | $(DEP_REPLACE) >> .depend.Windows | |
@echo -e '#\n# Dependencies for $$(ALL_CC_SRC):\n#' >> .depend.Windows | |
gcc @depend_cc.args | $(DEP_REPLACE) >> .depend.Windows | |
-include .depend.Windows | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment