Replace OBJ_EXT with EXT.obj and similar for other extensions

This will allow to make the code dealing with extensions more generic in the
future.

Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
Christophe de Dinechin 2020-09-01 22:04:53 +02:00
parent 4344969408
commit ff92a7386f
7 changed files with 59 additions and 59 deletions

View File

@ -81,8 +81,8 @@ The kind of output your makefile produces depends on the extension in
The build commands for each case are defined in build environment
configurations, e.g. `config.gnu.mk`, by variables called `MAKE_EXE`,
`MAKE_LIB` and `MAKE_DLL`. The actual extension being used are also
defined in the same file, as `EXE_EXT`, `LIB_EXT` and `DLL_EXT`. For
example, on Linux, `LIB_EXT` is set to `.a`.
defined in the same file, as `EXT.exe`, `EXT.lib` and `EXT.dll`. For
example, on Linux, `EXT.lib` is set to `.a`.
## Building the products

View File

@ -40,14 +40,14 @@ OS_NAME_BUILDENV_cygwin=windows
include $(MIQ)config.gnu.mk
# Cygwin uses Windows extensions, e.g. ld looks for .dll files
EXE_EXT= .exe
LIB_EXT= .a
DLL_EXT= .dll
OBJ_EXT= .obj
EXT.exe= .exe
EXT.lib= .a
EXT.dll= .dll
EXT.obj= .obj
# Because of the above, we need to put the number before the extesion
# e.g. where Linux would have libfoo.so.1.3.2, cygwin has libfoo.1.3.2.dll
MIQ_DLLBASE= $(@:%.install_dll=%)
MIQ_DLLNAME= $(MIQ_DLLBASE:%$(DLL_EXT)=%$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))$(DLL_EXT))
MIQ_SONAME= $(MIQ_SOBASE:%$(DLL_EXT)=%)$(MIQ_V_MAJOR:%=.%)$(DLL_EXT)
MIQ_DLLNAME= $(MIQ_DLLBASE:%$(EXT.dll)=%$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))$(EXT.dll))
MIQ_SONAME= $(MIQ_SOBASE:%$(EXT.dll)=%)$(MIQ_V_MAJOR:%=.%)$(EXT.dll)
MIQ_SONAME_OPT= $(PRODUCTS_VERSION:%=-Wl,-soname -Wl,$(MIQ_SONAME))

View File

@ -101,20 +101,20 @@ LDFLAGS_TARGET_profile= -pg
# File extensions
#------------------------------------------------------------------------------
EXE_EXT=
EXT.exe=
ifdef LIBTOOL
OBJ_EXT= .lo
LIB_EXT= .la
DLL_EXT= .la
EXT.obj= .lo
EXT.lib= .la
EXT.dll= .la
else
OBJ_EXT= .o
LIB_EXT= .a
DLL_EXT= .so
EXT.obj= .o
EXT.lib= .a
EXT.dll= .so
endif
EXE_PFX=
LIB_PFX= lib
DLL_PFX= lib
PFX.exe=
PFX.lib= lib
PFX.dll= lib
#------------------------------------------------------------------------------

View File

@ -41,15 +41,15 @@ OS_NAME_BUILDENV_macosx-clang=macosx
include $(MIQ)config.gnu.mk
DLL_EXT= .dylib
EXT.dll= .dylib
TEST_ENV= DYLD_LIBRARY_PATH=$(OUTPUT)
# For macOS, the convention is to put the version number before extension,
# e.g. where Linux would have libfoo.so.1.3.2, macOS has libfoo.1.3.2.dylib
MIQ_DLLBASE= $(@:%.install_dll=%)
MIQ_DLLNAME= $(MIQ_DLLBASE:%$(DLL_EXT)=%$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))$(DLL_EXT))
MIQ_SONAME= $(MIQ_SOBASE:%$(DLL_EXT)=%)$(MIQ_V_MAJOR:%=.%)$(DLL_EXT)
MIQ_DLLNAME= $(MIQ_DLLBASE:%$(EXT.dll)=%$(PRODUCTS_VERSION:%=.$(MIQ_V_VERSION))$(EXT.dll))
MIQ_SONAME= $(MIQ_SOBASE:%$(EXT.dll)=%)$(MIQ_V_MAJOR:%=.%)$(EXT.dll)
MIQ_SONAME_OPT= $(PRODUCTS_VERSION:%=-Wl,-install_name -Wl,$(MIQ_SONAME))
# On MacOSX, we will use basic frameworks e.g. for string and filesystem functions

View File

@ -47,9 +47,9 @@ include $(MIQ)config.gnu.mk
PREFIX_DLL:=$(PREFIX_DLL:$(PREFIX_LIB)=$(PREFIX_BIN))
# Windows overrides for extensions
EXE_EXT= .exe
LIB_EXT= .a
DLL_EXT= .dll
EXT.exe= .exe
EXT.lib= .a
EXT.dll= .dll
# MinGW has no 'install' program
INSTALL= cp

View File

@ -104,14 +104,14 @@ LDFLAGS_TARGET_profile= -pdb:$(MIQ_PDB) -debug
# File extensions
#------------------------------------------------------------------------------
OBJ_EXT=.obj
LIB_EXT=.lib
EXE_EXT=.exe
DLL_EXT=.dll
EXT.obj=.obj
EXT.lib=.lib
EXT.exe=.exe
EXT.dll=.dll
EXE_PFX=
LIB_PFX=lib
DLL_PFX=lib
PFX.exe=
PFX.lib=
PFX.dll=
LINK_DIR_OPT=-L:
LINK_LIB_OPT=-l:

View File

@ -125,14 +125,14 @@ endif
# Configuration variables
MIQ_OBJDIR:= $(MIQ_OBJROOT)/$(MIQ_DIR)
MIQ_OBJECTS= $(MIQ_SOURCES:%=$(MIQ_OBJDIR)%$(OBJ_EXT))
MIQ_OBJECTS= $(MIQ_SOURCES:%=$(MIQ_OBJDIR)%$(EXT.obj))
MIQ_PRODEXE= $(filter %.exe,$(PRODUCTS))
MIQ_PRODLIB= $(filter %.lib,$(PRODUCTS))
MIQ_PRODDLL= $(filter %.dll,$(PRODUCTS))
MIQ_PRODLIBS= $(OUTPUT:%=$(LINK_DIR_OPT)%) $(filter %.lib %.dll,$(PRODUCTS))
MIQ_OUTEXE= $(MIQ_PRODEXE:%.exe=$(OUTPUT)$(EXE_PFX)%$(EXE_EXT))
MIQ_OUTLIB= $(MIQ_PRODLIB:%.lib=$(OUTPUT)$(LIB_PFX)%$(LIB_EXT))
MIQ_OUTDLL= $(MIQ_PRODDLL:%.dll=$(OUTPUT)$(DLL_PFX)%$(DLL_EXT))
MIQ_OUTEXE= $(MIQ_PRODEXE:%.exe=$(OUTPUT)$(PFX.exe)%$(EXT.exe))
MIQ_OUTLIB= $(MIQ_PRODLIB:%.lib=$(OUTPUT)$(PFX.lib)%$(EXT.lib))
MIQ_OUTDLL= $(MIQ_PRODDLL:%.dll=$(OUTPUT)$(PFX.dll)%$(EXT.dll))
MIQ_OUTPRODS= $(MIQ_OUTEXE) $(MIQ_OUTLIB) $(MIQ_OUTDLL)
MIQ_BUILDTEST= $(MAKE) SOURCES=$(@:%.test=%) \
PRODUCTS=$*_test.exe \
@ -142,7 +142,7 @@ MIQ_BUILDTEST= $(MAKE) SOURCES=$(@:%.test=%) \
MIQ_RUNTEST= $(TEST_ENV) \
$(TEST_CMD_$*) \
$(OUTPUT)$(EXE_PFX)$*_test$(EXE_EXT) \
$(OUTPUT)$(PFX.exe)$*_test$(EXT.exe) \
$(TEST_ARGS_$*)
# Versioning for DLLs
@ -167,8 +167,8 @@ endif
MIQ_LIBS= $(LIBRARIES) $(LINK_LIBS)
MIQ_LIBNAMES= $(filter %.lib, $(notdir $(MIQ_LIBS)))
MIQ_DLLNAMES= $(filter %.dll, $(notdir $(MIQ_LIBS)))
MIQ_OBJLIBS= $(MIQ_LIBNAMES:%.lib=$(OUTPUT)$(LIB_PFX)%$(LIB_EXT))
MIQ_OBJDLLS= $(MIQ_DLLNAMES:%.dll=$(OUTPUT)$(DLL_PFX)%$(DLL_EXT))
MIQ_OBJLIBS= $(MIQ_LIBNAMES:%.lib=$(OUTPUT)$(PFX.lib)%$(EXT.lib))
MIQ_OBJDLLS= $(MIQ_DLLNAMES:%.dll=$(OUTPUT)$(PFX.dll)%$(EXT.dll))
MIQ_LINKLIBS= $(MIQ_LIBNAMES:%.lib=$(LINK_LIB_OPT)%) \
$(MIQ_DLLNAMES:%.dll=$(LINK_DLL_OPT)%)
MIQ_TOLINK= $(MIQ_OBJECTS) $(MIQ_OBJLIBS) $(MIQ_OBJDLLS)
@ -184,7 +184,7 @@ MIQ_RECURSE= $(MAKE) TARGET=$(TARGET) \
MIQ_MAKEDEPS:= $(MAKEFILE_LIST)
MIQ_INDEX:= 1
MIQ_COUNT:= $(words $(MIQ_SOURCES))
MIQ_PROFOUT:= $(subst $(EXE_EXT),,$(MIQ_OUTEXE))_prof_$(GIT_REVISION).vsp
MIQ_PROFOUT:= $(subst $(EXT.exe),,$(MIQ_OUTEXE))_prof_$(GIT_REVISION).vsp
MIQ_TARNAME= $(PACKAGE_NAME)-$(PACKAGE_VERSION)
MIQ_TARBALL= $(MIQ_TARNAME).tar.bz2
@ -371,9 +371,9 @@ endif
.PRECIOUS: %/.mkdir
# If LIBRARIES=foo/bar, go to directory foo/bar, which should build bar.a
$(OUTPUT)$(LIB_PFX)%$(LIB_EXT): $(DEEP_BUILD)
$(OUTPUT)$(PFX.lib)%$(EXT.lib): $(DEEP_BUILD)
+$(PRINT_COMMAND) cd $(firstword $(dir $(filter %$*, $(LIBRARIES:.lib=) $(SUBDIRS))) .nonexistent) && $(MIQ_RECURSE)
$(OUTPUT)$(DLL_PFX)%$(DLL_EXT): $(DEEP_BUILD)
$(OUTPUT)$(PFX.dll)%$(EXT.dll): $(DEEP_BUILD)
+$(PRINT_COMMAND) cd $(firstword $(dir $(filter %$*, $(LIBRARIES:.dll=) $(SUBDIRS))) .nonexistent) && $(MIQ_RECURSE)
@ -419,7 +419,7 @@ ifdef RECURSE
# Dependencies generation
#------------------------------------------------------------------------------
MIQ_DEPENDENCIES=$(MIQ_SOURCES:%=$(MIQ_OBJDIR)%$(OBJ_EXT).d)
MIQ_DEPENDENCIES=$(MIQ_SOURCES:%=$(MIQ_OBJDIR)%$(EXT.obj).d)
MIQ_OBJDIR_DEPS=$(MIQ_OBJDIR)%.deps/.mkdir
MIQ_OBJDEPS=$(MIQ_OBJDIR_DEPS) $(MIQ_MAKEDEPS) $(MIQ_ORDERONLY:%=% .prebuild)
@ -436,21 +436,21 @@ POSTPROCESS_DEPENDENCY?= \
fmt -1 | \
sed -e 's/^ *//' -e 's/$$/:/' >> $@ )
$(MIQ_OBJDIR)%.c$(OBJ_EXT).d: %.c $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.c$(EXT.obj).d: %.c $(MIQ_OBJDEPS)
$(PRINT_DEPEND) ( $(CC_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(MIQ_OBJDIR)%.cpp$(OBJ_EXT).d: %.cpp $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.cpp$(EXT.obj).d: %.cpp $(MIQ_OBJDEPS)
$(PRINT_DEPEND) ( $(CXX_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(MIQ_OBJDIR)%.cc$(OBJ_EXT).d: %.cc $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.cc$(EXT.obj).d: %.cc $(MIQ_OBJDEPS)
$(PRINT_DEPEND) ( $(CXX_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(MIQ_OBJDIR)%.s$(OBJ_EXT).d: %.s $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.s$(EXT.obj).d: %.s $(MIQ_OBJDEPS)
$(PRINT_DEPEND) ( $(AS_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
$(MIQ_OBJDIR)%.asm$(OBJ_EXT).d: %.asm $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.asm$(EXT.obj).d: %.asm $(MIQ_OBJDEPS)
$(PRINT_DEPEND) ( $(AS_DEPEND) && $(POSTPROCESS_DEPENDENCY) )
else
# Compiler has decent support for dependency generation
$(MIQ_OBJDIR)%$(OBJ_EXT).d: $(MIQ_OBJDIR)%$(OBJ_EXT)
$(MIQ_OBJDIR)%$(EXT.obj).d: $(MIQ_OBJDIR)%$(EXT.obj)
endif
@ -460,21 +460,21 @@ endif
#------------------------------------------------------------------------------
# Compilation
$(MIQ_OBJDIR)%.c$(OBJ_EXT): %.c $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.c$(EXT.obj): %.c $(MIQ_OBJDEPS)
$(PRINT_COMPILE) $(MAKE_CC)
$(MIQ_OBJDIR)%.cpp$(OBJ_EXT): %.cpp $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.cpp$(EXT.obj): %.cpp $(MIQ_OBJDEPS)
$(PRINT_COMPILE) $(MAKE_CXX)
$(MIQ_OBJDIR)%.cc$(OBJ_EXT): %.cc $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.cc$(EXT.obj): %.cc $(MIQ_OBJDEPS)
$(PRINT_COMPILE) $(MAKE_CXX)
$(MIQ_OBJDIR)%.s$(OBJ_EXT): %.s $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.s$(EXT.obj): %.s $(MIQ_OBJDEPS)
$(PRINT_COMPILE) $(MAKE_AS)
$(MIQ_OBJDIR)%.asm$(OBJ_EXT): %.asm $(MIQ_OBJDEPS)
$(MIQ_OBJDIR)%.asm$(EXT.obj): %.asm $(MIQ_OBJDEPS)
$(PRINT_COMPILE) $(MAKE_AS)
# Skip headers
$(MIQ_OBJDIR)%.h$(OBJ_EXT):
$(MIQ_OBJDIR)%.hpp$(OBJ_EXT):
$(MIQ_OBJDIR)%.hh$(OBJ_EXT):
$(MIQ_OBJDIR)%.h$(EXT.obj):
$(MIQ_OBJDIR)%.hpp$(EXT.obj):
$(MIQ_OBJDIR)%.hh$(EXT.obj):
# Include dependencies from current directory
# We only build when the target is set to avoid dependencies on 'clean'
@ -488,9 +488,9 @@ $(MIQ_OUTPRODS): | $(OUTPUT).mkdir-only
# Link
.SECONDEXPANSION:
MIQ_NOSRC= $(@:$(OUTPUT)%=%)
MIQ_NOEXE= $(MIQ_NOSRC:$(EXE_PFX)%$(EXE_EXT)=%)
MIQ_NOLIB= $(MIQ_NOEXE:$(LIB_PFX)%$(LIB_EXT)=%)
MIQ_NODLL= $(MIQ_NOLIB:$(DLL_PFX)%$(DLL_EXT)=%)
MIQ_NOEXE= $(MIQ_NOSRC:$(PFX.exe)%$(EXT.exe)=%)
MIQ_NOLIB= $(MIQ_NOEXE:$(PFX.lib)%$(EXT.lib)=%)
MIQ_NODLL= $(MIQ_NOLIB:$(PFX.dll)%$(EXT.dll)=%)
MIQ_OUT_SOURCES=$(SOURCES_$(MIQ_NODLL))
$(MIQ_OUTLIB): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
$(PRINT_BUILD) $(MAKE_LIB)