DEPTH = . SUBDIR = . # for Windows under Linux: # export OSTYPE=Linux_to_Windows include $(DEPTH)/Makefile.os -include Makefile.objects DIRECTORIES = party game player card misc ui os class utils text OBJECTS_ALL = $(OBJECTS) \ $(OBJECTS_PARTY) $(OBJECTS_GAME) $(OBJECTS_PLAYER) \ $(OBJECTS_CARD) $(OBJECTS_MISC) \ $(OBJECTS_UI) $(OBJECTS_OS) \ $(OBJECTS_CLASS) $(OBJECTS_UTILS) INCLUDE_ALL = $(INCLUDE) LIBS_ALL = $(LIBS) -lm ifeq ($(USE_UI_GTKMM), true) OBJECTS_ALL += $(OBJECTS_GTKMM) INCLUDE_ALL += $(INCLUDE_GTKMM) LIBS_ALL += $(LIBS_GTKMM) endif ifeq ($(USE_SOUND), true) DIRECTORIES += sound OBJECTS_ALL += $(OBJECTS_SOUND) INCLUDE_ALL += $(INCLUDE_SOUND) LIBS_ALL += $(LIBS_SOUND) endif ifeq ($(USE_NETWORK), true) DIRECTORIES += network OBJECTS_ALL += $(OBJECTS_NETWORK) INCLUDE_ALL += $(INCLUDE_NETWORK) LIBS_ALL += $(LIBS_NETWORK) endif # check the environment and compile the program .PHONY: all all : Makefile.local logo.png $(MAKE) check $(MAKE) $(PROGNAME) # create the file 'Makefile.local' from the template Makefile.local: ifeq ($(SHELLTYPE), sh) cp Makefile.local.template $@ endif ifeq ($(SHELLTYPE), COMMAND.COM) copy Makefile.local.template $@ endif # create the logo from the free one logo.png: ifeq ($(SHELLTYPE), sh) cp logo.free.png $@ endif ifeq ($(SHELLTYPE), COMMAND.COM) copy logo.free.png $@ endif # print the targets of this makefile .PHONY: help help : @echo "make targets" @echo " all check the environment and compile the program" @echo " help print the targests of this makefile" @echo " check check the os and the libraries" @echo " os_check check, whether the ostype was detected correctly" @echo " libraries_check "check, whether the needed libraries are installed @echo " watch automatic compile FreeDoko if a *.cpp-file has changed" @echo " seed.out create a file with the gametype for the different seeds" @echo " show_settings show all settings (environment, modules, flags)" @echo " show_environment show the environment settings" @echo " show_modules show the modules" @echo " show_flags show the flags used for compiling" @echo " FreeDoko compile FreeDoko" @echo " release_bin compile FreeDoko for a release" @echo " one_compile create one file and compile the program (does not work)" @echo " fast compile FreeDoko with three processes at once (like '-j 3')" @echo " strip strip the program from all symbols" @echo " objects compile all cpp files in this directoriy" @echo " doc create api overview" @echo " tags create a tags file" @$(MAKE) -s rules_help # check the os and the libraries .PHONY: check check : os_check libraries_check # check, whether the ostype was detected correctly .PHONY: os_check os_check : ifeq ($(OPERATING_SYSTEM), Windows) ifneq ($(OSTYPE), Cygwin) @REM \ ; (echo -e \\n\ "***** Error *****\\n"\ "If you see these lines, the operating system was not detected correctly.\\n"\ "Detected operating system: $(OPERATING_SYSTEM)\\n"\ "Try an 'export OSTYPE' before compiling.\\n"\ && false) endif else @# echo "***** Error ***** If you see this line, the operating system was not detected correctly. Detected operating system: $(OPERATING_SYSTEM)" endif # check, whether the needed libraries are installed # till now only supports 'pkg-config', t.i. unix systems .PHONY: libraries_check libraries_check : ifeq ($(SHELLTYPE), sh) ifeq ($(USE_UI_GTKMM), true) @pkg-config --exists gtkmm-2.4 \ || (echo "gtkmm 2.4 (user interface) is not found."; \ export problem=true) endif ifeq ($(USE_NETWORK), true) @pkg-config --exists glib-2.0 \ || echo "glib 2.0 (needed for gnet) is not found." @pkg-config --exists gnet-2.0 \ || echo "gnet 2.0 (network library) is not found." endif endif ifeq ($(SHELLTYPE), COMMAND.COM) # ToDo endif # automatic compile FreeDoko if a *.cpp-file has changed # uses program 'auto_execute' (write to dknof@gmx.de) .PHONY: watch watch : # Does not work, too many files? # auto_execute -e 'nice make -k' `find . -name "*.cpp" -o -name "*.h"` rm -f commands.sh echo '#!/bin/bash' >> commands.sh echo 'if [ -e ./FreeDoko ]; then' >> commands.sh echo ' for f in $$(find . -name "*.cpp"); do' >> commands.sh echo ' if [ $$f -nt ./FreeDoko ]; then rm ./FreeDoko; break; fi' >> commands.sh echo ' done' >> commands.sh echo 'fi' >> commands.sh echo 'nice -n 5 make -s -k' >> commands.sh auto_execute -e 'bash ./commands.sh' `find . -name "*.cpp"` rm -f commands.sh # create a file with the gametype for the different seeds # The program must be prepared (in 'constants.cpp') seed.out : $(PROGNAME) ./$(PROGNAME) > seed.out # show the settings .PHONY: show_settings show_settings : show_environment show_modules show_flags # show the environment .PHONY: show_environment show_environment : @echo 'Environment' @echo ' OPERATING_SYSTEM : $(OPERATING_SYSTEM)' @echo ' OPERATING_SYSTEM_NAME : $(OPERATING_SYSTEM_NAME)' @echo ' SHELLTYPE : $(SHELLTYPE)' ifneq ($(MINGW_DIR),) @echo ' MINGW_DIR : $(MINGW_DIR)' endif @echo ' PROGNAME : $(PROGNAME)' @echo ' FREEDOKO_WORKING_DIRECTORY : $(FREEDOKO_WORKING_DIRECTORY)' # show the modules used .PHONY: show_modules show_modules : @echo 'Modules' @echo ' USE_UI_TEXT : $(USE_UI_TEXT)' @echo ' USE_UI_GTKMM : $(USE_UI_GTKMM)' @echo ' USE_SOUND : $(USE_SOUND)' @echo ' USE_SOUND_ALUT : $(USE_SOUND_ALUT)' @echo ' USE_SOUND_APLAY : $(USE_SOUND_APLAY)' @echo ' USE_NETWORK : $(USE_NETWORK)' # show the flags used for compiling .PHONY: show_flags show_flags : @echo 'Flags' @echo ' CXX : $(CXX)' @echo ' CPPFLAGS : $(CPPFLAGS)' @echo ' CXXFLAGS : $(CXXFLAGS)' @echo ' INCLUDE : $(INCLUDE_ALL)' @echo ' LIBS : $(LIBS_ALL)' # compile FreeDoko $(PROGNAME) : show_settings objects $(DIRECTORIES) @echo "compiling $(PROGNAME)..." # Gentoo users do want to see the real compile line. # So remove the next five lines (the echo lines) # and remove the '@' in the line after. @echo '$(CXX) $(CXXFLAGS)' @echo ' $$(OBJECTS)' @echo ' $(INCLUDE_ALL)' @echo ' $(LIBS_ALL)' @echo ' -o $@' @$(CXX) $(CXXFLAGS) \ $(OBJECTS_ALL:%.o=$(FREEDOKO_WORKING_DIRECTORY)/%.o) \ $(INCLUDE_ALL) \ $(LIBS_ALL) \ -o $@ @echo "$(PROGNAME) compiled successfully" # compile FreeDoko for a release .PHONY: release_bin release_bin : Makefile.local logo.png $(MAKE) \ "USE_UI_TEXT=false" \ "USE_UI_GTKMM=true" \ "USE_NETWORK=true" \ "CXXFLAGS=-Wall -Werror -pipe -O2" \ "CPPFLAGS=-DRELEASE -DVERSION_DESCRIPTION='\"$(OPERATING_SYSTEM_NAME) binary\"'" \ $(PROGNAME) # test code, does not work # Create one file and compile from it the program. # Use this in order to test package creating # (this uses less time than compiling all files one for one) .PHONY: one_compile one_compile : show_settings @echo "compiling $(PROGNAME)..." # Gentoo users do want to see the real compile line. # So remove the following echo lines # and remove the '@' in the lines after. @echo '$(CXX) $(CPPFLAGS)' @echo ' $$(OBJECTS).cpp' @echo ' $(INCLUDE_ALL)' @echo ' -E -o $(PROGNAME).ii' @$(CXX) $(CPPFLAGS) \ $(patsubst %.o,%.cpp,$(OBJECTS_ALL)) \ $(INCLUDE_ALL) \ -E > FreeDoko.ii @echo '$(CXX) $(CXXFLAGS)' @echo ' -c $(PROGNAME).ii' # errors @$(CXX) $(CXXFLAGS) -c -x c++-cpp-output $(PROGNAME).ii # $(LIBS_ALL) #-o $(PROGNAME) @echo '$(CXX) $(LIBS_ALL)' @echo ' $(PROGNAME).o' @echo ' -o $(PROGNAME)' @$(CXX) $(LIBS_ALL) $(PROGNAME).o -o $(PROGNAME) @echo "$(PROGNAME) compiled successfully" # compile FreeDoko with three processes at once (like '-j 3') ifeq ($(SHELLTYPE), sh) .PHONY: fast fast : nice $(MAKE) -k -C ui & ( nice $(MAKE) -k -C party; \ nice $(MAKE) -k -C game; \ nice $(MAKE) -k -C card ) & ( nice $(MAKE) -k -C player; \ nice $(MAKE) -k objects; \ nice $(MAKE) -k -C misc; \ nice $(MAKE) -k -C os; \ nice $(MAKE) -k -C class; \ nice $(MAKE) -k -C utils ) endif # strip the program from all symbols .PHONY: strip strip : $(STRIP) $(PROGNAME) # create api overview # uses doxygen # bug: does not create all documentation, since doxygen has problem with two different files with the same name ifeq ($(OPERATING_SYSTEM), Linux) .PHONY : doc doc : doxygen # create a tags file .PHONY : tags tags : ctags -R endif include $(DEPTH)/Makefile.subdir include $(DEPTH)/Makefile.rules