diff options
author | midipix <writeonce@midipix.org> | 2016-12-18 10:52:23 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-12-26 03:47:35 -0500 |
commit | e16d3bc96487787bcef61b08f7044c6b08ebe14f (patch) | |
tree | dd07bacb03066b7cfee91cee8d4163c76235fbe4 /project | |
parent | c832fd08bcbada09ea1f9e51ce8b6c223933803d (diff) | |
download | ptycon-e16d3bc96487787bcef61b08f7044c6b08ebe14f.tar.bz2 ptycon-e16d3bc96487787bcef61b08f7044c6b08ebe14f.tar.xz |
added clbuild-bat: a poor man's transitional clbuild command translator.
Diffstat (limited to 'project')
-rw-r--r-- | project/arch.mk | 4 | ||||
-rwxr-xr-x | project/clbuild.sh | 216 | ||||
-rw-r--r-- | project/extras.mk | 11 |
3 files changed, 231 insertions, 0 deletions
diff --git a/project/arch.mk b/project/arch.mk index f7089c6..14fb02d 100644 --- a/project/arch.mk +++ b/project/arch.mk @@ -3,3 +3,7 @@ src/internal/nolibc/ptyc_compiler.lo: $(PROJECT_DIR)/src/internal/nolibc/$(ARCH) src/internal/nolibc/ptyc_compiler.o: $(PROJECT_DIR)/src/internal/nolibc/$(ARCH)/ptyc_compiler.s host.tag tree.tag $(CC) -c -o $@ $< + +shared-objs-asm: src/internal/nolibc/ptyc_compiler.lo + +static-objs-asm: src/internal/nolibc/ptyc_compiler.o diff --git a/project/clbuild.sh b/project/clbuild.sh new file mode 100755 index 0000000..df796ca --- /dev/null +++ b/project/clbuild.sh @@ -0,0 +1,216 @@ +#!/bin/sh +# a poor man's universal driver (but stay tuned...) + +error_msg() +{ + echo $@ >&2 +} + +mb_cc= +mb_ar= +mb_source_dir= +mb_project_dir= +mb_sysroot= +version_header= +version_macro= +link_target= + +# one: args +for arg ; do + case "$arg" in + --help) usage + ;; + --cc=*) + mb_cc=${arg#*=} + ;; + --ar=*) + mb_ar=${arg#*=} + ;; + --source-dir=*) + mb_source_dir=${arg#*=} + ;; + --project-dir=*) + mb_project_dir=${arg#*=} + ;; + --sysroot=*) + mb_sysroot=${arg#*=} + ;; + --version-header=*) + version_header=${arg#*=} + ;; + --version-macro=*) + version_macro='-D'${arg#*=}'=\\\"unknown\\\"' + ;; + --link-target=*) + link_target=${arg#*=} + ;; + *) + error_msg ${arg#}: "unsupported config argument." + exit 2 + ;; + esac +done + +if [ -z "$mb_cc" ] || [ -z "$mb_ar" ] \ + || [ -z "$mb_source_dir" ] \ + || [ -z "$mb_project_dir" ]; then + usage +fi + +# two: clean +make -s clean || exit 1 + +# three: init +echo '@echo on' +echo '@dir . > nul' +echo +echo +echo 'REM override variables either here or from the shell' +echo 'set source_dir=%source_dir%' +echo 'set sysroot=%sysroot%' +echo +echo + +# four: build tree +cmd_abort_on_error='@if %errorlevel% neq 0 exit /b %errorlevel%' +sysroot_include_arg='-I%sysroot%/include' + +dirs=`make dirs.tag tree.tag \ + | grep -v 'make\[1\]:' \ + | grep -v 'touch dirs.tag' \ + | grep -v 'touch tree.tag' \ + | sed \ + -e 's/mkdir -p//g' \ + -e 's@/@\\\\@g'` + +for d in build $dirs; do + printf 'if not exist %-20smkdir %s\n' "$d" "$d" +done + +# version.tag +make version.tag > /dev/null + +echo +echo "type nul > build/$version_header" +echo +echo "$cmd_abort_on_error" +echo + +echo +echo "$cmd_abort_on_error" +echo + +# five: compile assembly sources +make shared-objs-asm static-objs-asm \ + | grep -v 'make\[1\]:' \ + | grep -v "$mb_project_dir/sysinfo/host" \ + | grep -v 'touch dirs.tag' \ + | grep -v 'touch host.tag' \ + | grep -v 'touch app.tag' \ + | sed \ + -e 's@'"$mb_cc -c "'@ml64 /nologo @' \ + -e 's@ '"$mb_source_dir"'@ /c %source_dir%@' \ + -e 's@-o @/Fo @g' \ + -e 's@\.s@\.asm@g' \ + -e 's,$,\n\n'"$cmd_abort_on_error"'\n,g' + +# six: compile C sources +make shared-objs static-objs app-objs \ + | grep -v 'make\[1\]:' \ + | grep -v "$mb_project_dir/sysinfo/host" \ + | grep -v 'touch dirs.tag' \ + | grep -v 'touch host.tag' \ + | grep -v 'touch version.tag' \ + | grep -v 'touch app.tag' \ + | sed \ + -e 's@'"$mb_cc -c "'@cl /nologo -c @' \ + -e 's@ '"$mb_source_dir"'@ %source_dir%@' \ + -e 's@-I'"$mb_source_dir"'@-I%source_dir%@g' \ + -e 's@-ffreestanding@/X /GS-@g' \ + -e 's@-o @/Fo:@g' \ + -e 's@-std=c99 @@g' \ + -e 's@-fPIC@@g' \ + -e 's@-fpic@@g' \ + -e 's@-g @/Zi @g' \ + -e 's@-g0 @/Zi @g' \ + -e 's@-g1 @/Zi @g' \ + -e 's@-g2 @/Zi @g' \ + -e 's@-g3 @/Zi @g' \ + -e 's@-O @/O2 @g' \ + -e 's@-Os @/O1 @g' \ + -e 's@-O0 @/Od @g' \ + -e 's@-O1 @/O2 @g' \ + -e 's@-O2 @/O2 @g' \ + -e 's@-O3 @/O2 @g' \ + -e 's@-Wall @/Wall @g' \ + -e 's@-Werror @/WX @g' \ + -e 's@-Wextra @@g' \ + -e 's@-Wundef @/Wall @g' \ + -e 's@-Wno-missing-field-initializers @ @g' \ + -e 's@-Wno-unused-parameter @/wd4100 @g' \ + -e 's@-mno-stack-arg-probe @/Gs65536 @g' \ + -e 's@'"$mb_sysroot "'@ @' \ + -e 's,$, '"$version_macro"' -I%sysroot%/include\n\n'"$cmd_abort_on_error"'\n,g' + +echo +echo '@echo.' +echo '@echo clbuild: successfully built: shared-objs static-objs app-objs.' +echo '@echo.' +echo + +# seven: create static archive +make static \ + | grep -v 'make\[1\]:' \ + | grep -v "rm -f " \ + | sed \ + -e 's@'"$mb_ar"' rcs @lib /out:@' \ + -e 's,$, /nologo\n,g' + +echo +echo "$cmd_abort_on_error" +echo + +echo +echo '@echo.' +echo '@echo clbuild: successfully created: static archive.' +echo '@echo.' +echo + +# eight: link +make LDFLAGS_IMPLIB= LDFLAGS_SONAME= $link_target \ + | grep -v 'make\[1\]:' \ + | grep -v 'rm -f app\.tag' \ + | sed \ + -e 's@'"$mb_cc"' -shared @link /dll /nologo @' \ + -e 's@'"$mb_cc"' -static @link /nologo @' \ + -e 's@'"$mb_cc"' @link /nologo @' \ + -e 's@-o @/out:@g' \ + -e 's@ -L@ /libpath:@g' \ + -e 's,-static -l\([^ ]\+\), %sysroot%/lib/lib\1.a,g' \ + -e 's, -l\([^ ]\+\), %sysroot%/lib/lib\1.lib,g' \ + -e 's@-nostdlib @/nodefaultlib @g' \ + -e 's@-Wl,--subsystem=@/subsystem:@g' \ + -e 's@-Wl,--entry -Wl,'"''"'@/entry:@g' \ + -e 's@-Wl,--entry -Wl,@/entry:@g' \ + -e 's@-Wl,--no-undefined@@g' \ + -e 's@-Wl,--exclude-all-symbols@@g' \ + -e 's@'"$mb_sysroot "'@ @' \ + +echo +echo "$cmd_abort_on_error" +echo + +echo +echo '@echo.' +echo '@echo clbuild: successfully linked: shared library.' +echo '@echo.' +echo + +echo +echo '@echo.' +echo '@echo yay.' +echo '@echo.' +echo + +# all done +exit 0 diff --git a/project/extras.mk b/project/extras.mk index cddaa32..88b2766 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -14,3 +14,14 @@ LDFLAGS_COMMON += -nostdlib -lntapi -lpemagine -ldalist -lntcon LDFLAGS_COMMON += -Wl,--entry -Wl,$(HOST_UNDERSCORE)$(PACKAGE)_entry_point LDFLAGS_SHARED += -Wl,--exclude-all-symbols + +clbuild-bat: + @$(PROJECT_DIR)/project/clbuild.sh \ + --cc=$(CC) \ + --ar=$(AR) \ + --source-dir=$(SOURCE_DIR) \ + --project-dir=$(PROJECT_DIR) \ + --sysroot=$(CFLAGS_SYSROOT) \ + --version-header=ptycon_version.h \ + --version-macro=PTYCON_GIT_VERSION \ + --link-target=static-app |