diff --git Makefile Makefile index 16df332d5..73e5aa242 100644 --- Makefile +++ Makefile @@ -20,21 +20,22 @@ FREETYPE_CONFIG ?= freetype-config #FREETYPE_CONFIG ?= pkg-config freetype2 BACKENDS = allegro gdi sdl sdl2 mixer_sdl mixer_sdl2 posix -COLOUR_DEPTHS = 0 16 OSTYPES = amiga beos freebsd haiku linux mingw mac openbsd ifeq ($(findstring $(BACKEND), $(BACKENDS)),) $(error Unkown BACKEND "$(BACKEND)", must be one of "$(BACKENDS)") endif -ifeq ($(findstring $(COLOUR_DEPTH), $(COLOUR_DEPTHS)),) - $(error Unkown COLOUR_DEPTH "$(COLOUR_DEPTH)", must be one of "$(COLOUR_DEPTHS)") -endif - ifeq ($(findstring $(OSTYPE), $(OSTYPES)),) $(error Unkown OSTYPE "$(OSTYPE)", must be one of "$(OSTYPES)") endif +ifeq ($(BACKEND),posix) + COLOUR_DEPTH = 0 +else + COLOUR_DEPTH = 16 +endif + ifeq ($(OSTYPE),amiga) STD_LIBS ?= -lunix -lSDL_mixer -lsmpeg -lvorbisfile -lvorbis -logg CFLAGS += -mcrt=newlib -DSIM_BIG_ENDIAN -gstabs+ @@ -83,14 +84,14 @@ LIBS += -lbz2 -lz ifdef OPTIMISE ifeq ($(shell expr $(OPTIMISE) \>= 1), 1) CFLAGS += -O3 - ifeq ($(findstring $(OSTYPE), amiga),) - ifneq ($(findstring $(CXX), clang),) + ifeq ($(findstring amiga, $(OSTYPE)),) + ifneq ($(findstring clang, $(CXX)),) CFLAGS += -minline-all-stringops endif endif endif else - CFLAGS += -O + CFLAGS += -O2 endif ifdef DEBUG @@ -175,7 +176,11 @@ ifdef PROFILE ifeq ($(shell expr $(PROFILE) \>= 1), 1) CFLAGS += -pg -DPROFILE ifeq ($(shell expr $(PROFILE) \>= 2), 1) - CFLAGS += -fno-inline -fno-schedule-insns + CFLAGS += -fno-inline + + ifeq ($(findstring clang, $(CXX)),) + CFLAGS += -fno-schedule-insns + endif endif LDFLAGS += -pg endif @@ -698,14 +703,28 @@ PROGDIR ?= $(BUILDDIR) PROG ?= sim +.DEFAULT_GOAL := all +.PHONY: simutrans makeobj nettool + include common.mk ifeq ($(OSTYPE),mac) include OSX/osx.mk endif - -.PHONY: makeobj +all: simutrans makeobj nettool makeobj: $(Q)$(MAKE) -e -C makeobj FLAGS="$(FLAGS)" + +nettool: + $(Q)$(MAKE) -e -C nettools FLAGS="$(FLAGS)" + +clean: + @echo "===> Cleaning up" + $(Q)rm -f $(OBJS) + $(Q)rm -f $(DEPS) + $(Q)rm -f $(PROGDIR)/$(PROG) + $(Q)rm -fr $(PROGDIR)/$(PROG).app + $(Q)$(MAKE) -e -C makeobj clean + $(Q)$(MAKE) -e -C nettools clean diff --git common.mk common.mk index 2921d6f22..04a6bed28 100644 --- common.mk +++ common.mk @@ -10,6 +10,8 @@ DIRS := $(sort $(dir $(OBJS))) # Make build directories DUMMY := $(shell mkdir -p $(DIRS)) +BUILDCONFIG_FILES := common.mk Makefile config.$(CFG) + .PHONY: all clean .SUFFIXES: .rc @@ -20,42 +22,35 @@ else Q = endif -all: $(PROGDIR)/$(PROG) +simutrans: $(PROGDIR)/$(PROG) $(PROGDIR)/$(PROG): $(OBJS) @echo "===> LD $@" $(Q)$(HOSTCXX) $(OBJS) $(LDFLAGS) $(LIBS) -o $(PROGDIR)/$(PROG) -clean: - @echo "===> Cleaning up" - $(Q)rm -f $(OBJS) - $(Q)rm -f $(DEPS) - $(Q)rm -f $(PROGDIR)/$(PROG) - $(Q)rm -fr $(PROGDIR)/$(PROG).app - -include $(DEPS) # Silence stale header dependency errors %.h: @true -$(BUILDDIR)/%.o: %.mm +$(BUILDDIR)/%.o: %.mm $(BUILDCONFIG_FILES) @echo "===> Obj-c OSX $<" $(Q)$(HOSTCXX) $(CXXFLAGS) $(OBJCFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/%.o: %.m +$(BUILDDIR)/%.o: %.m $(BUILDCONFIG_FILES) @echo "===> Obj-c OSX $<" $(Q)$(HOSTCXX) $(CXXFLAGS) $(OBJCFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/%.o: %.c +$(BUILDDIR)/%.o: %.c $(BUILDCONFIG_FILES) @echo "===> HOSTCC $<" $(Q)$(HOSTCC) $(CCFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/%.o: %.cc +$(BUILDDIR)/%.o: %.cc $(BUILDCONFIG_FILES) @echo "===> HOSTCXX $<" $(Q)$(HOSTCXX) $(CXXFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/%.o: %.rc +$(BUILDDIR)/%.o: %.rc $(BUILDCONFIG_FILES) @echo "===> RES $<" # $(Q)$(WINDRES) --preprocessor "$(HOSTCXX) -E -xc -DRC_INVOKED -MMD -MF $(@:%.o=%.d) -MT $@" -O COFF $< $@ $(Q)$(WINDRES) --preprocessor "$(HOSTCXX) -E -xc -DRC_INVOKED -MMD -MT $@" -O COFF $< $@ diff --git config.default.in config.default.in index 0b2b0770a..4ba845ff4 100644 --- config.default.in +++ config.default.in @@ -5,29 +5,7 @@ # this is config.default.in -# allowed backends: -#BACKEND = allegro -#BACKEND = gdi -#BACKEND = opengl -#BACKEND = sdl -#BACKEND = sdl2 -#BACKEND = mixer_sdl -#BACKEND = posix BACKEND = @backend@ - -# color depth either 16 or 0 (the latter needed for server) -COLOUR_DEPTH = @color@ - -# architecture specifi flags -#OSTYPE = amiga -#OSTYPE = beos -#OSTYPE = cygwin -#OSTYPE = freebsd -#OSTYPE = haiku -#OSTYPE = linux -#OSTYPE = mingw -#OSTYPE = mac - OSTYPE = @os_type@ MSG_LEVEL = 3 diff --git config.template config.template index a31f43586..8471608c7 100644 --- config.template +++ config.template @@ -13,11 +13,9 @@ #BACKEND = sdl #BACKEND = sdl2 #BACKEND = mixer_sdl +#BACKEND = mixer_sdl2 #BACKEND = posix -#COLOUR_DEPTH = 0 -#COLOUR_DEPTH = 16 - #OSTYPE = amiga #OSTYPE = beos #OSTYPE = cygwin diff --git configure.ac configure.ac index 21da7ed81..674e4f1c5 100644 --- configure.ac +++ configure.ac @@ -120,30 +120,24 @@ AC_ARG_ENABLE([server], if test "x$enable_server" != "xno" then AC_SUBST(backend, posix) - AC_SUBST(color, 0) elif test "$ac_cv_header_windows_h" == yes then AC_SUBST(backend, gdi) - AC_SUBST(color, 16) AC_MSG_WARN([Using GDI backend!]) elif test "$ac_cv_lib_SDL2_SDL_GetRenderDriverInfo" == yes then AC_SUBST(backend, sdl2) - AC_SUBST(color, 16) AC_MSG_WARN([Using SDL2 backend!]) elif test "$ac_cv_lib_SDL_SDL_Init" == yes then AC_SUBST(backend, sdl) - AC_SUBST(color, 16) AC_MSG_WARN([Using SDL backend!]) elif test "$ac_cv_lib_allegro_get_desktop_resolution" == yes then AC_SUBST(backend, allegro) - AC_SUBST(color, 16) AC_MSG_WARN([Using SDL2 backend!]) else AC_SUBST(backend, posix) - AC_SUBST(color, 0) AC_MSG_WARN([No backend found, using server (posix)!]) fi diff --git makeobj/Makefile makeobj/Makefile index 98a2bb274..1d3f644d6 100644 --- makeobj/Makefile +++ makeobj/Makefile @@ -6,7 +6,7 @@ CFG ?= default -include ../config.$(CFG) -OSTYPES = beos cygwin freebsd haiku linux mingw mac +OSTYPES = beos cygwin freebsd haiku linux mingw mac ifeq ($(findstring $(OSTYPE), $(OSTYPES)),) $(error Unkown OSTYPE "$(OSTYPE)", must be one of "$(OSTYPES)") @@ -53,8 +53,15 @@ endif ifdef OPTIMISE ifeq ($(shell expr $(OPTIMISE) \>= 1), 1) - CFLAGS += -O3 -fno-schedule-insns - CXXFLAGS += -O3 -fno-schedule-insns + CFLAGS += -O3 + CXXFLAGS += -O3 + + # clang does not support fno-schedule-insns + ifeq ($(findstring clang, $(CXX)),) + CFLAGS += -fno-schedule-insns + CXXFLAGS += -fno-schedule-insns + endif + ifneq ($(OSTYPE),mac) CFLAGS += -minline-all-stringops endif @@ -90,8 +97,8 @@ ifdef PROFILE endif endif -CFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS) -CXXFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align $(OS_INC) $(OS_OPT) $(FLAGS) +CFLAGS += -Wall -Wextra -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS) +CXXFLAGS += -Wall -Wextra -Wcast-qual -Wpointer-arith -Wcast-align $(OS_INC) $(OS_OPT) $(FLAGS) # SOLO_SOURCES contains files which are unique to makeobj; # SHARED_SOURCES contains those with the exact same object code in makeobj and simutrans; diff --git nettools/Makefile nettools/Makefile index 19d7bd0bc..8bf66318b 100644 --- nettools/Makefile +++ nettools/Makefile @@ -36,8 +36,15 @@ endif ifdef OPTIMISE ifeq ($(shell expr $(OPTIMISE) \>= 1), 1) - CFLAGS += -O3 -fno-schedule-insns - CXXFLAGS += -O3 -fno-schedule-insns + CFLAGS += -O3 + CXXFLAGS += -O3 + + # clang does not support fno-schedule-insns + ifeq ($(findstring clang, $(CXX)),) + CFLAGS += -fno-schedule-insns + CXXFLAGS += -fno-schedule-insns + endif + ifneq ($(OSTYPE),mac) CFLAGS += -minline-all-stringops endif @@ -73,8 +80,8 @@ ifdef PROFILE endif endif -CFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS) -CXXFLAGS += -Wall -W -Wcast-qual -Wpointer-arith -Wcast-align $(OS_INC) $(OS_OPT) $(FLAGS) +CFLAGS += -Wall -Wextra -Wcast-qual -Wpointer-arith -Wcast-align -Wstrict-prototypes $(OS_INC) $(OS_OPT) $(FLAGS) +CXXFLAGS += -Wall -Wextra -Wcast-qual -Wpointer-arith -Wcast-align $(OS_INC) $(OS_OPT) $(FLAGS) # SOLO_SOURCES contains files which are unique to nettool; # SHARED_SOURCES contains those with the exact same object code in nettool and simutrans; diff --git uncommon.mk uncommon.mk index 68227e8df..f3db3256f 100644 --- uncommon.mk +++ uncommon.mk @@ -10,10 +10,12 @@ OBJS += $(patsubst %, $(BUILDDIR)/$(TOOL)/%-$(TOOL).o, $(basename $(filter-out . DEPS := $(patsubst %.o, %.d, $(OBJS)) DIRS := $(sort $(dir $(OBJS))) +BUILDCONFIG_FILES := ../uncommon.mk Makefile ../config.$(CFG) + # Make build directories DUMMY := $(shell mkdir -p $(DIRS)) -.PHONY: clean clean-prog +.PHONY: all clean clean-prog ifeq ($(VERBOSE),) Q = @ @@ -43,19 +45,19 @@ clean: @true # Source files located in ../ -$(BUILDDIR)/%-$(TOOL).o: ../%.c +$(BUILDDIR)/%-$(TOOL).o: ../%.c $(BUILDCONFIG_FILES) @echo "===> CC $<" $(Q)$(CC) $(CCFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/%-$(TOOL).o: ../%.cc +$(BUILDDIR)/%-$(TOOL).o: ../%.cc $(BUILDCONFIG_FILES) @echo "===> CXX $<" $(Q)$(CXX) $(CXXFLAGS) -c -MMD -o $@ $< # Source files located in current directory -$(BUILDDIR)/$(TOOL)/%-$(TOOL).o: %.c +$(BUILDDIR)/$(TOOL)/%-$(TOOL).o: %.c $(BUILDCONFIG_FILES) @echo "===> CC $<" $(Q)$(CC) $(CCFLAGS) -c -MMD -o $@ $< -$(BUILDDIR)/$(TOOL)/%-$(TOOL).o: %.cc +$(BUILDDIR)/$(TOOL)/%-$(TOOL).o: %.cc $(BUILDCONFIG_FILES) @echo "===> CXX $<" $(Q)$(CXX) $(CXXFLAGS) -c -MMD -o $@ $<