1 ################################################################################
2 # Desc: Web Cross Compiler
5 ################################################################################
6 # This makefile manages a build environment targeting native platforms with gcc
7 # and web platforms with either emscripten or binaryen (js or wasm).
8 ################################################################################
9 # Each .c file is automatically compiled into an environment-dependent object
10 # file of compiler-specific format (.o for gcc, .bc for llvm/emcc/em++).
11 ################################################################################
14 # source directory to find compilable language files in
15 SRC_DIR
:= $(ROOT_DIR
)/src
16 # directory where files with 'main' functions live (can be in SRC_DIR)
17 DRIVER_DIR
:= $(SRC_DIR
)/bin
18 # make configuration directory
19 CONF_DIR
:= $(ROOT_DIR
)/make
20 # include initialization variables
21 include $(CONF_DIR
)/init.mk
22 # Include the make libraries
23 include $(CONF_DIR
)/lib
/*.mk
25 # The default rule to be built if none specified
28 # If available, invoke the premake system
29 ifdef PREMAKE_SOURCE_COMPILER
30 $(eval
$(call PREMAKE_SOURCE_COMPILER
,))
32 $(info No premake system found
, source-to-source languages
(e.g. ragel
) not functional
)
35 # Backup the CVS password and CVSROOT environment vars in case we change them
36 # during lib downloading
37 $(if
$(wildcard ~
/.cvspass
),\
38 $(eval CVSPASS_BAK
:= $(file
<~
/.cvspass
)))
40 $(eval CVSROOT_BAK
:= $(CVSROOT
)))
42 # Initialize each language, look for its source files, and generate rules
44 $(foreach lang
,$(LANGS
),\
45 $(eval
$(call LANG_INIT
,$(lang
)))\
48 $(error No LANG_INIT available
, no languages can be compiled
)
51 # Create module object rules for each module
52 $(foreach module
,$(MODULES
),\
53 $(eval
$(call MODULE_ARCRULE
,$(module
)))\
55 $(if
$(c_DBG
),$(eval MAKE_DIRS
+= .
$(c_DBG
)/))
57 # Create lang-specific rules for producing final (linked) targets
58 $(foreach lang
,$(LANGS
),\
59 $(foreach drvsrc
,$($(lang
)_DRV_SRC
),\
60 $(eval
$(call SRC_LANG_DRVRULE
,$(drvsrc
),$(lang
)))\
63 # Create driver rules for each driver we found, let users call make specifying
64 # the basename of the driver file, and just route to the correct linking rule
65 $(foreach drvsrc
,$(DRV_SRC
),\
66 $(eval
$(call DRVSRC_DRIVERPHONY
,$(drvsrc
)))\
72 # Rule to make any dirs that we're in charge of
77 # Clean destroys all object files and internal module archives.
78 CLEAN_TARGETS
:= $(sort $(foreach mtarg
,$(MAKE_TARGETS
),$(if
$(wildcard $(mtarg
)),$(mtarg
))))
79 clean: $(BUILTLIBS
:%=clean_
%)
80 $(if
$(CLEAN_TARGETS
),rm $(CLEAN_TARGETS
))
82 # Scrub destroys all distributable binaries
83 SCRUB_TARGETS
:= $(sort $(foreach starg
,$(SCRUB_TARGETS
),$(if
$(wildcard $(starg
)),$(starg
))))
85 $(if
$(SCRUB_TARGETS
),rm $(SCRUB_TARGETS
))
87 # Purge destroys all distributables created by a distributable binary
90 # Uninstall destroys all objects and directories that can be recreated by this