(svn r2196) -Change: updated the Makefile, now it works for crossplatform compiling

(and distcc compiling via Makefile.config). Wiki is coming up soon! Big
tnx to Bjarni and Lucaspiller.
This commit is contained in:
TrueLight 2005-04-14 12:57:21 +00:00
parent cada1e24b5
commit ecc0cd37f4
3 changed files with 65 additions and 21 deletions

View File

@ -107,6 +107,14 @@
#
# VERBOSE: show full compiler invocations instead of brief progress messages
#
# Special for crosscompiling there are some commands available:
#
# ENDIAN_FORCE: forces the endian-check to give a certain result. Can be either BE or LE.
# WINDRES: the location of your windres
# CC_HOST: the gcc of your localhost if you are making a target that produces incompatible executables
# CFLAGS_HOST: cflags used for CC_HOST. Make it something if you are getting errors when you try to compi
# windows executables on linux. (just: CFLAGS_HOST:='-I' or something)
#
# Experimental (does not work properly):
# WITH_DIRECTMUSIC: enable DirectMusic MIDI support
@ -119,7 +127,7 @@
# Makefile version tag
# it checks if the version tag in Makefile.config is the same and force update outdated config files
MAKEFILE_VERSION:=6
MAKEFILE_VERSION:=7
# CONFIG_WRITER has to be found even for manual configuration
CONFIG_WRITER=makefiledir/Makefile.config_writer
@ -261,6 +269,23 @@ endwarnings:=endwarnings
BASECFLAGS += -m64
endif
# Check if there is a windres override
ifndef WINDRES
WINDRES = windres
endif
# Check if we have a new target
ifdef CC_TARGET
CC = $(CC_TARGET)
endif
# Check if CC_HOST is defined. If not, it is CC
ifndef CC_HOST
CC_HOST = $(CC)
endif
ifndef CFLAGS_HOST
CFLAGS_HOST = $(BASECFLAGS)
endif
# When calling the compiler, use these flags
# -g debugging symbols
@ -520,7 +545,10 @@ CDEFS += -DWIN32_ENABLE_DIRECTMUSIC_SUPPORT
endif
ifdef WIN32
LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32 -lstdc++
LIBS += -lws2_32 -lwinmm -lgdi32 -ldxguid -lole32
ifdef WITH_DIRECTMUSIC
LIBS += -lstdc++
endif
TTDLDFLAGS += -Wl,--subsystem,windows
endif
@ -723,7 +751,7 @@ cmd = @$(if $($(quiet)cmd_$(1)),echo $($(quiet)cmd_$(1)) &&) $(cmd_$(1))
# nothing will be shown in the non-verbose mode.
quiet_cmd_compile_link = '===> Compiling and Linking $@'
cmd_compile_link = $(CC) $(BASECFLAGS) $(CDEFS) $< -o $@
cmd_compile_link = $(CC_HOST) $(CFLAGS_HOST) $(CDEFS) $< -o $@
quiet_cmd_ttd_link = '===> Linking $@'
cmd_ttd_link = $(CC) $(LDFLAGS) $(TTDLDFLAGS) $(OBJS) $(LIBS) -o $@
@ -755,7 +783,7 @@ all: endian.h $(UPDATECONFIG) $(LANGS) $(TTD) $(OSX) $(endwarnings)
endian.h: $(ENDIAN_CHECK)
@echo '===> Testing endianness'
$(Q)./$(ENDIAN_CHECK) > $@
$(Q)./$(ENDIAN_CHECK) $(ENDIAN_FORCE) > $@
$(ENDIAN_CHECK): endian_check.c
$(call cmd,compile_link)
@ -800,7 +828,7 @@ lang/%.lng: lang/%.txt $(STRGEN) lang/english.txt
winres.o: ttd.rc
@echo '===> Compiling resource $<'
$(Q)windres -o $@ $<
$(Q)$(WINDRES) -o $@ $<
ifdef MORPHOS
release: all

View File

@ -8,10 +8,18 @@
// that says or TTD_LITTLE_ENDIAN, or TTD_BIG_ENDIAN. Makefile takes
// care of the real writing to the file.
int main () {
int main (int argc, char *argv[]) {
unsigned char EndianTest[2] = { 1, 0 };
int force_BE = 0, force_LE = 0;
if (argc > 1 && strcmp(argv[1], "BE") == 0)
force_BE = 1;
if (argc > 1 && strcmp(argv[1], "LE") == 0)
force_LE = 1;
printf("#ifndef ENDIAN_H\n#define ENDIAN_H\n");
if( *(short *) EndianTest == 1 )
if ( (*(short *) EndianTest == 1 && force_BE != 1) || force_LE == 1)
printf("#define TTD_LITTLE_ENDIAN\n");
else
printf("#define TTD_BIG_ENDIAN\n");

View File

@ -3,14 +3,14 @@
# Magic at work, note that you can't use commas in arguments for this
CONFIG_LINE=@$(SHELL) -c 'echo $(1)' >> $(MAKE_CONFIG) 2> /dev/null
$(MAKE_CONFIG):
$(MAKE_CONFIG):
touch $(MAKE_CONFIG)
$(call CONFIG_LINE,\# OpenTTD config file for makefile)
$(call CONFIG_LINE,\# OpenTTD config file for makefile)
$(call CONFIG_LINE,\# Set your options here - 1 for use and empty for disable)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# User setup flags)
$(call CONFIG_LINE,\# Translator: adds TODO to any untranslated strings)
$(call CONFIG_LINE,\# Display_Warnings: when off it hides some warnings while compiling)
@ -30,11 +30,11 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,WITH_NETWORK:=$(WITH_NETWORK))
$(call CONFIG_LINE,DEDICATED:=$(DEDICATED))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# Disable asserts. Leave them on for easier bug finding)
$(call CONFIG_LINE,DISABLE_ASSERTS:=$(DISABLE_ASSERTS))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# See Makefile for details on these paths)
$(call CONFIG_LINE,\# Folders should not end with /)
$(call CONFIG_LINE,INSTALL:=$(INSTALL))
@ -46,7 +46,7 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,SECOND_DATA_PATH:=$(SECOND_DATA_PATH))
$(call CONFIG_LINE,CUSTOM_LANG_PATH:=$(CUSTOM_LANG_PATH))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# Experimental)
$(call CONFIG_LINE,WITH_DIRECTMUSIC:=$(WITH_DIRECTMUSIC))
$(call CONFIG_LINE,)
@ -58,7 +58,7 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,\# Inform us if you have success)
$(call CONFIG_LINE,SKIP_STATIC_CHECK:=$(SKIP_STATIC_CHECK))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# Everything below this line is autogenerated)
$(call CONFIG_LINE,\#)
@ -66,15 +66,15 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,\# If that does not fix the problem, you should make a bug report.)
$(call CONFIG_LINE,\# It would really help if you could tell how to autodetect the missing setting)
$(call CONFIG_LINE,\# That info could be where the missing lib is placed)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# Libs)
$(call CONFIG_LINE,WITH_ZLIB:=$(WITH_ZLIB))
$(call CONFIG_LINE,WITH_SDL:=$(WITH_SDL))
$(call CONFIG_LINE,WITH_PNG:=$(WITH_PNG))
$(call CONFIG_LINE,STATIC_ZLIB_PATH:=$(STATIC_ZLIB_PATH))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# OS flags)
$(call CONFIG_LINE,WIN32:=$(WIN32))
$(call CONFIG_LINE,UNIX:=$(UNIX))
@ -85,8 +85,16 @@ $(MAKE_CONFIG):
$(call CONFIG_LINE,SUNOS:=$(SUNOS))
$(call CONFIG_LINE,CYGWIN:=$(CYGWIN))
$(call CONFIG_LINE,MINGW:=$(MINGW))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# For cross-compiling)
$(call CONFIG_LINE,CC_TARGET:=$(CC_TARGET))
$(call CONFIG_LINE,CC_HOST:=$(CC_HOST))
$(call CONFIG_LINE,CFLAGS_HOST:=$(CFLAGS_HOST))
$(call CONFIG_LINE,WINDRES:=$(WINDRES))
$(call CONFIG_LINE,ENDIAN_FORCE:=$(ENDIAN_FORCE))
$(call CONFIG_LINE,)
$(call CONFIG_LINE,\# misc)
$(call CONFIG_LINE,SDL-CONFIG:=$(SDL-CONFIG))
$(call CONFIG_LINE,BEOS_NET_SERVER:=$(BEOS_NET_SERVER))