745 else |
745 else |
746 Q = @ |
746 Q = @ |
747 quiet = quiet_ |
747 quiet = quiet_ |
748 endif |
748 endif |
749 |
749 |
750 # Show the command (quiet or non-quiet version based on the assignment |
|
751 # just above) and then execute it. |
|
752 cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1)) |
|
753 |
|
754 |
|
755 # The build commands themselves. Note that if you omit the quiet version, |
|
756 # nothing will be shown in the non-verbose mode. |
|
757 |
|
758 quiet_cmd_compile_link = '===> Compiling and Linking $@' |
|
759 cmd_compile_link = $(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@ |
|
760 |
|
761 quiet_cmd_ttd_link = '===> Linking $@' |
|
762 cmd_ttd_link = $(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@ |
|
763 |
|
764 COMPILE_PARAMS=$(CFLAGS) $(CDEFS) -MD -c $< -o $@ |
|
765 |
|
766 quiet_cmd_c_compile = '===> Compiling $<' |
|
767 cmd_c_compile = $(CC) $(COMPILE_PARAMS) |
|
768 |
|
769 quiet_cmd_cxx_compile = '===> Compiling $<' |
|
770 cmd_cxx_compile = $(CXX) $(COMPILE_PARAMS) |
|
771 |
|
772 quiet_cmd_objc_compile = '===> Compiling $<' |
|
773 cmd_objc_compile = $(CC) $(COMPILE_PARAMS) |
|
774 |
|
775 |
750 |
776 ############################################################################## |
751 ############################################################################## |
777 # |
752 # |
778 # Targets |
753 # Targets |
779 # |
754 # |
797 endian_target.h: $(ENDIAN_CHECK) |
772 endian_target.h: $(ENDIAN_CHECK) |
798 @echo '===> Testing endianness for target' |
773 @echo '===> Testing endianness for target' |
799 $(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@ |
774 $(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@ |
800 |
775 |
801 $(ENDIAN_CHECK): endian_check.c |
776 $(ENDIAN_CHECK): endian_check.c |
802 $(call cmd,compile_link) |
777 @echo '===> Compiling and Linking $@' |
803 |
778 $(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@ |
804 |
779 |
805 $(TTD): table/strings.h $(OBJS) $(MAKE_CONFIG) |
780 |
806 $(call cmd,ttd_link) |
781 $(TTD): $(OBJS) $(MAKE_CONFIG) |
|
782 @echo '===> Linking $@' |
|
783 $(Q)$(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@ |
807 |
784 |
808 $(OSX): $(TTD) |
785 $(OSX): $(TTD) |
809 $(Q)rm -fr "$(OSXAPP)" |
786 $(Q)rm -fr "$(OSXAPP)" |
810 $(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS |
787 $(Q)mkdir -p "$(OSXAPP)"/Contents/MacOS |
811 $(Q)mkdir -p "$(OSXAPP)"/Contents/Resources |
788 $(Q)mkdir -p "$(OSXAPP)"/Contents/Resources |
827 $(64_bit_warnings): |
804 $(64_bit_warnings): |
828 $(warning 64 bit CPUs will get some 64 bit specific bugs!) |
805 $(warning 64 bit CPUs will get some 64 bit specific bugs!) |
829 $(warning If you see any bugs, include in your bug report that you use a 64 bit CPU) |
806 $(warning If you see any bugs, include in your bug report that you use a 64 bit CPU) |
830 |
807 |
831 $(STRGEN): strgen/strgen.c endian_host.h |
808 $(STRGEN): strgen/strgen.c endian_host.h |
832 $(call cmd,compile_link) |
809 @echo '===> Compiling and Linking $@' |
|
810 $(Q)$(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@ |
833 |
811 |
834 table/strings.h: lang/english.txt $(STRGEN) |
812 table/strings.h: lang/english.txt $(STRGEN) |
835 @echo '===> Generating $@' |
813 @echo '===> Generating $@' |
836 $(Q)$(STRGEN) |
814 $(Q)$(STRGEN) |
837 |
815 |
1013 |
991 |
1014 # This makes sure the .deps dir is always around. |
992 # This makes sure the .deps dir is always around. |
1015 DEPS_MAGIC := $(shell mkdir -p .deps .deps/music .deps/sound .deps/video .deps/os .deps/os/macosx) |
993 DEPS_MAGIC := $(shell mkdir -p .deps .deps/music .deps/sound .deps/video .deps/os .deps/os/macosx) |
1016 |
994 |
1017 # Introduce the dependencies |
995 # Introduce the dependencies |
|
996 ifneq ($(MAKECMDGOALS), clean) |
1018 -include $(DEPS) |
997 -include $(DEPS) |
1019 |
998 endif |
1020 # This compiles the object file as well as silently updating its dependencies |
999 |
1021 # list at the same time. It is not an issue that they aren't around during the |
1000 %.o: .deps/%.d |
1022 # first compilation round as we just build everything at that time anyway, |
1001 |
1023 # therefore we do not need to watch deps. |
1002 .deps/%.d: %.c table/strings.h endian_target.h |
1024 |
1003 @echo '===> Determining dependencies of $<' |
1025 %.o: %.c $(MAKE_CONFIG) endian_target.h table/strings.h |
1004 $(Q)$(CC) $(CFLAGS) -M $< > $@ |
1026 $(call cmd,c_compile) |
1005 |
1027 @[ -f $(<:%.c=%.d) ] && mv $(<:%.c=%.d) $(<:%.c=.deps/%.d) || mv $(*F).d $(<:%.c=.deps/%.d) |
1006 .deps/%.d: %.cpp table/strings.h endian_target.h |
1028 |
1007 @echo '===> Determining dependencies of $<' |
1029 %.o: %.cpp $(MAKE_CONFIG) endian_target.h table/strings.h |
1008 $(Q)$(CXX) $(CFLAGS) -M $< > $@ |
1030 $(call cmd,cxx_compile) |
1009 |
1031 @[ -f $(<:%.cpp=%.d) ] && mv $(<:%.cpp=%.d) $(<:%.cpp=.deps/%.d) || mv $(*F).d $(<:%.cpp=.deps/%.d) |
1010 .deps/%.d: %.m table/strings.h endian_target.h |
1032 |
1011 @echo '===> Determining dependencies of $<' |
1033 %.o: %.m $(MAKE_CONFIG) endian_target.h table/strings.h |
1012 $(Q)$(OBJC) $(CFLAGS) -M $< > $@ |
1034 $(call cmd,objc_compile) |
1013 |
1035 @[ -f $(<:%.m=%.d) ] && mv $(<:%.m=%.d) $(<:%.m=.deps/%.d) || mv $(*F).d $(<:%.m=.deps/%.d) |
1014 |
1036 |
1015 %.o: %.c $(MAKE_CONFIG) |
1037 # Silence stale header dependencies |
1016 @echo '===> Compiling $<' |
1038 %.h: |
1017 $(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1039 @true |
1018 |
|
1019 %.o: %.cpp $(MAKE_CONFIG) |
|
1020 @echo '===> Compiling $<' |
|
1021 $(Q)$(CXX) $(CFLAGS) $(CDEFS) -c -o $@ $< |
|
1022 |
|
1023 %.o: %.m $(MAKE_CONFIG) |
|
1024 @echo '===> Compiling $<' |
|
1025 $(Q)$(OBJC) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1040 |
1026 |
1041 |
1027 |
1042 info: |
1028 info: |
1043 @echo 'CFLAGS = $(CFLAGS)' |
1029 @echo 'CFLAGS = $(CFLAGS)' |
1044 @echo 'LDFLAGS = $(LDFLAGS)' |
1030 @echo 'LDFLAGS = $(LDFLAGS)' |