Makefile
changeset 1435 89d0c6a56a9b
parent 1434 f219d7bf2eb6
child 1476 abbcea18a01c
equal deleted inserted replaced
1434:f219d7bf2eb6 1435:89d0c6a56a9b
   685 #
   685 #
   686 # Build commands
   686 # Build commands
   687 #
   687 #
   688 
   688 
   689 # If we are verbose, we will show commands prefixed by $(Q) (which acts as
   689 # If we are verbose, we will show commands prefixed by $(Q) (which acts as
   690 # @ in the non-verbose mode)
   690 # @ in the non-verbose mode), and we will show the "real" cmds instead of
       
   691 # their quiet versions (which are used in the non-verbose mode).
   691 # Inspired by the Linux kernel build system.
   692 # Inspired by the Linux kernel build system.
   692 ifdef VERBOSE
   693 ifdef VERBOSE
   693 	Q =
   694 	Q =
       
   695 	quiet =
   694 else
   696 else
   695 	Q = @
   697 	Q = @
   696 endif
   698 	quiet = quiet_
       
   699 endif
       
   700 
       
   701 # Show the command (quiet or non-quiet version based on the assignment
       
   702 # just above) and then execute it.
       
   703 cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
       
   704 
       
   705 
       
   706 # The build commands themselves. Note that if you omit the quiet version,
       
   707 # nothing will be shown in the non-verbose mode.
       
   708 
       
   709 quiet_cmd_compile_link = '===> Compiling and Linking $@'
       
   710       cmd_compile_link = $(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
       
   711 
       
   712 quiet_cmd_ttd_link = '===> Linking $@'
       
   713       cmd_ttd_link = $(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
       
   714 
       
   715 COMPILE_PARAMS=$(CFLAGS) $(CDEFS) -MD -c $< -o $@
       
   716 
       
   717 quiet_cmd_c_compile = '===> Compiling $<'
       
   718       cmd_c_compile = $(CC) $(COMPILE_PARAMS)
       
   719 
       
   720 quiet_cmd_cxx_compile = '===> Compiling $<'
       
   721       cmd_cxx_compile = $(CXX) $(COMPILE_PARAMS)
   697 
   722 
   698 
   723 
   699 ##############################################################################
   724 ##############################################################################
   700 #
   725 #
   701 # Targets
   726 # Targets
   715 endian.h: $(ENDIAN_CHECK)
   740 endian.h: $(ENDIAN_CHECK)
   716 	@echo '===> Testing endianness'
   741 	@echo '===> Testing endianness'
   717 	$(Q)./$(ENDIAN_CHECK) > $@
   742 	$(Q)./$(ENDIAN_CHECK) > $@
   718 
   743 
   719 $(ENDIAN_CHECK): endian_check.c
   744 $(ENDIAN_CHECK): endian_check.c
   720 	@echo '===> Compiling and Linking $@'
   745 	$(call cmd,compile_link)
   721 	$(Q)$(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
       
   722 
   746 
   723 
   747 
   724 $(TTD): table/strings.h $(OBJS) $(MAKE_CONFIG)
   748 $(TTD): table/strings.h $(OBJS) $(MAKE_CONFIG)
   725 	@echo '===> Linking $@'
   749 	$(call cmd,ttd_link)
   726 	$(Q)$(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
       
   727 
   750 
   728 $(OSX): $(TTD)
   751 $(OSX): $(TTD)
   729 	$(Q)rm -fr "$(OSXAPP)"
   752 	$(Q)rm -fr "$(OSXAPP)"
   730 	$(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS
   753 	$(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS
   731 	$(Q)mkdir -p "$(OSXAPP)"/Contents/Resources
   754 	$(Q)mkdir -p "$(OSXAPP)"/Contents/Resources
   747 $(64_bit_warnings):
   770 $(64_bit_warnings):
   748 	$(warning 64 bit CPUs will get some 64 bit specific bugs!)
   771 	$(warning 64 bit CPUs will get some 64 bit specific bugs!)
   749 	$(warning If you see any bugs, include in your bug report that you use a 64 bit CPU)
   772 	$(warning If you see any bugs, include in your bug report that you use a 64 bit CPU)
   750 
   773 
   751 $(STRGEN): strgen/strgen.c endian.h
   774 $(STRGEN): strgen/strgen.c endian.h
   752 	@echo '===> Compiling and Linking $@'
   775 	$(call cmd,compile_link)
   753 	$(Q)$(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
       
   754 
   776 
   755 table/strings.h: lang/english.txt $(STRGEN)
   777 table/strings.h: lang/english.txt $(STRGEN)
   756 	@echo '===> Generating $@'
   778 	@echo '===> Generating $@'
   757 	$(Q)$(STRGEN)
   779 	$(Q)$(STRGEN)
   758 
   780 
   933 # list at the same time. It is not an issue that they aren't around during the
   955 # list at the same time. It is not an issue that they aren't around during the
   934 # first compilation round as we just build everything at that time anyway,
   956 # first compilation round as we just build everything at that time anyway,
   935 # therefore we do not need to watch deps.
   957 # therefore we do not need to watch deps.
   936 
   958 
   937 %.o: %.c $(MAKE_CONFIG) endian.h table/strings.h
   959 %.o: %.c $(MAKE_CONFIG) endian.h table/strings.h
   938 	@echo '===> Compiling $<'
   960 	$(call cmd,c_compile)
   939 	$(Q)$(CC) $(CFLAGS) $(CDEFS) -MD -c $< -o $@
       
   940 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
   961 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
   941 
   962 
   942 %.o: %.cpp  $(MAKE_CONFIG) endian.h table/strings.h
   963 %.o: %.cpp  $(MAKE_CONFIG) endian.h table/strings.h
   943 	@echo '===> Compiling $<'
   964 	$(call cmd,cxx_compile)
   944 	$(Q)$(CXX) $(CFLAGS) $(CDEFS) -MD -c $< -o $@
       
   945 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
   965 	@mv $(<:%.c=%.d) $(<:%.c=.deps/%.d)
   946 
   966 
   947 # Silence stale header dependencies
   967 # Silence stale header dependencies
   948 %.h:
   968 %.h:
   949 	@true
   969 	@true
   950 
   970 
   951 
   971 
   952 info:
   972 info:
   953 	@echo 'CFLAGS  = $(CFLAGS) $(CDEFS)'
   973 	@echo 'CFLAGS  = $(CFLAGS)'
   954 	@echo 'LDFLAGS = $(LDFLAGS)'
   974 	@echo 'LDFLAGS = $(LDFLAGS)'
   955 	@echo 'LIBS    = $(LIBS)'
   975 	@echo 'LIBS    = $(LIBS)'