libk  arch.makefile at [12a51d9c50]

File legacy/arch.makefile artifact ce87fe2fb7 part of check-in 12a51d9c50


ifeq (${OS},lin)
    p-headers-syscall ?= /usr/include/asm/unistd_${BITS}.h
    p-headers-errno ?= /usr/include/asm-generic/errno.h /usr/include/asm-generic/errno-base.h
else ifeq (${OS},fbsd)
    p-headers-syscall ?= /usr/include/sys/syscall.h
    p-headers-errno ?= /usr/include/errno.h
else
    $(info we don’t know where to find your magic number headers.)
    $(info to compile libk, please provide the following variables \
to the make command line:)
    $(info --- p-headers-syscall=(location of syscall header))
    $(info --- p-headers-errno=(location of your errno values header))
    $(info note that /usr/include/errno.h or your system’s equivalent \
may not be sufficient. make sure the file you pass actually contains \
individual #define statements for each possible value of errno!)
    $(error table generation failed due to missing primaries)
endif

${TMP}:
	mkdir -p ${TMP}

${TMP}/calls.lin@x86.%.tbl: $(p-headers-syscall) 
	mkdir -p ${TMP}
	grep -h "#define __NR_" $^ | sed 's;^#define __NR_;;' > $@
${TMP}/calls.fbsd@%.tbl: $(p-headers-syscall) 
	mkdir -p ${TMP}
	grep -h "#define	SYS_" $^ | sed 's;^#define	SYS_;;' | sed 's;[\t ]\+; ;' > $@

${TMP}/system_calls.%: ${TMP}/calls.${OS}@${ARCH}.${BITS}.tbl ${TMP}
	awk -f syscall.awk -v out=$* <$< >$@

${TMP}/error_names.tbl: $(p-headers-errno)
	mkdir -p ${TMP}
	grep -h "#[	 ]*define[ 	]\+E" $^ | sed 's;^#[\t ]*define[\t ]\+\(E[A-Z0-9]\+\).*$$;k_platform_error_\1 \1;' > $@
${TMP}/error_numbers.tbl: $(p-headers-errno) ${TMP}/error_names.tbl
	cat $^ | cpp -P >$@

${TMP}/error_table.h: ${TMP}/error_numbers.tbl ${TMP}
	awk -f errtbl.awk <$< >$@

${TMP}/typesize: typesize.c ${TMP}
	$(CC) -std=c11 $< -o $@
${TMP}/typesize.def: ${TMP}/typesize ${TMP}
	$< > $@