quickjs-tart

quickjs-based runtime for wallet-core logic
Log | Files | Refs | README | LICENSE

Makefile (7889B)


      1 DESTDIR=/usr/local
      2 PREFIX=mbedtls_
      3 PERL ?= perl
      4 
      5 ifneq (,$(filter-out lib library/%,$(or $(MAKECMDGOALS),all)))
      6     ifeq (,$(wildcard framework/exported.make))
      7         # Use the define keyword to get a multi-line message.
      8         # GNU make appends ".  Stop.", so tweak the ending of our message accordingly.
      9         ifneq (,$(wildcard .git))
     10             define error_message
     11 ${MBEDTLS_PATH}/framework/exported.make not found (and does appear to be a git checkout). Run `git submodule update --init` from the source tree to fetch the submodule contents.
     12 This is a fatal error
     13             endef
     14         else
     15             define error_message
     16 ${MBEDTLS_PATH}/framework/exported.make not found (and does not appear to be a git checkout). Please ensure you have downloaded the right archive from the release page on GitHub.
     17             endef
     18         endif
     19         $(error $(error_message))
     20     endif
     21     include framework/exported.make
     22 endif
     23 
     24 .SILENT:
     25 
     26 .PHONY: all no_test programs lib tests install uninstall clean test check lcov apidoc apidoc_clean
     27 
     28 all: programs tests
     29 	$(MAKE) post_build
     30 
     31 no_test: programs
     32 
     33 programs: lib mbedtls_test
     34 	$(MAKE) -C programs
     35 
     36 ssl-opt: lib mbedtls_test
     37 	$(MAKE) -C programs ssl-opt
     38 	$(MAKE) -C tests ssl-opt
     39 
     40 lib:
     41 	$(MAKE) -C library
     42 
     43 tests: lib mbedtls_test
     44 	$(MAKE) -C tests
     45 
     46 mbedtls_test:
     47 	$(MAKE) -C tests mbedtls_test
     48 
     49 .PHONY: FORCE
     50 FORCE:
     51 
     52 library/%: FORCE
     53 	$(MAKE) -C library $*
     54 programs/%: FORCE
     55 	$(MAKE) -C programs $*
     56 tests/%: FORCE
     57 	$(MAKE) -C tests $*
     58 
     59 .PHONY: generated_files
     60 generated_files: library/generated_files
     61 generated_files: programs/generated_files
     62 generated_files: tests/generated_files
     63 generated_files: visualc_files
     64 
     65 # Set GEN_FILES to the empty string to disable dependencies on generated
     66 # source files. Then `make generated_files` will only build files that
     67 # are missing, it will not rebuilt files that are present but out of date.
     68 # This is useful, for example, if you have a source tree where
     69 # `make generated_files` has already run and file timestamps reflect the
     70 # time the files were copied or extracted, and you are now in an environment
     71 # that lacks some of the necessary tools to re-generate the files.
     72 # If $(GEN_FILES) is non-empty, the generated source files' dependencies
     73 # are treated ordinarily, based on file timestamps.
     74 GEN_FILES ?=
     75 
     76 # In dependencies where the target is a configuration-independent generated
     77 # file, use `TARGET: $(gen_file_dep) DEPENDENCY1 DEPENDENCY2 ...`
     78 # rather than directly `TARGET: DEPENDENCY1 DEPENDENCY2 ...`. This
     79 # enables the re-generation to be turned off when GEN_FILES is disabled.
     80 ifdef GEN_FILES
     81 gen_file_dep =
     82 else
     83 # Order-only dependency: generate the target if it's absent, but don't
     84 # re-generate it if it's present but older than its dependencies.
     85 gen_file_dep = |
     86 endif
     87 
     88 .PHONY: visualc_files
     89 VISUALC_FILES = visualc/VS2017/mbedTLS.sln visualc/VS2017/mbedTLS.vcxproj
     90 # TODO: $(app).vcxproj for each $(app) in programs/
     91 visualc_files: $(VISUALC_FILES)
     92 
     93 # Ensure that the .c files that generate_visualc_files.pl enumerates are
     94 # present before it runs. It doesn't matter if the files aren't up-to-date,
     95 # they just need to be present.
     96 $(VISUALC_FILES): | library/generated_files
     97 $(VISUALC_FILES): | programs/generated_files
     98 $(VISUALC_FILES): | tests/generated_files
     99 $(VISUALC_FILES): $(gen_file_dep) scripts/generate_visualc_files.pl
    100 $(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-app-template.vcxproj
    101 $(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-main-template.vcxproj
    102 $(VISUALC_FILES): $(gen_file_dep) scripts/data_files/vs2017-sln-template.sln
    103 # TODO: also the list of .c and .h source files, but not their content
    104 $(VISUALC_FILES):
    105 	echo "  Gen   $@ ..."
    106 	$(PERL) scripts/generate_visualc_files.pl
    107 
    108 ifndef WINDOWS
    109 install: no_test
    110 	mkdir -p $(DESTDIR)/include/mbedtls
    111 	cp -rp include/mbedtls $(DESTDIR)/include
    112 	mkdir -p $(DESTDIR)/include/psa
    113 	cp -rp include/psa $(DESTDIR)/include
    114 
    115 	mkdir -p $(DESTDIR)/lib
    116 	cp -RP library/libmbedtls.*    $(DESTDIR)/lib
    117 	cp -RP library/libmbedx509.*   $(DESTDIR)/lib
    118 	cp -RP library/libmbedcrypto.* $(DESTDIR)/lib
    119 
    120 	mkdir -p $(DESTDIR)/bin
    121 	for p in programs/*/* ; do              \
    122 	    if [ -x $$p ] && [ ! -d $$p ] ;     \
    123 	    then                                \
    124 	        f=$(PREFIX)`basename $$p` ;     \
    125 	        cp $$p $(DESTDIR)/bin/$$f ;     \
    126 	    fi                                  \
    127 	done
    128 
    129 uninstall:
    130 	rm -rf $(DESTDIR)/include/mbedtls
    131 	rm -rf $(DESTDIR)/include/psa
    132 	rm -f $(DESTDIR)/lib/libmbedtls.*
    133 	rm -f $(DESTDIR)/lib/libmbedx509.*
    134 	rm -f $(DESTDIR)/lib/libmbedcrypto.*
    135 
    136 	for p in programs/*/* ; do              \
    137 	    if [ -x $$p ] && [ ! -d $$p ] ;     \
    138 	    then                                \
    139 	        f=$(PREFIX)`basename $$p` ;     \
    140 	        rm -f $(DESTDIR)/bin/$$f ;      \
    141 	    fi                                  \
    142 	done
    143 endif
    144 
    145 
    146 WARNING_BORDER_LONG      =**********************************************************************************\n
    147 CTR_DRBG_128_BIT_KEY_WARN_L1=****  WARNING!  MBEDTLS_CTR_DRBG_USE_128_BIT_KEY defined!                      ****\n
    148 CTR_DRBG_128_BIT_KEY_WARN_L2=****  Using 128-bit keys for CTR_DRBG limits the security of generated         ****\n
    149 CTR_DRBG_128_BIT_KEY_WARN_L3=****  keys and operations that use random values generated to 128-bit security ****\n
    150 
    151 CTR_DRBG_128_BIT_KEY_WARNING=\n$(WARNING_BORDER_LONG)$(CTR_DRBG_128_BIT_KEY_WARN_L1)$(CTR_DRBG_128_BIT_KEY_WARN_L2)$(CTR_DRBG_128_BIT_KEY_WARN_L3)$(WARNING_BORDER_LONG)
    152 
    153 # Post build steps
    154 post_build:
    155 ifndef WINDOWS
    156 
    157 	# If 128-bit keys are configured for CTR_DRBG, display an appropriate warning
    158 	-scripts/config.py get MBEDTLS_CTR_DRBG_USE_128_BIT_KEY && ([ $$? -eq 0 ]) && \
    159 	    echo '$(CTR_DRBG_128_BIT_KEY_WARNING)'
    160 
    161 endif
    162 
    163 clean: clean_more_on_top
    164 	$(MAKE) -C library clean
    165 	$(MAKE) -C programs clean
    166 	$(MAKE) -C tests clean
    167 
    168 clean_more_on_top:
    169 ifndef WINDOWS
    170 	find . \( -name \*.gcno -o -name \*.gcda -o -name \*.info \) -exec rm {} +
    171 endif
    172 
    173 neat: clean_more_on_top
    174 	$(MAKE) -C library neat
    175 	$(MAKE) -C programs neat
    176 	$(MAKE) -C tests neat
    177 ifndef WINDOWS
    178 	rm -f visualc/VS2017/*.vcxproj visualc/VS2017/mbedTLS.sln
    179 else
    180 	if exist visualc\VS2017\*.vcxproj del /Q /F visualc\VS2017\*.vcxproj
    181 	if exist visualc\VS2017\mbedTLS.sln del /Q /F visualc\VS2017\mbedTLS.sln
    182 endif
    183 
    184 check: lib tests
    185 	$(MAKE) -C tests check
    186 
    187 test: check
    188 
    189 ifndef WINDOWS
    190 # For coverage testing:
    191 # 1. Build with:
    192 #         make CFLAGS='--coverage -g3 -O0' LDFLAGS='--coverage'
    193 # 2. Run the relevant tests for the part of the code you're interested in.
    194 #    For the reference coverage measurement, see
    195 #    tests/scripts/basic-build-test.sh
    196 # 3. Run scripts/lcov.sh to generate an HTML report.
    197 lcov:
    198 	scripts/lcov.sh
    199 
    200 apidoc:
    201 	mkdir -p apidoc
    202 	cd doxygen && doxygen mbedtls.doxyfile
    203 
    204 apidoc_clean:
    205 	rm -rf apidoc
    206 endif
    207 
    208 ## Editor navigation files
    209 C_SOURCE_FILES = $(wildcard \
    210 	3rdparty/*/include/*/*.h 3rdparty/*/include/*/*/*.h 3rdparty/*/include/*/*/*/*.h \
    211 	3rdparty/*/*.c 3rdparty/*/*/*.c 3rdparty/*/*/*/*.c 3rdparty/*/*/*/*/*.c \
    212 	include/*/*.h \
    213 	library/*.[hc] \
    214 	programs/*/*.[hc] \
    215 	framework/tests/include/*/*.h framework/tests/include/*/*/*.h \
    216 	framework/tests/src/*.c framework/tests/src/*/*.c \
    217 	tests/suites/*.function \
    218 )
    219 # Exuberant-ctags invocation. Other ctags implementations may require different options.
    220 CTAGS = ctags --langmap=c:+.h.function --line-directives=no -o
    221 tags: $(C_SOURCE_FILES)
    222 	$(CTAGS) $@ $(C_SOURCE_FILES)
    223 TAGS: $(C_SOURCE_FILES)
    224 	etags --no-line-directive -o $@ $(C_SOURCE_FILES)
    225 global: GPATH GRTAGS GSYMS GTAGS
    226 GPATH GRTAGS GSYMS GTAGS: $(C_SOURCE_FILES)
    227 	ls $(C_SOURCE_FILES) | gtags -f - --gtagsconf .globalrc
    228 cscope: cscope.in.out cscope.po.out cscope.out
    229 cscope.in.out cscope.po.out cscope.out: $(C_SOURCE_FILES)
    230 	cscope -bq -u -Iinclude -Ilibrary $(patsubst %,-I%,$(wildcard 3rdparty/*/include)) -Iframework/tests/include $(C_SOURCE_FILES)
    231 .PHONY: cscope global