Ticket #1053: 0001-Add-set-of-extra-options-for-compiler-linker-and-ass.patch

File 0001-Add-set-of-extra-options-for-compiler-linker-and-ass.patch, 12.8 KB (added by felix winkelmann, 11 years ago)
  • Makefile.cygwin

    From 00cbb08cc46ea6d3635d90960890cab271c6b3ea Mon Sep 17 00:00:00 2001
    From: felix <felix@call-with-current-continuation.org>
    Date: Thu, 1 Aug 2013 17:12:45 +0200
    Subject: [PATCH 1/2] Add set of extra options for compiler, linker and
     assembler. This allows easier customization of the
     build process for specific targets.
    
    ---
     Makefile.cygwin |    8 ++++----
     Makefile.mingw  |    8 ++++----
     defaults.make   |   15 +++++++++------
     rules.make      |   26 +++++++++++++-------------
     4 files changed, 30 insertions(+), 27 deletions(-)
    
    diff --git a/Makefile.cygwin b/Makefile.cygwin
    index 5772caf..7bcfb0e 100644
    a b chicken-defaults.h: 
    137137        echo "# define C_INSTALL_CXX \"$(CXX_COMPILER)\"" >>$@
    138138        echo "#endif" >>$@
    139139        echo "#ifndef C_INSTALL_CFLAGS" >>$@
    140         echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
     140        echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_EXTRA_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
    141141        echo "#endif" >>$@
    142142        echo "#ifndef C_INSTALL_LDFLAGS" >>$@
    143         echo "# define C_INSTALL_LDFLAGS \"$(LINKER_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
     143        echo "# define C_INSTALL_LDFLAGS \"$(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
    144144        echo "#endif" >>$@
    145145        echo "#ifndef C_INSTALL_PREFIX" >>$@
    146146        echo "# define C_INSTALL_PREFIX \"$(PREFIX)\"" >>$@
    chicken-defaults.h: 
    197197        echo "# define C_TARGET_CXX \"$(TARGET_CXX_COMPILER)\"" >>$@
    198198        echo "#endif" >>$@
    199199        echo "#ifndef C_TARGET_CFLAGS" >>$@
    200         echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
     200        echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_EXTRA_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
    201201        echo "#endif" >>$@
    202202        echo "#ifndef C_TARGET_LDFLAGS" >>$@
    203         echo "# define C_TARGET_LDFLAGS \"$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
     203        echo "# define C_TARGET_LDFLAGS \"$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_EXTRA_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
    204204        echo "#endif" >>$@
    205205        echo "#ifndef C_TARGET_FEATURES" >>$@
    206206        echo "# define C_TARGET_FEATURES \"$(TARGET_FEATURES)\"" >>$@
  • Makefile.mingw

    diff --git a/Makefile.mingw b/Makefile.mingw
    index e34f604..8694e2d 100644
    a b endif 
    143143        echo # define C_INSTALL_RC_COMPILER "$(RC_COMPILER)" >>$@
    144144        echo #endif >>$@
    145145        echo #ifndef C_INSTALL_CFLAGS >>$@
    146         echo # define C_INSTALL_CFLAGS "$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
     146        echo # define C_INSTALL_CFLAGS "$(C_COMPILER_OPTIONS) $(C_COMPILER_EXTRA_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
    147147        echo #endif >>$@
    148148        echo #ifndef C_INSTALL_LDFLAGS >>$@
    149         echo # define C_INSTALL_LDFLAGS "$(LINKER_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)" >>$@
     149        echo # define C_INSTALL_LDFLAGS "$(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)" >>$@
    150150        echo #endif >>$@
    151151        echo #ifndef C_INSTALL_PREFIX >>$@
    152152        echo # define C_INSTALL_PREFIX "$(PREFIX)" >>$@
    endif 
    200200        echo # define C_TARGET_RC_COMPILER "$(TARGET_RC_COMPILER)" >>$@
    201201        echo #endif >>$@
    202202        echo #ifndef C_TARGET_CFLAGS >>$@
    203         echo # define C_TARGET_CFLAGS "$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
     203        echo # define C_TARGET_CFLAGS "$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_EXTRA_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)" >>$@
    204204        echo #endif >>$@
    205205        echo #ifndef C_TARGET_LDFLAGS >>$@
    206         echo # define C_TARGET_LDFLAGS "$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)" >>$@
     206        echo # define C_TARGET_LDFLAGS "$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_EXTRA_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)" >>$@
    207207        echo #endif >>$@
    208208        echo #ifndef C_TARGET_FEATURES >>$@
    209209        echo # define C_TARGET_FEATURES "$(TARGET_FEATURES)" >>$@
  • defaults.make

    diff --git a/defaults.make b/defaults.make
    index 9bb2baf..6ef993e 100644
    a b endif 
    128128
    129129TARGET_C_COMPILER_OPTIONS ?= $(C_COMPILER_OPTIONS)
    130130TARGET_C_COMPILER_OPTIMIZATION_OPTIONS ?= $(C_COMPILER_OPTIMIZATION_OPTIONS)
     131TARGET_C_COMPILER_EXTRA_OPTIONS ?= $(C_COMPILER_EXTRA_OPTIONS)
    131132TARGET_PREFIX ?= $(PREFIX)
    132133TARGET_RUN_PREFIX ?= $(TARGET_PREFIX)
    133134TARGET_LIBRARIES ?= $(LIBRARIES)
    134135TARGET_LINKER_OPTIONS ?= $(LINKER_OPTIONS)
    135136TARGET_LINKER_OPTIMIZATION_OPTIONS ?= $(LINKER_OPTIMIZATION_OPTIONS)
     137TARGET_LINKER_EXTRA_OPTIONS ?= $(LINKER_EXTRA_OPTIONS)
    136138TARGET_FEATURES ?=
    137 TARGET_LIB_NAME ?= chicken
    138139
    139140ifneq ($(TARGET_C_COMPILER),$(C_COMPILER))
    140141CROSS_CHICKEN = 1
     142TARGET_LIB_NAME ?= chicken
    141143else
    142144CROSS_CHICKEN = 0
     145TARGET_LIB_NAME ?= $(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)
    143146endif
    144147
    145148
    INSTALL_PROGRAM_EXECUTABLE_OPTIONS ?= -m755 
    200203INSTALL_PROGRAM_FILE_OPTIONS ?= -m644
    201204MAKEDIR_COMMAND_OPTIONS ?= -p
    202205endif
    203 ASSEMBLER_OPTIONS ?= $(C_COMPILER_OPTIONS)
     206ASSEMBLER_OPTIONS ?= $(C_COMPILER_OPTIONS) $(C_COMPILER_EXTRA_OPTIONS)
    204207ASSEMBLER_OUTPUT_OPTION ?= -o
    205208ASSEMBLER_OUTPUT ?= $(ASSEMBLER_OUTPUT_OPTION) $@
    206209ASSEMBLER_COMPILE_OPTION ?= -c
    endif 
    356359        echo "# define C_INSTALL_RC_COMPILER \"$(RC_COMPILER)\"" >>$@
    357360        echo "#endif" >>$@
    358361        echo "#ifndef C_INSTALL_CFLAGS" >>$@
    359         echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
     362        echo "# define C_INSTALL_CFLAGS \"$(C_COMPILER_OPTIONS) $(C_COMPILER_EXTRA_OPTIONS) $(C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
    360363        echo "#endif" >>$@
    361364        echo "#ifndef C_INSTALL_LDFLAGS" >>$@
    362         echo "# define C_INSTALL_LDFLAGS \"$(LINKER_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
     365        echo "# define C_INSTALL_LDFLAGS \"$(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
    363366        echo "#endif" >>$@
    364367        echo "#ifndef C_INSTALL_PREFIX" >>$@
    365368        echo "# define C_INSTALL_PREFIX \"$(PREFIX)\"" >>$@
    endif 
    413416        echo "# define C_TARGET_RC_COMPILER \"$(TARGET_RC_COMPILER)\"" >>$@
    414417        echo "#endif" >>$@
    415418        echo "#ifndef C_TARGET_CFLAGS" >>$@
    416         echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
     419        echo "# define C_TARGET_CFLAGS \"$(TARGET_C_COMPILER_OPTIONS) $(TARGET_C_COMPILER_EXTRA_OPTIONS) $(TARGET_C_COMPILER_OPTIMIZATION_OPTIONS)\"" >>$@
    417420        echo "#endif" >>$@
    418421        echo "#ifndef C_TARGET_LDFLAGS" >>$@
    419         echo "# define C_TARGET_LDFLAGS \"$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
     422        echo "# define C_TARGET_LDFLAGS \"$(TARGET_LINKER_OPTIONS) $(TARGET_LINKER_EXTRA_OPTIONS) $(TARGET_LINKER_OPTIMIZATION_OPTIONS)\"" >>$@
    420423        echo "#endif" >>$@
    421424        echo "#ifndef C_TARGET_FEATURES" >>$@
    422425        echo "# define C_TARGET_FEATURES \"$(TARGET_FEATURES)\"" >>$@
  • rules.make

    diff --git a/rules.make b/rules.make
    index 30c53fd..cb56bad 100644
    a b DISTFILES := $(sort $(DISTFILES)) 
    103103
    104104define declare-shared-library-object
    105105$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    106         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
     106        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) \
    107107          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
    108108          $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    109109          $$(INCLUDES)
    $(foreach obj, $(LIBCHICKEN_OBJECTS_1),\ 
    119119
    120120define declare-static-library-object
    121121$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    122         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
     122        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) \
    123123          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) \
    124124          $$(C_COMPILER_STATIC_OPTIONS) \
    125125          $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    $(foreach obj, $(LIBCHICKEN_OBJECTS_1),\ 
    135135
    136136define declare-import-lib-object
    137137$(1).import$(O): $(1).import.c chicken.h $$(CHICKEN_CONFIG_H)
    138         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_PTABLES_OPTIONS) \
     138        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) $$(C_COMPILER_PTABLES_OPTIONS) \
    139139          -DC_SHARED $$(C_COMPILER_COMPILE_OPTION) \
    140140          $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
    141141          $$(C_COMPILER_BUILD_RUNTIME_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    $(foreach obj,$(SETUP_API_OBJECTS_1),\ 
    156156
    157157define declare-compiler-object
    158158$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    159         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
     159        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) \
    160160          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) $$< \
    161161          $$(C_COMPILER_OUTPUT) $$(INCLUDES)
    162162endef
    $(foreach obj, $(COMPILER_OBJECTS_1),\ 
    168168
    169169define declare-static-compiler-object
    170170$(1)-static$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    171         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
     171        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) \
    172172          $$(C_COMPILER_STATIC_OPTIONS) \
    173173          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    174174          $$(INCLUDES)
    endif 
    188188
    189189define declare-utility-program-object
    190190$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    191         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
     191        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) $$(C_COMPILER_SHARED_OPTIONS) \
    192192          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    193193         $$(INCLUDES)
    194194endef
    $(foreach obj, $(UTILITY_PROGRAM_OBJECTS_1),\ 
    201201
    202202define declare-always-static-utility-program-object
    203203$(1)$(O): $(1).c chicken.h $$(CHICKEN_CONFIG_H)
    204         $$(C_COMPILER) $$(C_COMPILER_OPTIONS) \
     204        $$(C_COMPILER) $$(C_COMPILER_OPTIONS) $$(C_COMPILER_EXTRA_OPTIONS) \
    205205          $$(C_COMPILER_STATIC_OPTIONS) \
    206206          $$(C_COMPILER_COMPILE_OPTION) $$(C_COMPILER_OPTIMIZATION_OPTIONS) $$< $$(C_COMPILER_OUTPUT) \
    207207          $$(INCLUDES)
    $(foreach obj, $(ALWAYS_STATIC_UTILITY_PROGRAM_OBJECTS_1),\ 
    222222libs: $(TARGETLIBS)
    223223
    224224lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(SO): $(LIBCHICKEN_SHARED_OBJECTS) $(APPLY_HACK_OBJECT)
    225         $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_LINKER_OPTIONS) \
     225        $(LINKER) $(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_LINK_SHARED_LIBRARY_OPTIONS) $(LIBCHICKEN_SO_LINKER_OPTIONS) \
    226226          $(LINKER_OUTPUT) $^ $(LIBCHICKEN_SO_LIBRARIES)
    227227ifdef USES_SONAME
    228228        ln -sf $(LIBCHICKEN_SO_FILE) $(LIBCHICKEN_SO_FILE).$(BINARYVERSION)
    lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A): $(APPLY_HACK_OBJECT) $(LIBCHIC 
    244244# import libraries and extensions
    245245
    246246%.so: %.o
    247         $(LINKER) $(LINKER_OPTIONS) $(LINKER_LINK_SHARED_DLOADABLE_OPTIONS) $^ $(LINKER_OUTPUT_OPTION) $@ \
     247        $(LINKER) $(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_LINK_SHARED_DLOADABLE_OPTIONS) $^ $(LINKER_OUTPUT_OPTION) $@ \
    248248          $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) \
    249249          $(LIBRARIES)
    250250
    251251# executables
    252252
    253253$(CHICKEN_SHARED_EXECUTABLE): $(COMPILER_OBJECTS) $(PRIMARY_LIBCHICKEN)
    254         $(LINKER) $(LINKER_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $(COMPILER_OBJECTS) $(LINKER_OUTPUT) \
     254        $(LINKER) $(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_EXECUTABLE_OPTIONS) $(COMPILER_OBJECTS) $(LINKER_OUTPUT) \
    255255          $(LINKER_LIBRARY_PREFIX)$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(LINKER_LIBRARY_SUFFIX) $(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $(LIBRARIES)
    256256
    257257define declare-program-from-object
    258258$(1)-RC_FILE = $(if $(and $(RC_COMPILER),$(3)),$(2).rc$(O))
    259259
    260260$(1): $(2)$(O) $$(PRIMARY_LIBCHICKEN) $$($(1)-RC_FILE)
    261         $$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_EXECUTABLE_OPTIONS) $$< \
     261        $$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_EXTRA_OPTIONS) $$(LINKER_EXECUTABLE_OPTIONS) $$< \
    262262          $$($(1)-RC_FILE) $$(LINKER_OUTPUT) \
    263263          $$(LINKER_LIBRARY_PREFIX)$$(PROGRAM_PREFIX)chicken$$(PROGRAM_SUFFIX)$$(LINKER_LIBRARY_SUFFIX) \
    264264          $$(LINKER_LINK_SHARED_PROGRAM_OPTIONS) $$(LIBRARIES)
    $(eval $(call declare-program-from-object,$(CSC_PROGRAM)$(EXE),csc)) 
    276276# static executables
    277277
    278278$(CHICKEN_STATIC_EXECUTABLE): $(COMPILER_STATIC_OBJECTS) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)
    279         $(LINKER) $(LINKER_OPTIONS) $(LINKER_STATIC_OPTIONS) $(COMPILER_STATIC_OBJECTS) $(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $(LIBRARIES)
     279        $(LINKER) $(LINKER_OPTIONS) $(LINKER_EXTRA_OPTIONS) $(LINKER_STATIC_OPTIONS) $(COMPILER_STATIC_OBJECTS) $(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $(LIBRARIES)
    280280
    281281define declare-static-program-from-object
    282282$(1): $(2)$(O) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A)
    283         $$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_STATIC_OPTIONS) $$< $$(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $$(LIBRARIES)
     283        $$(LINKER) $$(LINKER_OPTIONS) $$(LINKER_EXTRA_OPTIONS) $$(LINKER_STATIC_OPTIONS) $$< $$(LINKER_OUTPUT) lib$(PROGRAM_PREFIX)chicken$(PROGRAM_SUFFIX)$(A) $$(LIBRARIES)
    284284endef
    285285
    286286$(eval $(call declare-program-from-object,$(CSI_STATIC_EXECUTABLE),csi))