# $Id: Makefile.kmk 778 2007-01-21 00:29:17Z bird $ DEPTH = ../.. include $(PATH_KBUILD)/header.kmk # # kmk # PROGRAMS += kmk kmk_TEMPLATE = BIN kmk_DEPS = $(PATH_TARGET)/config.h kmk_INCS = $(PATH_TARGET) . kmk_INCS.darwin = glob kmk_INCS.freebsd = glob #ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) #kmk_INCS += kmkbuiltin/w32 #endif kmk_DEFS = \ HAVE_CONFIG_H \ NO_ARCHIVES \ CONFIG_NO_DEFAULT_SUFFIXES \ CONFIG_NO_DEFAULT_PATTERN_RULES \ CONFIG_NO_DEFAULT_TERMINAL_RULES \ CONFIG_NO_DEFAULT_SUFFIX_RULES \ CONFIG_NO_DEFAULT_VARIABLES \ CONFIG_WITH_EXTENDED_NOTPARALLEL \ CONFIG_WITH_INCLUDEDEP \ CONFIG_WITH_TOUPPER_TOLOWER \ CONFIG_WITH_ABSPATHEX \ CONFIG_PRETTY_COMMAND_PRINTING \ KMK \ \ KMK_HELPERS \ VARIABLE_HASH \ CONFIG_WITH_OPTIMIZATION_HACKS \ CONFIG_WITH_VALUE_LENGTH \ CONFIG_WITH_COMPARE \ CONFIG_WITH_STACK \ CONFIG_WITH_MATH \ EXPERIMENTAL \ \ BUILD_PLATFORM=\"$(BUILD_TARGET)\" \ BUILD_PLATFORM_ARCH=\"$(BUILD_TARGET_ARCH)\" \ BUILD_PLATFORM_CPU=\"$(BUILD_TARGET_CPU)\" kmk_DEFS.win = CONFIG_NEW_WIN32_CTRL_EVENT kmk_SOURCES = \ main.c \ read.c \ hash.c \ strcache.c \ variable.c \ ar.c \ arscan.c \ commands.c \ default.c \ dir.c \ expand.c \ file.c \ function.c \ implicit.c \ job.c \ misc.c \ remake.c \ rule.c \ signame.c \ version.c \ vpath.c \ remote-stub.c \ kbuild.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_SOURCES += \ getopt.c \ getopt1.c \ getloadavg.c \ w32/subproc/misc.c \ w32/subproc/sub_proc.c \ w32/subproc/w32err.c \ glob/glob.c \ glob/fnmatch.c \ w32/compat/dirent.c \ w32/pathstuff.c endif kmk_SOURCES.freebsd = \ glob/glob.c \ glob/fnmatch.c kmk_SOURCES.darwin = \ glob/glob.c \ glob/fnmatch.c # # kmkbuiltin commands # kmk_DEFS += CONFIG_WITH_KMK_BUILTIN kmk_SOURCES += \ kmkbuiltin.c \ kmkbuiltin/append.c \ kmkbuiltin/cat.c \ kmkbuiltin/cp.c \ kmkbuiltin/cp_utils.c \ kmkbuiltin/echo.c \ kmkbuiltin/install.c \ kmkbuiltin/mkdir.c \ kmkbuiltin/mv.c \ kmkbuiltin/ln.c \ kmkbuiltin/printf.c \ kmkbuiltin/rm.c \ kmkbuiltin/rmdir.c \ \ kmkbuiltin/err.c \ kmkbuiltin/setmode.c \ kmkbuiltin/strmode.c \ kmkbuiltin/strlcpy.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_SOURCES += \ kmkbuiltin/mscfakes.c \ kmkbuiltin/fts.c endif kmk_SOURCES.darwin += \ kmkbuiltin/darwin.c # # Standalone kmkbuiltin commands. # PROGRAMS += kmk_append kmk_cat kmk_cp kmk_echo kmk_mkdir kmk_mv kmk_install kmk_ln kmk_printf kmk_rm kmk_rmdir kmk_append_TEMPLATE = BIN kmk_append_DEFS = kmk_builtin_append=main kmk_append_INCS = . kmk_append_SOURCES = \ kmkbuiltin/append.c \ kmkbuiltin/err.c kmk_cat_TEMPLATE = BIN kmk_cat_DEFS = kmk_builtin_cat=main kmk_cat_SOURCES = \ kmkbuiltin/cat.c \ kmkbuiltin/err.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_cat_INCS += $(PATH_TARGET) . kmk_cat_DEFS += HAVE_CONFIG_H kmk_cat_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif kmk_cp_TEMPLATE = BIN kmk_cp_DEFS = kmk_builtin_cp=main kmk_cp_SOURCES = \ kmkbuiltin/cp.c \ kmkbuiltin/cp_utils.c \ kmkbuiltin/strlcpy.c \ kmkbuiltin/err.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_cp_INCS += $(PATH_TARGET) . kmk_cp_DEFS += HAVE_CONFIG_H kmk_cp_SOURCES += \ kmkbuiltin/mscfakes.c \ kmkbuiltin/fts.c \ w32/compat/dirent.c \ getopt.c \ getopt1.c endif kmk_cp_SOURCES.darwin = \ kmkbuiltin/darwin.c kmk_echo_TEMPLATE = BIN kmk_echo_DEFS = kmk_builtin_echo=main kmk_echo_SOURCES = \ kmkbuiltin/echo.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_echo_SOURCES += \ kmkbuiltin/mscfakes.c \ kmkbuiltin/err.c endif kmk_install_TEMPLATE = BIN kmk_install_DEFS = kmk_builtin_install=main kmk_install_SOURCES = \ kmkbuiltin/install.c \ kmkbuiltin/err.c \ kmkbuiltin/strmode.c \ kmkbuiltin/setmode.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_install_INCS += $(PATH_TARGET) . kmk_install_DEFS += HAVE_CONFIG_H kmk_install_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif kmk_ln_TEMPLATE = BIN kmk_ln_DEFS = kmk_builtin_ln=main kmk_ln_SOURCES = \ kmkbuiltin/ln.c \ kmkbuiltin/err.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_ln_INCS += $(PATH_TARGET) . kmk_ln_DEFS += HAVE_CONFIG_H kmk_ln_SOURCES += \ kmkbuiltin/mscfakes.c\ getopt.c \ getopt1.c endif kmk_mkdir_TEMPLATE = BIN kmk_mkdir_DEFS = kmk_builtin_mkdir=main kmk_mkdir_SOURCES = \ kmkbuiltin/mkdir.c \ kmkbuiltin/err.c \ kmkbuiltin/setmode.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_mkdir_INCS += $(PATH_TARGET) . kmk_mkdir_DEFS += HAVE_CONFIG_H kmk_mkdir_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif kmk_mv_TEMPLATE = BIN kmk_mv_DEFS = kmk_builtin_mv=main kmk_mv_SOURCES = \ kmkbuiltin/mv.c \ kmkbuiltin/err.c \ kmkbuiltin/strmode.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_mv_INCS += $(PATH_TARGET) . kmk_mv_DEFS += HAVE_CONFIG_H kmk_mv_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif kmk_printf_TEMPLATE = BIN kmk_printf_DEFS = kmk_builtin_printf=main kmk_printf_SOURCES = \ kmkbuiltin/printf.c \ kmkbuiltin/err.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_printf_INCS += $(PATH_TARGET) . kmk_printf_DEFS += HAVE_CONFIG_H kmk_printf_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif kmk_rm_TEMPLATE = BIN kmk_rm_DEFS = kmk_builtin_rm=main kmk_rm_SOURCES = \ kmkbuiltin/rm.c \ kmkbuiltin/err.c \ kmkbuiltin/strmode.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_rm_INCS += $(PATH_TARGET) . kmk_rm_DEFS += HAVE_CONFIG_H kmk_rm_SOURCES += \ kmkbuiltin/mscfakes.c\ getopt.c \ getopt1.c endif kmk_rmdir_TEMPLATE = BIN kmk_rmdir_DEFS = kmk_builtin_rmdir=main kmk_rmdir_SOURCES = \ kmkbuiltin/rmdir.c \ kmkbuiltin/err.c \ kmkbuiltin/setmode.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_rmdir_INCS += $(PATH_TARGET) . kmk_rmdir_DEFS += HAVE_CONFIG_H kmk_rmdir_SOURCES += \ kmkbuiltin/mscfakes.c \ getopt.c \ getopt1.c endif # # kmk_gmake - almost plain GNU Make. # PROGRAMS += kmk_gmake kmk_gmake_TEMPLATE = BIN kmk_gmake_DEPS = $(PATH_TARGET)/config.h kmk_gmake_INCS = $(PATH_TARGET) . kmk_gmake_INCS.darwin = glob kmk_gmake_INCS.freebsd = glob kmk_gmake_DEFS = \ HAVE_CONFIG_H \ NO_ARCHIVES \ CONFIG_WITH_TOUPPER_TOLOWER \ EXPERIMENTAL kmk_gmake_SOURCES = \ main.c \ read.c \ hash.c \ strcache.c \ variable.c \ ar.c \ arscan.c \ commands.c \ default.c \ dir.c \ expand.c \ file.c \ function.c \ implicit.c \ job.c \ misc.c \ remake.c \ rule.c \ signame.c \ version.c \ vpath.c \ remote-stub.c ifeq ($(filter-out win32 win64 win nt,$(BUILD_TARGET)),) kmk_gmake_SOURCES += \ getopt.c \ getopt1.c \ getloadavg.c \ w32/subproc/misc.c \ w32/subproc/sub_proc.c \ w32/subproc/w32err.c \ glob/glob.c \ glob/fnmatch.c \ w32/compat/dirent.c \ w32/pathstuff.c endif kmk_gmake_SOURCES.freebsd = \ glob/glob.c \ glob/fnmatch.c kmk_gmake_SOURCES.darwin = \ glob/glob.c \ glob/fnmatch.c include $(PATH_KBUILD)/footer.kmk # # Use checked in config.h instead of running ./Configure for it. # config.h.$(BUILD_TARGET) := config.h.$(BUILD_TARGET) config.h.win := config.h.W32 config.h.win32 := config.h.W32 config.h.win64 := config.h.W32 config.h.nt := config.h.W32 $(PATH_TARGET)/config.h: $(config.h.$(BUILD_TARGET)) $(MKDIR) -p $(dir $@) $(CP) $^ $@ # # Some tests. # parallel: parallel_1 parallel_2 parallel_3 parallel_4 parallel_5 parallel_1 parallel_2 parallel_3 parallel_4 parallel_5: echo $@_start ; sleep 1; echo $@_done test: echo "1" echo "2" echo "3" echo "4" # # Shell execution tests. # test_shell: test_shell_quoting test_shell_double_quoting test_shell_newline # shell double and single quoting check (was busted on windows in 3.81). test_shell_quoting: $(ECHO_EXT) "double quoted sTrInG" $(ECHO_EXT) "double quoted sTrInG" | $(SED_EXT) -e "s/sTrInG/string/g" $(ECHO_EXT) 'single quoted sTrInG' | $(SED_EXT) -e 's/sTrInG/string/g' $(ECHO) "This string should not be printed with double quotes." $(ECHO) 'This string should not be printed with single quotes.' ( echo " #define PWD \"`pwd`\""; ) test_shell_double_quoting: $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \ "s/foo/$@/" -e \ "s/foo/works/" \ -e "s/foo/\!/" test_shell_double_quoting2: $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \ "s/foo/$@/" -e \ "s/foo/works/" \ -e\ "s/foo/\!/" # when using batch mode shell, the newline got escaped twice and spoiling everything. test_shell_newline: $(ECHO_EXT) "foo foo foo" | $(SED_EXT) -e \ 's/foo/$@/' -e \ 's/foo/works/' \ -e 's/foo/\!/' test_stack: $(MAKE) -f testcase-stack.kmk test_math: $(MAKE) -f testcase-math.kmk test_all: test_math test_stack test_shell