26 # clean: remove intermediate build files |
26 # clean: remove intermediate build files |
27 # mrproper: remove intermediate files and makefile configuration |
27 # mrproper: remove intermediate files and makefile configuration |
28 # upgradeconf: add new options to old Makefile.config |
28 # upgradeconf: add new options to old Makefile.config |
29 # osx: OS X application |
29 # osx: OS X application |
30 # release: used by OSX to make a dmg file ready to release |
30 # release: used by OSX to make a dmg file ready to release |
|
31 # unittest: compile and link ./yapf/unittest/unittest - test for some yapf related classes, and run it |
31 |
32 |
32 # Options: |
33 # Options: |
33 # |
34 # |
34 # Summary of OS choice defines |
35 # Summary of OS choice defines |
35 # WIN32: building on Windows |
36 # WIN32: building on Windows |
250 # Set output executable names |
251 # Set output executable names |
251 TTD=openttd$(EXE) |
252 TTD=openttd$(EXE) |
252 ENDIAN_CHECK=endian_check$(EXE) |
253 ENDIAN_CHECK=endian_check$(EXE) |
253 STRGEN=strgen/strgen$(EXE) |
254 STRGEN=strgen/strgen$(EXE) |
254 OSXAPP="OpenTTD.app" |
255 OSXAPP="OpenTTD.app" |
|
256 UNITTEST=unit_test$(EXE) |
255 |
257 |
256 ifdef RELEASE |
258 ifdef RELEASE |
257 REV:=$(RELEASE) |
259 REV:=$(RELEASE) |
258 else |
260 else |
259 REV := $(shell if test -d .svn; then svnversion . | awk '{ print "r"$$0 }'; fi) |
261 REV := $(shell if test -d .svn; then svnversion . | awk '{ print "r"$$0 }'; fi) |
|
262 endif |
|
263 |
|
264 # define flag to use for -lrt (some OSes overwrites this later for compatibility) |
|
265 ifndef LRT |
|
266 ifndef MORPHOS |
|
267 LRT:= -lrt |
|
268 endif |
260 endif |
269 endif |
261 |
270 |
262 # MorphOS needs builddate |
271 # MorphOS needs builddate |
263 BUILDDATE=`date +%d.%m.%y` |
272 BUILDDATE=`date +%d.%m.%y` |
264 |
273 |
265 # Check if there is a windres override |
274 # Check if there is a windres override |
266 ifndef WINDRES |
275 ifndef WINDRES |
267 WINDRES = windres |
276 WINDRES = windres |
268 endif |
277 endif |
269 |
278 |
|
279 # Check that CXX is defined. If not, then it's g++ |
|
280 ifndef CXX |
|
281 CXX = g++ |
|
282 endif |
|
283 |
|
284 # Check if CXX_HOST is defined. If not, it is CXX |
|
285 ifndef CXX_HOST |
|
286 CXX_HOST = $(CXX) |
|
287 endif |
|
288 |
|
289 # Check if we have a new target |
|
290 ifdef CXX_TARGET |
|
291 CXX = $(CXX_TARGET) |
|
292 endif |
|
293 |
270 # Check if CC_HOST is defined. If not, it is CC |
294 # Check if CC_HOST is defined. If not, it is CC |
271 ifndef CC_HOST |
295 ifndef CC_HOST |
272 CC_HOST = $(CC) |
296 CC_HOST = $(CC) |
273 endif |
297 endif |
274 ifndef CFLAGS_HOST |
298 ifndef CFLAGS_HOST |
283 CC_VERSION = $(shell $(CC) -dumpversion | cut -c 1,3) |
307 CC_VERSION = $(shell $(CC) -dumpversion | cut -c 1,3) |
284 |
308 |
285 # GNU make can only test for (in)equality |
309 # GNU make can only test for (in)equality |
286 # this is a workaround to test for >= |
310 # this is a workaround to test for >= |
287 ifeq ($(shell expr $(CC_VERSION) \>= 29), 1) |
311 ifeq ($(shell expr $(CC_VERSION) \>= 29), 1) |
288 CFLAGS += -O -Wall -Wno-multichar -Wsign-compare -Wstrict-prototypes -Wundef |
312 CFLAGS += -O -Wall -Wno-multichar -Wsign-compare -Wundef |
|
313 CC_CFLAGS += -Wstrict-prototypes |
289 CFLAGS += -Wwrite-strings -Wpointer-arith |
314 CFLAGS += -Wwrite-strings -Wpointer-arith |
290 endif |
315 endif |
291 ifeq ($(shell expr $(CC_VERSION) \>= 30), 1) |
316 ifeq ($(shell expr $(CC_VERSION) \>= 30), 1) |
292 CFLAGS += -W -Wno-unused-parameter |
317 CFLAGS += -W -Wno-unused-parameter |
293 endif |
318 endif |
294 ifeq ($(shell expr $(CC_VERSION) \>= 34), 1) |
319 ifeq ($(shell expr $(CC_VERSION) \>= 34), 1) |
295 CFLAGS += -Wdeclaration-after-statement -Wold-style-definition |
320 CC_CFLAGS += -Wdeclaration-after-statement -Wold-style-definition |
296 endif |
321 endif |
297 |
322 |
298 ifdef DEBUG |
323 ifdef DEBUG |
299 ifeq ($(shell expr $(DEBUG) \>= 1), 1) |
324 ifeq ($(shell expr $(DEBUG) \>= 1), 1) |
300 CFLAGS += -g -D_DEBUG |
325 CFLAGS += -g -D_DEBUG |
698 SRCS += window.c |
741 SRCS += window.c |
699 SRCS += music/null_m.c |
742 SRCS += music/null_m.c |
700 SRCS += sound/null_s.c |
743 SRCS += sound/null_s.c |
701 SRCS += video/dedicated_v.c |
744 SRCS += video/dedicated_v.c |
702 SRCS += video/null_v.c |
745 SRCS += video/null_v.c |
|
746 SRCS += yapf/follow_track.cpp |
|
747 SRCS += yapf/yapf_common.cpp |
|
748 SRCS += yapf/yapf_rail.cpp |
|
749 SRCS += yapf/yapf_road.cpp |
|
750 SRCS += yapf/yapf_ship.cpp |
703 |
751 |
704 # AI related files |
752 # AI related files |
705 SRCS += ai/ai.c |
753 SRCS += ai/ai.c |
706 SRCS += ai/default/default.c |
754 SRCS += ai/default/default.c |
707 SRCS += ai/trolly/build.c |
755 SRCS += ai/trolly/build.c |
822 |
870 |
823 lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt |
871 lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt |
824 @echo '===> Compiling language $(*F)' |
872 @echo '===> Compiling language $(*F)' |
825 $(Q)$(STRGEN) $(STRGEN_FLAGS) $< $(LANG_ERRORS) || rm -f $@ |
873 $(Q)$(STRGEN) $(STRGEN_FLAGS) $< $(LANG_ERRORS) || rm -f $@ |
826 |
874 |
|
875 # stupid KUDr doesn't know how to setup unittest dependencies (so rm,cp,rm) |
|
876 # please don't blame him and repair it: |
|
877 unittest: endian_host.h $(UPDATECONFIG) $(UNITTEST) rununittest |
|
878 $(UNITTEST): yapf/unittest/unittest.cpp |
|
879 @echo '===> Compiling and Linking $@' |
|
880 $(Q)rm -f $(UNITTEST) |
|
881 $(Q)$(CXX_HOST) $(CFLAGS_HOST) $(CDEFS) $< $(LIBS) $(LRT) -o $@ |
|
882 |
|
883 .PHONY: unittest |
|
884 |
|
885 rununittest: |
|
886 @echo '===> Starting unittest' |
|
887 $(Q)./$(UNITTEST) |
|
888 .PHONY: rununittest |
|
889 |
827 ifdef MORPHOS |
890 ifdef MORPHOS |
|
891 |
828 release: all |
892 release: all |
829 $(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.lha" |
893 $(Q)rm -fr "/t/openttd-$(RELEASE)-morphos.lha" |
830 $(Q)mkdir -p "/t/" |
894 $(Q)mkdir -p "/t/" |
831 $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos" |
895 $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos" |
832 $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/docs" |
896 $(Q)mkdir -p "/t/openttd-$(RELEASE)-morphos/docs" |
875 |
939 |
876 |
940 |
877 clean: |
941 clean: |
878 @echo '===> Cleaning up' |
942 @echo '===> Cleaning up' |
879 # endian.h is out-dated and no longer in use, so it can be removed soon |
943 # endian.h is out-dated and no longer in use, so it can be removed soon |
880 $(Q)rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(OBJS) $(OSX_MIDI_PLAYER_FILE) endian.h endian_host.h endian_target.h $(ENDIAN_CHECK) .OSX |
944 $(Q)rm -rf .deps *~ $(TTD) $(STRGEN) core table/strings.h $(LANGS) $(OBJS) $(OSX_MIDI_PLAYER_FILE) endian.h endian_host.h endian_target.h $(ENDIAN_CHECK) .OSX $(UNITTEST) |
881 |
945 |
882 mrproper: clean |
946 mrproper: clean |
883 $(Q)rm -rf $(MAKE_CONFIG) |
947 $(Q)rm -rf $(MAKE_CONFIG) |
884 |
948 |
885 ifndef OSX |
949 ifndef OSX |
961 |
1025 |
962 depend: |
1026 depend: |
963 @true # The include handles this automagically |
1027 @true # The include handles this automagically |
964 |
1028 |
965 # Introduce the dependencies |
1029 # Introduce the dependencies |
966 ifeq ($(findstring $(MAKECMDGOALS), clean info depend mrproper upgradeconf $(MAKE_CONFIG)),) |
1030 ifeq ($(findstring $(MAKECMDGOALS), clean info depend mrproper upgradeconf unittest $(MAKE_CONFIG)),) |
967 -include $(DEPS) |
1031 -include $(DEPS) |
968 endif |
1032 endif |
969 |
1033 |
970 # Silence stale header dependency errors |
1034 # Silence stale header dependency errors |
971 %.h: |
1035 %.h: |
986 |
1050 |
987 ifndef NATIVE_OSX |
1051 ifndef NATIVE_OSX |
988 # OSX uses os/macosx/Makefile to compile files |
1052 # OSX uses os/macosx/Makefile to compile files |
989 %.o: %.c $(MAKE_CONFIG) |
1053 %.o: %.c $(MAKE_CONFIG) |
990 @echo '===> Compiling $<' |
1054 @echo '===> Compiling $<' |
991 $(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1055 $(Q)$(CC) $(CC_CFLAGS) $(CFLAGS) $(CDEFS) -c -o $@ $< |
992 |
1056 |
993 %.o: %.cpp $(MAKE_CONFIG) |
1057 %.o: %.cpp $(MAKE_CONFIG) |
994 @echo '===> Compiling $<' |
1058 @echo '===> Compiling $<' |
995 $(Q)$(CXX) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1059 $(Q)$(CXX) $(CFLAGS) $(CDEFS) -c -o $@ $< |
996 |
1060 |
997 %.o: %.m $(MAKE_CONFIG) |
1061 %.o: %.m $(MAKE_CONFIG) |
998 @echo '===> Compiling $<' |
1062 @echo '===> Compiling $<' |
999 $(Q)$(CC) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1063 $(Q)$(CC) $(CC_CFLAGS) $(CFLAGS) $(CDEFS) -c -o $@ $< |
1000 endif |
1064 endif |
1001 |
1065 |
1002 %.o: %.rc |
1066 %.o: %.rc |
1003 @echo '===> Compiling resource $<' |
1067 @echo '===> Compiling resource $<' |
1004 $(Q)$(WINDRES) -o $@ $< |
1068 $(Q)$(WINDRES) -o $@ $< |