Make the COMPILE and LINK build steps more generic
By using names like COMPILE.c and LINK.lib, this will make it easier to generate build rules more easily based on extensions Signed-off-by: Christophe de Dinechin <christophe@dinechin.org>
This commit is contained in:
parent
445cae64ae
commit
42a0bb0ac2
|
@ -79,8 +79,8 @@ The kind of output your makefile produces depends on the extension in
|
||||||
* `.dll` for a dynamic library
|
* `.dll` for a dynamic library
|
||||||
|
|
||||||
The build commands for each case are defined in build environment
|
The build commands for each case are defined in build environment
|
||||||
configurations, e.g. `config.gnu.mk`, by variables called `MAKE_EXE`,
|
configurations, e.g. `config.gnu.mk`, by variables called `LINK.exe`,
|
||||||
`MAKE_LIB` and `MAKE_DLL`. The actual extension being used are also
|
`LINK.lib` and `LINK.dll`. The actual extension being used are also
|
||||||
defined in the same file, as `EXT.exe`, `EXT.lib` and `EXT.dll`. For
|
defined in the same file, as `EXT.exe`, `EXT.lib` and `EXT.dll`. For
|
||||||
example, on Linux, `EXT.lib` is set to `.a`.
|
example, on Linux, `EXT.lib` is set to `.a`.
|
||||||
|
|
||||||
|
|
|
@ -150,32 +150,35 @@ LDFLAGS_RPATH= -Wl,-rpath,$(PREFIX_DLL)
|
||||||
ifdef LIBTOOL
|
ifdef LIBTOOL
|
||||||
MIQ_COMPILE= $(LIBTOOL) --silent --mode=compile
|
MIQ_COMPILE= $(LIBTOOL) --silent --mode=compile
|
||||||
MIQ_LINK= $(LIBTOOL) --silent --mode=link
|
MIQ_LINK= $(LIBTOOL) --silent --mode=link
|
||||||
MAKE_CC= $(MIQ_COMPILE) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
COMPILE.c= $(MIQ_COMPILE) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
||||||
MAKE_CXX= $(MIQ_COMPILE) $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
COMPILE.cpp= $(MIQ_COMPILE) $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
||||||
MAKE_AS= $(MIQ_COMPILE) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
COMPILE.s= $(MIQ_COMPILE) $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
||||||
MAKE_LIB= $(MIQ_LINK) $(LD) $(MIQ_LDFLAGS) $(MIQ_LINKARGS) \
|
LINK.lib= $(MIQ_LINK) $(LD) $(MIQ_LDFLAGS) $(MIQ_LINKARGS) \
|
||||||
-o $@ \
|
-o $@ \
|
||||||
$(MIQ_LT_VERS_OPT)
|
$(MIQ_LT_VERS_OPT)
|
||||||
MAKE_DLL= $(MAKE_LIB)
|
LINK.dll= $(LINK.lib)
|
||||||
INSTALL_DLL= $(LIBTOOL) --silent --mode=install \
|
INSTALL.dll= $(LIBTOOL) --silent --mode=install \
|
||||||
$(INSTALL) $(MIQ_DLLNAME) $(PACKAGE_INSTALL_DLL)
|
$(INSTALL) $(MIQ_DLLNAME) $(PACKAGE_INSTALL_DLL)
|
||||||
MAKE_EXE= $(MIQ_LINK) $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
LINK.exe= $(MIQ_LINK) $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
||||||
else
|
else
|
||||||
# Non-libtool case: manage manually
|
# Non-libtool case: manage manually
|
||||||
CFLAGS_PIC= -fPIC
|
CFLAGS_PIC= -fPIC
|
||||||
MAKE_CC= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
COMPILE.c= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
||||||
MAKE_CXX= $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
COMPILE.cpp= $(CXX) $(MIQ_CXXFLAGS) -c $< -o $@
|
||||||
MAKE_AS= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
COMPILE.s= $(CC) $(MIQ_CFLAGS) -c $< -o $@
|
||||||
MAKE_LIB= $(AR) $@ $(MIQ_TOLINK) && $(RANLIB) $@
|
LINK.lib= $(AR) $@ $(MIQ_TOLINK) && $(RANLIB) $@
|
||||||
MAKE_DLL= $(LD) -shared $(MIQ_LINKARGS) $(MIQ_LDFLAGS) \
|
LINK.dll= $(LD) -shared $(MIQ_LINKARGS) $(MIQ_LDFLAGS) \
|
||||||
-o $(MIQ_DLLNAME) \
|
-o $(MIQ_DLLNAME) \
|
||||||
$(MIQ_SONAME_OPT) \
|
$(MIQ_SONAME_OPT) \
|
||||||
&& (cd $(OUTPUT) $(MIQ_SYMLINKS))
|
&& (cd $(OUTPUT) $(MIQ_SYMLINKS))
|
||||||
INSTALL_DLL= $(INSTALL) $(MIQ_DLLNAME) $(PACKAGE_INSTALL_DLL) \
|
INSTALL.dll= $(INSTALL) $(MIQ_DLLNAME) $(PACKAGE_INSTALL_DLL) \
|
||||||
&& (cd $(PACKAGE_INSTALL_DLL) $(MIQ_SYMLINKS))
|
&& (cd $(PACKAGE_INSTALL_DLL) $(MIQ_SYMLINKS))
|
||||||
MAKE_EXE= $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
LINK.exe= $(LD) $(MIQ_LINKARGS) $(MIQ_LDFLAGS) -o $@
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
COMPILE.cc= $(COMPILE.cpp)
|
||||||
|
COMPILE.asm= $(COMPILE.s)
|
||||||
|
|
||||||
LINK_DIR_OPT= -L
|
LINK_DIR_OPT= -L
|
||||||
LINK_LIB_OPT= -l
|
LINK_LIB_OPT= -l
|
||||||
LINK_DLL_OPT= -l
|
LINK_DLL_OPT= -l
|
||||||
|
|
|
@ -128,13 +128,14 @@ LINK_DLL_OPT=-l:
|
||||||
# In order to merge all .pdb information for an executable, we need to pass the -debug
|
# In order to merge all .pdb information for an executable, we need to pass the -debug
|
||||||
# option to the linker.
|
# option to the linker.
|
||||||
|
|
||||||
MAKE_CC= $(CC) $(MIQ_CFLAGS) -c -Fo$@ $<
|
COMPILE.c= $(CC) $(MIQ_CFLAGS) -c -Fo$@ $<
|
||||||
MAKE_CXX= $(CXX) $(MIQ_CXXFLAGS) -c -Fo$@ $<
|
COMPILE.cpp= $(CXX) $(MIQ_CXXFLAGS) -c -Fo$@ $<
|
||||||
|
COMPILE.cc= $(COMPILE.cpp)
|
||||||
MAKE_DIR= mkdir -p $*
|
MAKE_DIR= mkdir -p $*
|
||||||
MAKE_OBJDIR= $(MAKE_DIR) && touch $@
|
MAKE_OBJDIR= $(MAKE_DIR) && touch $@
|
||||||
MAKE_LIB= $(MSLIB) $(MIQ_LINKOPTS) -out:$@
|
LINK.lib= $(MSLIB) $(MIQ_LINKOPTS) -out:$@
|
||||||
MAKE_DLL= $(LD) $(MIQ_LINKOPTS) $(MIQ_LDFLAGS) -dll -out:$@
|
LINK.dll= $(LD) $(MIQ_LINKOPTS) $(MIQ_LDFLAGS) -dll -out:$@
|
||||||
MAKE_EXE= $(LD) $(MIQ_LINKOPTS) $(MIQ_LDFLAGS) -out:$@
|
LINK.exe= $(LD) $(MIQ_LINKOPTS) $(MIQ_LDFLAGS) -out:$@
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
|
|
16
rules.mk
16
rules.mk
|
@ -461,15 +461,15 @@ endif
|
||||||
|
|
||||||
# Compilation
|
# Compilation
|
||||||
$(MIQ_OBJDIR)%.c$(EXT.obj): %.c $(MIQ_OBJDEPS)
|
$(MIQ_OBJDIR)%.c$(EXT.obj): %.c $(MIQ_OBJDEPS)
|
||||||
$(PRINT_COMPILE) $(MAKE_CC)
|
$(PRINT_COMPILE) $(COMPILE.c)
|
||||||
$(MIQ_OBJDIR)%.cpp$(EXT.obj): %.cpp $(MIQ_OBJDEPS)
|
$(MIQ_OBJDIR)%.cpp$(EXT.obj): %.cpp $(MIQ_OBJDEPS)
|
||||||
$(PRINT_COMPILE) $(MAKE_CXX)
|
$(PRINT_COMPILE) $(COMPILE.cpp)
|
||||||
$(MIQ_OBJDIR)%.cc$(EXT.obj): %.cc $(MIQ_OBJDEPS)
|
$(MIQ_OBJDIR)%.cc$(EXT.obj): %.cc $(MIQ_OBJDEPS)
|
||||||
$(PRINT_COMPILE) $(MAKE_CXX)
|
$(PRINT_COMPILE) $(COMPILE.cc)
|
||||||
$(MIQ_OBJDIR)%.s$(EXT.obj): %.s $(MIQ_OBJDEPS)
|
$(MIQ_OBJDIR)%.s$(EXT.obj): %.s $(MIQ_OBJDEPS)
|
||||||
$(PRINT_COMPILE) $(MAKE_AS)
|
$(PRINT_COMPILE) $(COMPILE.s)
|
||||||
$(MIQ_OBJDIR)%.asm$(EXT.obj): %.asm $(MIQ_OBJDEPS)
|
$(MIQ_OBJDIR)%.asm$(EXT.obj): %.asm $(MIQ_OBJDEPS)
|
||||||
$(PRINT_COMPILE) $(MAKE_AS)
|
$(PRINT_COMPILE) $(COMPILE.asm)
|
||||||
|
|
||||||
# Skip headers
|
# Skip headers
|
||||||
$(MIQ_OBJDIR)%.h$(EXT.obj):
|
$(MIQ_OBJDIR)%.h$(EXT.obj):
|
||||||
|
@ -493,11 +493,11 @@ MIQ_NOLIB= $(MIQ_NOEXE:$(PFX.lib)%$(EXT.lib)=%)
|
||||||
MIQ_NODLL= $(MIQ_NOLIB:$(PFX.dll)%$(EXT.dll)=%)
|
MIQ_NODLL= $(MIQ_NOLIB:$(PFX.dll)%$(EXT.dll)=%)
|
||||||
MIQ_OUT_SOURCES=$(SOURCES_$(MIQ_NODLL))
|
MIQ_OUT_SOURCES=$(SOURCES_$(MIQ_NODLL))
|
||||||
$(MIQ_OUTLIB): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
$(MIQ_OUTLIB): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
||||||
$(PRINT_BUILD) $(MAKE_LIB)
|
$(PRINT_BUILD) $(LINK.lib)
|
||||||
$(MIQ_OUTDLL): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
$(MIQ_OUTDLL): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
||||||
$(PRINT_BUILD) $(MAKE_DLL)
|
$(PRINT_BUILD) $(LINK.dll)
|
||||||
$(MIQ_OUTEXE): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
$(MIQ_OUTEXE): $(MIQ_TOLINK) $$(MIQ_TOLINK) $(MIQ_MAKEDEPS)
|
||||||
$(PRINT_BUILD) $(MAKE_EXE)
|
$(PRINT_BUILD) $(LINK.exe)
|
||||||
|
|
||||||
#------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------
|
||||||
# Package configuration
|
# Package configuration
|
||||||
|
|
Loading…
Reference in New Issue