Changeset 99 for trunk/libjdkmidi/trunk

Show
Ignore:
Timestamp:
09/07/06 16:35:45 (2 years ago)
Author:
jeffk@…
Message:

more factoring out of common makefile code into functions

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libjdkmidi/trunk/magic.mak

    r98 r99  
    1111 
    1212 
     13# this first target, 'everything' is a placeholder which makes the required subdirectories and then 
     14# calls make again with the required directories made. Since these subdirectories are part of the 
     15# search paths, make must see them when invoked otherwise it gets confused. 
     16 
     17.PHONY : everything 
     18 
     19ifeq ($(CROSS_COMPILING),1) 
     20everything : native_dirs dirs 
     21   @$(MAKE) all 
     22else 
     23everything : dirs 
     24   @$(MAKE) all 
     25endif 
     26 
     27 
    1328# default project settings. These are usually originally set in project.mak 
    1429 
     
    213228# all source files in a specified directory class and construct the o file lists for them. 
    214229# Param $(1) is the class of program in capitals, for example TOOLS, TESTS, EXAMPLES, GUI 
     230# Param $(2) is the lowercase directory name that these source files live in. $(2) is also 
     231# used as the make target for the exe files in this class. 
    215232# the text returned by this function is then to be eval'd.  The appropriate lists of  
    216233# source files and O files for this class are then created dynamically. 
    217234 
    218235define search_program_group 
     236LIB_$(1)_DIR+=$$(call target_suffix_platform_dirs,$(2)) 
     237 
     238 
    219239LIB_$(1)_CPP_FILES=$$(call get_file_list,$$(LIB_$(1)_DIR),cpp) 
    220240LIB_$(1)_CC_FILES=$$(call get_file_list,$$(LIB_$(1)_DIR),cc) 
     
    231251LIB_$(1)_EXE_FILES=$$(addprefix $$(OUTPUT_$(1)_DIR)/,$$(notdir $$(LIB_$(1)_O_FILES:.o=$$(EXE)))) 
    232252 
    233 ifeq ($(CROSS_COMPILING),1) 
     253OUTPUT_$(1)_DIR?=$$(OUTPUT_DIR)/$(2) 
     254 
     255ALL_OUTPUT_DIRS+=$$(OUTPUT_DIR)/$(2) 
     256 
     257.PHONY : $(2) 
     258 
     259$(2) : lib $$(LIB_$(1)_EXE_FILES) config-tool 
     260 
     261$$(LIB_$(1)_EXE_FILES) : $$(OUTPUT_LIB) 
     262 
     263ifeq ($(CROSS_COMPILING),1) 
     264 
     265NATIVE_LIB_$(1)_DIR+=$$(call native_suffix_platform_dirs,$(2)) 
     266 
    234267NATIVE_LIB_$(1)_CPP_FILES=$$(call get_file_list,$$(NATIVE_LIB_$(1)_DIR),cpp) 
    235268NATIVE_LIB_$(1)_CC_FILES=$$(call get_file_list,$$(NATIVE_LIB_$(1)_DIR),cc) 
     
    238271NATIVE_LIB_$(1)_SH_FILES=$$(call get_file_list,$$(NATIVE_LIB_$(1)_DIR),sh) 
    239272 
    240 NATIVE_LIB_TOOLS_O_FILES=$$(call get_native_cpp_o_files,$$(NATIVE_LIB_$(1)_CPP_FILES)) \ 
     273NATIVE_LIB_$(1)_O_FILES=$$(call get_native_cpp_o_files,$$(NATIVE_LIB_$(1)_CPP_FILES)) \ 
    241274   $$(call get_native_cc_o_files,$$(NATIVE_LIB_$(1)_CC_FILES)) \ 
    242275   $$(call get_native_c_o_files,$$(NATIVE_LIB_$(1)_C_FILES)) \ 
     
    245278 
    246279NATIVE_LIB_$(1)_EXE_FILES=$$(addprefix $$(NATIVE_OUTPUT_$(1)_DIR)/,$$(notdir $$(NATIVE_LIB_$(1)_O_FILES:.o=$$(NATIVE_EXE)))) 
    247 endif 
     280 
     281NATIVE_OUTPUT_$(1)_DIR?=$$(NATIVE_OUTPUT_DIR)/$(2) 
     282 
     283NATIVE_ALL_OUTPUT_DIRS+=$$(NATIVE_OUTPUT_DIR)/$(2) 
     284 
     285.PHONY : native_$(1) 
     286 
     287native-$(2) : native-lib $$(NATIVE_LIB_$(1)_EXE_FILES) 
     288 
     289$$(NATIVE_LIB_$(1)_EXE_FILES) : $(NATIVE_OUTPUT_LIB) 
     290endif 
     291 
     292 
    248293endef 
    249294 
     
    412457LIB_INCLUDE_DIR+=$(call target_suffix_platform_dirs,include) 
    413458LIB_SRC_DIR+=$(call target_suffix_platform_dirs,src) 
    414 LIB_TESTS_DIR+=$(call target_suffix_platform_dirs,tests) 
    415 LIB_GUI_DIR+=$(call target_suffix_platform_dirs,gui) 
    416 LIB_EXAMPLES_DIR+=$(call target_suffix_platform_dirs,examples) 
    417 LIB_TOOLS_DIR+=$(call target_suffix_platform_dirs,tools) 
    418459LIB_DOCS_DIR+=$(call target_suffix_platform_dirs,docs) 
    419460 
     
    421462OUTPUT_DIR=$(BUILD_DIR)/build 
    422463OUTPUT_LIB_DIR?=$(OUTPUT_DIR)/lib 
    423 OUTPUT_TESTS_DIR?=$(OUTPUT_DIR)/tests 
    424464OUTPUT_DOCS_DIR?=$(OUTPUT_DIR)/docs 
    425 OUTPUT_TOOLS_DIR?=$(OUTPUT_DIR)/tools 
    426 OUTPUT_GUI_DIR?=$(OUTPUT_DIR)/gui 
    427 OUTPUT_EXAMPLES_DIR?=$(OUTPUT_DIR)/examples 
    428465OUTPUT_OBJ_DIR?=$(OUTPUT_DIR)/obj 
    429466 
     
    439476INSTALL_DOCS_DIR?=$(INSTALL_DIR)/share/$(PROJECT)-$(PROJECT_VERSION) 
    440477 
    441 ALL_OUTPUT_DIRS+=$(OUTPUT_LIB_DIR) $(OUTPUT_TOOLS_DIR) $(OUTPUT_TESTS_DIR) $(OUTPUT_DOCS_DIR) $(OUTPUT_EXAMPLES_DIR) $(OUTPUT_OBJ_DIR) $(OUTPUT_GUI_DIR) 
    442  
    443  
     478ALL_OUTPUT_DIRS+=$(OUTPUT_LIB_DIR) $(OUTPUT_DOCS_DIR) $OUTPUT_OBJ_DIR) 
    444479 
    445480NATIVE_USE_AR?=1 
     
    516551# calculate our output directories for our native platform results 
    517552 
     553NATIVE_LIB_SRC_DIR+=$(call native_suffix_platform_dirs,src) 
     554 
    518555NATIVE_OUTPUT_DIR=$(NATIVE_BUILD_DIR)/native 
    519556NATIVE_OUTPUT_LIB_DIR?=$(NATIVE_OUTPUT_DIR)/lib 
    520 NATIVE_OUTPUT_TESTS_DIR?=$(NATIVE_OUTPUT_DIR)/tests 
    521557NATIVE_OUTPUT_DOCS_DIR?=$(NATIVE_OUTPUT_DIR)/docs 
    522 NATIVE_OUTPUT_TOOLS_DIR?=$(NATIVE_OUTPUT_DIR)/tools 
    523 NATIVE_OUTPUT_EXAMPLES_DIR?=$(NATIVE_OUTPUT_DIR)/examples 
    524558NATIVE_OUTPUT_OBJ_DIR?=$(NATIVE_OUTPUT_DIR)/obj 
    525559 
    526560NATIVE_OUTPUT_LIB?=$(NATIVE_OUTPUT_LIB_DIR)/lib$(PROJECT).a 
    527561 
    528  
    529 NATIVE_LIB_SRC_DIR+=$(call native_suffix_platform_dirs,tests) 
    530 NATIVE_LIB_TESTS_DIR+=$(call native_suffix_platform_dirs,tests) 
    531 NATIVE_LIB_GUI_DIR+=$(call native_suffix_platform_dirs,gui) 
    532 NATIVE_LIB_EXAMPLES_DIR+=$(call native_suffix_platform_dirs,examples) 
    533 NATIVE_LIB_TOOLS_DIR+=$(call native_suffix_platform_dirs,tools) 
    534  
    535  
    536 NATIVE_ALL_OUTPUT_DIRS+=$(NATIVE_OUTPUT_LIB_DIR) $(NATIVE_OUTPUT_TOOLS_DIR) $(NATIVE_OUTPUT_TESTS_DIR) $(NATIVE_OUTPUT_DOCS_DIR) $(NATIVE_OUTPUT_EXAMPLES_DIR) $(NATIVE_OUTPUT_OBJ_DIR)  
     562NATIVE_ALL_OUTPUT_DIRS+=$(NATIVE_OUTPUT_LIB_DIR) $(NATIVE_OUTPUT_DOCS_DIR) $(NATIVE_OUTPUT_OBJ_DIR)  
    537563 
    538564 
     
    546572vpath %.o $(OUTPUT_OBJ_DIR) 
    547573 
    548 # all source files in all of our src,tests,ecxamples,tools,gui dirs 
     574# all source files in all of our src,tests,examples,tools,gui dirs 
    549575vpath %.m $(LIB_SRC_DIR) $(LIB_TESTS_DIR) $(LIB_EXAMPLES_DIR) $(LIB_TOOLS_DIR) $(LIB_GUI_DIR) 
    550576vpath %.mm $(LIB_SRC_DIR) $(LIB_TESTS_DIR) $(LIB_EXAMPLES_DIR) $(LIB_TOOLS_DIR) $(LIB_GUI_DIR) 
     
    752778# get the list of tool program source files from the tools directories 
    753779 
    754 $(eval $(call search_program_group,TOOLS)) 
     780$(eval $(call search_program_group,TOOLS,tools)) 
    755781 
    756782# get the list of test program source files from the tests directories 
    757783 
    758 $(eval $(call search_program_group,TESTS)) 
     784$(eval $(call search_program_group,TESTS,tests)) 
    759785 
    760786# get the list of example program source files from the examples directories 
    761787 
    762 $(eval $(call search_program_group,EXAMPLES)) 
     788$(eval $(call search_program_group,EXAMPLES,examples)) 
    763789 
    764790# get the list of example program source files from the gui directories 
    765791 
    766 $(eval $(call search_program_group,GUI)) 
     792$(eval $(call search_program_group,GUI,gui)) 
    767793 
    768794 
    769795 
    770796# manipulate these file lists to create our desired output files in the proper place 
    771  
    772 # this first target, 'everything' is a placeholder which makes the required subdirectories and then 
    773 # calls make again with the required directories made. Since these subdirectories are part of the 
    774 # search paths, make must see them when invoked otherwise it gets confused. 
    775  
    776 .PHONY : everything 
    777  
    778 ifeq ($(CROSS_COMPILING),1) 
    779 everything : native_dirs dirs 
    780    @$(MAKE) all 
    781 else 
    782 everything : dirs 
    783    @$(MAKE) all 
    784 endif 
    785  
    786797 
    787798 
     
    817828endif 
    818829 
    819  
    820  
    821 .PHONY : tools 
    822  
    823 tools : lib $(LIB_TOOLS_EXE_FILES) config-tool 
    824  
    825 $(LIB_TOOLS_EXE_FILES) : $(OUTPUT_LIB) 
    826  
    827 .PHONY : examples 
    828  
    829 examples: lib $(LIB_EXAMPLES_EXE_FILES) 
    830  
    831 $(LIB_EXAMPLES_EXE_FILES) : $(OUTPUT_LIB) 
    832  
    833 .PHONY : tests 
    834  
    835 tests: lib $(LIB_TESTS_EXE_FILES) 
    836  
    837 $(LIB_TESTS_EXE_FILES) : $(OUTPUT_LIB) 
    838  
    839  
    840 gui: lib $(LIB_GUI_EXE_FILES) 
    841  
    842 $(LIB_GUI_EXE_FILES) : $(OUTPUT_LIB) 
    843830 
    844831.PHONY : install 
     
    934921 
    935922 
    936 .PHONY : native_tools 
    937  
    938 native-tools : native-lib $(NATIVE_LIB_TOOLS_EXE_FILES) 
    939  
    940 $(NATIVE_LIB_TOOLS_EXE_FILES) : $(NATIVE_OUTPUT_LIB) 
    941  
    942 .PHONY : native-examples 
    943  
    944 native-examples: native-lib $(NATIVE_LIB_EXAMPLES_EXE_FILES) 
    945  
    946 $(NATIVE_LIB_EXAMPLES_EXE_FILES) : $(NATIVE_OUTPUT_LIB) 
    947  
    948 .PHONY : native-tests 
    949  
    950 native-tests: native-lib $(NATIVE_LIB_TESTS_EXE_FILES) 
    951  
    952 $(NATIVE_LIB_TESTS_EXE_FILES) : $(NATIVE_OUTPUT_LIB) 
    953923 
    954924.PHONY : native-test 
     
    998968   @echo "RANLIB : $(RANLIB)" 
    999969   @echo "COMPILE_FLAGS: $(COMPILE_FLAGS)" 
     970   @echo "DEFINES: $(DEFINES)" 
    1000971   @echo "LINK_FLAGS: $(LINK_FLAGS)" 
    1001972   @echo "LDLIBS: $(LDLIBS)"