From 5b49a6a348a7e70a9b0a50c88e0b0a5c0715e2c6 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 10 May 2016 23:02:09 -0400 Subject: build system: upgrade build system, eliminate differences in core definitions. Prior to this patch, there were several differences between this project's build system and the one from which it was derived (sofort). Although the differences were very minor and for the most part related to this project being part of a free-standing, midipix-specific development framework, they still added an extra maintenance burden, specifically by requiring that common changes be applied via patch(1) rather than git-am(1). Following recent improvements to the common build system, it is now possible to have a free-standing, midipix-specific project without any changes to the core build system files, hence the current upgrade. --- Makefile.in | 191 +++++++++++++++++++++++++++++------ config.project | 22 +++- config.usage | 25 +++++ configure | 156 +++++++++++++++++++++++++++- project/defs.mk | 31 ------ project/extras.mk | 11 +- project/overrides.mk | 4 +- project/tagver.mk | 5 + sofort/custom.mk | 76 ++++++++++++++ sofort/defs.mk | 64 ++++++++++++ sofort/version.mk | 63 ++++++++++++ sysinfo/host/host.sh | 1 - sysinfo/host/i686-nt32-midipix.mk | 4 +- sysinfo/host/i686-unknown-linux.mk | 5 - sysinfo/host/i686-w64-mingw32.mk | 4 +- sysinfo/host/native.mk | 4 +- sysinfo/host/x86_64-nt64-midipix.mk | 4 +- sysinfo/host/x86_64-unknown-linux.mk | 5 - sysinfo/host/x86_64-w64-mingw32.mk | 4 +- sysinfo/os/any-os.mk | 4 +- sysinfo/os/bsd.mk | 10 -- sysinfo/os/darwin.mk | 10 -- sysinfo/os/elf.mk | 2 + sysinfo/os/linux.mk | 10 -- sysinfo/os/midipix.mk | 22 ++-- sysinfo/os/mingw.mk | 24 ++--- sysinfo/os/pe.mk | 70 +++++++++++++ sysinfo/toolchain/binutils.mk | 1 + sysinfo/toolchain/llvm.mk | 1 + sysinfo/version.sh | 61 +++++++++++ 30 files changed, 738 insertions(+), 156 deletions(-) delete mode 100644 project/defs.mk create mode 100644 project/tagver.mk create mode 100644 sofort/custom.mk create mode 100644 sofort/defs.mk create mode 100644 sofort/version.mk delete mode 100644 sysinfo/host/i686-unknown-linux.mk delete mode 100644 sysinfo/host/x86_64-unknown-linux.mk delete mode 100644 sysinfo/os/bsd.mk delete mode 100644 sysinfo/os/darwin.mk create mode 100644 sysinfo/os/elf.mk delete mode 100644 sysinfo/os/linux.mk create mode 100644 sysinfo/os/pe.mk create mode 100755 sysinfo/version.sh diff --git a/Makefile.in b/Makefile.in index 42ae8ad..9f87f7f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,5 +1,9 @@ PACKAGE = @package@ +NICKNAME = @nickname@ PROJECT_DIR = @project_dir@ +GIT_REFERENCE_DIR = @git_reference_dir@ +CUSTOM_INSTALL_HEADERS = @custom_install_headers@ +AVOID_VERSION = @avoid_version@ BUILD = @build@ HOST = @host@ @@ -11,19 +15,25 @@ SYSROOT = @sysroot@ CROSS_COMPILE = @cross_compile@ SHELL = @shell@ -CFLAGS_DEBUG = @cflags_debug@ CFLAGS_COMMON = @cflags_common@ +CFLAGS_DEBUG = @cflags_debug@ CFLAGS_CMDLINE = @cflags_cmdline@ CFLAGS_CONFIG = @cflags_config@ CFLAGS_SYSROOT = @cflags_sysroot@ +CFLAGS_OS = @cflags_os@ +CFLAGS_SITE = @cflags_site@ CFLAGS_PATH = @cflags_path@ +CFLAGS_STRICT = @cflags_strict@ +CFLAGS_UTIL = @cflags_util@ -LDFLAGS_DEBUG = @ldflags_debug@ LDFLAGS_COMMON = @ldflags_common@ +LDFLAGS_DEBUG = @ldflags_debug@ LDFLAGS_CMDLINE = @ldflags_cmdline@ LDFLAGS_CONFIG = @ldflags_config@ LDFLAGS_SYSROOT = @ldflags_sysroot@ LDFLAGS_PATH = @ldflags_path@ +LDFLAGS_STRICT = @ldflags_strict@ +LDFLAGS_UTIL = @ldflags_util@ PE_SUBSYSTEM = @pe_subsystem@ PE_IMAGE_BASE = @pe_image_base@ @@ -51,19 +61,28 @@ USER_CC = @user_cc@ USER_CPP = @user_cpp@ USER_CXX = @user_cxx@ +ALL_SHARED = @all_shared@ +ALL_STATIC = @all_static@ +DISABLE_FRONTEND = @disable_frontend@ +DISABLE_SHARED = @disable_shared@ +DISABLE_STATIC = @disable_static@ all: install: shared: static: - +install-extras: +install-app-extras: include $(PROJECT_DIR)/sysinfo/host/$(HOST).mk include $(PROJECT_DIR)/sysinfo/compiler/$(COMPILER).mk include $(PROJECT_DIR)/sysinfo/toolchain/$(TOOLCHAIN).mk -include $(PROJECT_DIR)/project/defs.mk +include $(PROJECT_DIR)/sofort/defs.mk +include $(PROJECT_DIR)/sofort/version.mk +include $(PROJECT_DIR)/sofort/custom.mk + include $(PROJECT_DIR)/project/tree.mk include $(PROJECT_DIR)/project/depends.mk include $(PROJECT_DIR)/project/headers.mk @@ -74,14 +93,16 @@ include $(PROJECT_DIR)/project/overrides.mk -src/%.lo: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag +$(APP_SRCS:%.c=%.o): CFLAGS_STATIC = $(CFLAGS_APP) + +src/%.lo: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag version.tag $(CC) -c -o $@ $< $(CFLAGS_SHARED) -src/%.o: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag dirs.tag +src/%.o: $(PROJECT_DIR)/src/%.c $(ALL_HEADERS) host.tag tree.tag version.tag $(CC) -c -o $@ $< $(CFLAGS_STATIC) -lib/%$(OS_LIB_SUFFIX): - $(LD) -shared -o $@ $^ $(LDFLAGS_SHARED) +lib/%$(OS_LIB_SUFFIX)$(VER_XYZ): + $(CC) -shared -o $@ $^ $(LDFLAGS_SHARED) lib/%$(OS_ARCHIVE_EXT): rm -f $@ @@ -89,36 +110,67 @@ lib/%$(OS_ARCHIVE_EXT): -all: shared static +all: package-shared package-static app + +install: package-install-app +install: package-install-extras +install: install-libs -install: install-libs install-headers +app: app-tag +app.tag: + cp $(PACKAGE_APP) $(APP) + touch app.tag -install-libs: install-shared install-static install-implib +install-libs: package-install-shared +install-libs: package-install-static -install-headers:shared static +install-headers-default: mkdir -p $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) cp $(API_HEADERS) $(DESTDIR)$(INCLUDEDIR)/$(PACKAGE) -install-shared: shared install-implib +install-shared: shared install-lib install-implib +install-shared: package-install-soname package-install-solink +install-shared: install-headers + +install-lib: shared mkdir -p $(DESTDIR)$(LIBDIR) cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR) -install-static: static +install-static: static install-headers mkdir -p $(DESTDIR)$(LIBDIR) cp $(STATIC_LIB) $(DESTDIR)$(LIBDIR) +install-app: app install-app-extras + mkdir -p $(DESTDIR)$(BINDIR) + cp $(APP) $(DESTDIR)$(BINDIR) + +install-static-app: static-app install-app-extras + mkdir -p $(DESTDIR)$(BINDIR) + cp $(STATIC_APP) $(DESTDIR)$(BINDIR)/$(NICKNAME)$(OS_APP_SUFFIX) -shared: shared-lib shared-implib + +shared: shared-lib implib +shared: package-shared-soname package-shared-solink static: static-lib shared-lib: shared-objs $(SHARED_LIB) +shared-soname: shared-lib $(SHARED_SONAME) + +shared-solink: shared-lib $(SHARED_SOLINK) + static-lib: static-objs $(STATIC_LIB) -shared-implib: shared-lib + + +default-app: version.tag static-objs $(DEFAULT_APP) + +shared-app: version.tag shared $(SHARED_APP) + +static-app: version.tag static-objs $(STATIC_APP) @@ -126,16 +178,33 @@ shared-objs: dirs $(SHARED_OBJS) static-objs: dirs $(STATIC_OBJS) +app-objs: dirs $(APP_OBJS) + $(SHARED_LIB): $(SHARED_OBJS) $(STATIC_LIB): $(STATIC_OBJS) +$(APP): $(PACKAGE_APP) + +$(DEFAULT_APP): $(STATIC_OBJS) $(APP_OBJS) + rm -f app.tag + $(CC) -o $@ $^ $(LDFLAGS_APP) -dirs: dirs.tag tree.tag +$(SHARED_APP): $(SHARED_LIB) $(APP_OBJS) + rm -f app.tag + $(CC) -o $@ $(APP_OBJS) -l$(PACKAGE) $(LDFLAGS_SHARED) + +$(STATIC_APP): $(STATIC_OBJS) $(APP_OBJS) + rm -f app.tag + $(CC) -static -o $@ $^ $(LDFLAGS_STATIC) + + +dirs: dirs.tag dirs.tag: + mkdir -p bin mkdir -p lib touch dirs.tag @@ -143,24 +212,46 @@ host.tag: Makefile $(PROJECT_DIR)/sysinfo/host/host.sh --compiler="$(CC)" --cflags="$(CFLAGS)" touch host.tag +version.tag: $(GIT_REFERENCE_DIR) + $(PROJECT_DIR)/sysinfo/version.sh \ + -s $(PROJECT_DIR) \ + -o build/$(PACKAGE)_version.h \ + -p $(PACKAGE) + touch version.tag + distclean: clean rm -f Makefile -clean: +clean: clean-implib rm -f tree.tag rm -f dirs.tag rm -f host.tag + rm -f version.tag + rm -f app.tag rm -f $(SHARED_OBJS) rm -f $(STATIC_OBJS) + rm -f $(APP_OBJS) rm -f $(SHARED_LIB) + rm -f $(SHARED_SONAME) + rm -f $(SHARED_SOLINK) rm -f $(STATIC_LIB) - rm -f $(SHARED_IMPLIB) + rm -f $(APP) + rm -f $(DEFAULT_APP) + rm -f $(SHARED_APP) + rm -f $(STATIC_APP) .display: .display-project .display-env .display-tools .display-flags \ - .display-pe .display-elf .display-dirs .display-build + .display-pe .display-elf .display-dirs .display-build \ + .display-config + +.conf: PAGER ?= less +.conf: + $(MAKE) .display | $(PAGER) .display-project: + @echo PACKAGE:' '$(PACKAGE) + @echo NICKNAME:' '$(NICKNAME) @echo PROJECT_DIR:' '$(PROJECT_DIR) @echo BUILD_DIR:' '$(CURDIR) @echo @@ -201,19 +292,26 @@ clean: @echo .display-flags: - @echo CFLAGS_DEBUG:' '$(CFLAGS_DEBUG) @echo CFLAGS_COMMON:' '$(CFLAGS_COMMON) + @echo CFLAGS_DEBUG:' '$(CFLAGS_DEBUG) + @echo CFLAGS_VERSION:' '$(CFLAGS_VERSION) @echo CFLAGS_CMDLINE:' '$(CFLAGS_CMDLINE) @echo CFLAGS_CONFIG:' '$(CFLAGS_CONFIG) @echo CFLAGS_SYSROOT:' '$(CFLAGS_SYSROOT) + @echo CFLAGS_OS:' '$(CFLAGS_OS) + @echo CFLAGS_SITE:' '$(CFLAGS_SITE) @echo CFLAGS_PATH:' '$(CFLAGS_PATH) + @echo CFLAGS_STRICT:' '$(CFLAGS_STRICT) + @echo CFLAGS_UTIL:' '$(CFLAGS_UTIL) @echo - @echo LDFLAGS_DEBUG:' '$(LDFLAGS_DEBUG) - @echo LDFLAGS_COMMON:' '$(LDFLAGS_COMMON) - @echo LDFLAGS_CMDLINE:' '$(LDFLAGS_CMDLINE) - @echo LDFLAGS_CONFIG:' '$(LDFLAGS_CONFIG) - @echo LDFLAGS_SYSROOT:' '$(LDFLAGS_SYSROOT) - @echo LDFLAGS_PATH:' '$(LDFLAGS_PATH) + @echo LDFLAGS_COMMON:' '$(LDFLAGS_COMMON) + @echo LDFLAGS_DEBUG:' '$(LDFLAGS_DEBUG) + @echo LDFLAGS_CMDLINE:' '$(LDFLAGS_CMDLINE) + @echo LDFLAGS_CONFIG:' '$(LDFLAGS_CONFIG) + @echo LDFLAGS_SYSROOT:' '$(LDFLAGS_SYSROOT) + @echo LDFLAGS_PATH:' '$(LDFLAGS_PATH) + @echo LDFLAGS_STRICT:' '$(LDFLAGS_STRICT) + @echo LDFLAGS_UTIL:' '$(LDFLAGS_UTIL) @echo .display-pe: @@ -250,12 +348,39 @@ clean: @echo USER_CXX:' '$(USER_CXX) @echo +.display-config: + @echo ALL_SHARED:' '$(ALL_SHARED) + @echo ALL_STATIC:' '$(ALL_STATIC) + @echo DISABLE_FRONTEND:' '$(DISABLE_FRONTEND) + @echo DISABLE_SHARED:' '$(DISABLE_SHARED) + @echo DISABLE_STATIC:' '$(DISABLE_STATIC) + +.display-host: + @$(CC) $(CFLAGS) -dumpmachine + +.display-cc: + @echo $(CC) + +.display-cflags: + @echo $(CFLAGS) + -.PHONY: all install shared static .display \ - shared-objs shared-lib shared-implib \ +.PHONY: all install shared static app \ + package-app \ + shared-objs shared-lib \ + shared-soname shared-solink \ + package-shared-soname package-shared-solink \ static-objs static-lib \ - install-shared install-static install-implib \ - install-headers \ - clean distclean \ + default-app shared-app static-app \ + install-shared install-static \ + install-soname install-solink \ + package-install-soname package-install-solink \ + install-headers install-app \ + install-headers-default install-headers-custom \ + clean distclean clean-implib version \ + .display .conf \ .display-project .display-env .display-tools .display-flags \ - .display-pe .display-elf .display-dirs .display-build + .display-pe .display-elf .display-dirs .display-build \ + implib implib-ver implib-soname implib-solink \ + install-implib install-implib-ver \ + install-implib-soname install-implib-solink diff --git a/config.project b/config.project index 46976d3..6d12171 100644 --- a/config.project +++ b/config.project @@ -1,6 +1,8 @@ # project mb_package=ntcon mb_require_out_of_tree=no +mb_custom_install_headers=no +mb_avoid_version=yes # build @@ -16,19 +18,27 @@ mb_default_shell=sh # switches +mb_default_cflags_common="-std=c99 -ffreestanding" +mb_default_cflags_common="$mb_default_cflags_common -I\$(PROJECT_DIR)/src/internal" +mb_default_cflags_common="$mb_default_cflags_common -I\$(PROJECT_DIR)/include" +mb_default_cflags_common="$mb_default_cflags_common -Ibuild" + mb_default_cflags_debug= -mb_default_cflags_common="-I\$(PROJECT_DIR)/src/internal -I\$(PROJECT_DIR)/include -Ibuild" mb_default_cflags_cmdline= mb_default_cflags_config= mb_default_cflags_sysroot= mb_default_cflags_path= +mb_default_cflags_strict= +mb_default_cflags_util= -mb_default_ldflags_debug= mb_default_ldflags_common="-Llib" +mb_default_ldflags_debug= mb_default_ldflags_cmdline= mb_default_ldflags_config= mb_default_ldflags_sysroot= mb_default_ldflags_path= +mb_default_ldflags_strict= +mb_default_ldflags_util= mb_default_pe_subsystem=windows mb_default_pe_image_base= @@ -37,3 +47,11 @@ mb_default_pe_config_defs= mb_default_elf_eh_frame= mb_default_elf_hash_style= mb_default_elf_config_defs= + + +# config +mb_all_static= +mb_all_shared= +mb_disable_frontend=yes +mb_disable_static= +mb_disable_shared= diff --git a/config.usage b/config.usage index 8544fbe..3d334a8 100644 --- a/config.usage +++ b/config.usage @@ -4,6 +4,9 @@ supported switches: ------------------- --help + --nickname + --avoid-version + --prefix --exec-prefix --bindir @@ -24,9 +27,27 @@ supported switches: --shell --debug + --strict + --ccstrict + --ldstrict + + --all-static + --all-shared + --enable-static + --enable-shared + --disable-static + --disable-shared + + --enable-app + --enable-frontend + --disable-app + --disable-frontend + supported variables: -------------------- + NICKNAME + PREFIX EXEC_PREFIX BINDIR @@ -57,6 +78,8 @@ supported variables: CFLAGS_CONFIG CFLAGS_SYSROOT CFLAGS_PATH + CFLAGS_STRICT + CFLAGS_UTIL LDFLAGS LDFLAGS_DEBUG @@ -65,6 +88,8 @@ supported variables: LDFLAGS_CONFIG LDFLAGS_SYSROOT LDFLAGS_PATH + LDFLAGS_STRICT + LDFLAGS_UTIL PE_SUBSYSTEM PE_IMAGE_BASE diff --git a/configure b/configure index 504bfcb..4dacc2a 100755 --- a/configure +++ b/configure @@ -13,7 +13,7 @@ usage() error_msg() { - echo $@ >&2 + echo "$@" >&2 } @@ -28,6 +28,14 @@ init_vars() . "$mb_config" || exit 2 fi + # git + if [ -d "$mb_project_dir/.git" ]; then + mb_git_reference_dir="\$(PROJECT_DIR)/.git" + fi + + # project + mb_nickname=$NICKNAME + # dirs mb_prefix=$PREFIX mb_exec_prefix=$EXEC_PREFIX @@ -57,7 +65,11 @@ init_vars() mb_cflags_cmdline=$CFLAGS_CMDLINE mb_cflags_config=$CFLAGS_CONFIG mb_cflags_sysroot=$CFLAGS_SYSROOT + mb_cflags_os=$CFLAGS_OS + mb_cflags_site=$CFLAGS_SITE mb_cflags_path=$CFLAGS_PATH + mb_cflags_strict=$CFLAGS_STRICT + mb_cflags_util=$CFLAGS_UTIL mb_ldflags=$LDFLAGS mb_ldflags_debug=$LDFLAGS_DEBUG @@ -66,6 +78,8 @@ init_vars() mb_ldflags_config=$LDFLAGS_CONFIG mb_ldflags_sysroot=$LDFLAGS_SYSROOT mb_ldflags_path=$LDFLAGS_PATH + mb_ldflags_strict=$LDFLAGS_STRICT + mb_ldflags_util=$LDFLAGS_UTIL mb_pe_subsystem=$PE_SUBSYSTEM mb_pe_image_base=$PE_IMAGE_BASE @@ -103,6 +117,10 @@ verify_build_directory() common_defaults() { + # project + [ -z "$mb_nickname" ] && mb_nickname=$mb_package + [ -z "$mb_avoid_version" ] && mb_avoid_version='no' + # dirs [ -z "$mb_prefix" ] && [ -z "$mb_prefix_set" ] \ && mb_prefix='/usr/local' @@ -135,7 +153,11 @@ common_defaults() [ -z "$mb_cflags_cmdline" ] && mb_cflags_cmdline=$mb_default_cflags_cmdline [ -z "$mb_cflags_config" ] && mb_cflags_config=$mb_default_cflags_config [ -z "$mb_cflags_sysroot" ] && mb_cflags_sysroot=$mb_default_cflags_sysroot + [ -z "$mb_cflags_os" ] && mb_cflags_os=$mb_default_cflags_os + [ -z "$mb_cflags_site" ] && mb_cflags_site=$mb_default_cflags_site [ -z "$mb_cflags_path" ] && mb_cflags_path=$mb_default_cflags_path + [ -z "$mb_cflags_strict" ] && mb_cflags_strict=$mb_default_cflags_strict + [ -z "$mb_cflags_util" ] && mb_cflags_util=$mb_default_cflags_util [ -z "$mb_ldflags_debug" ] && mb_ldflags_debug=$mb_default_ldflags_debug [ -z "$mb_ldflags_common" ] && mb_ldflags_common=$mb_default_ldflags_common @@ -143,6 +165,8 @@ common_defaults() [ -z "$mb_ldflags_config" ] && mb_ldflags_config=$mb_default_ldflags_config [ -z "$mb_ldflags_sysroot" ] && mb_ldflags_sysroot=$mb_default_ldflags_sysroot [ -z "$mb_ldflags_path" ] && mb_ldflags_path=$mb_default_ldflags_path + [ -z "$mb_ldflags_strict" ] && mb_ldflags_strict=$mb_default_ldflags_strict + [ -z "$mb_ldflags_util" ] && mb_ldflags_util=$mb_default_ldflags_util [ -z "$mb_pe_subsystem" ] && mb_pe_subsystem=$mb_default_pe_subsystem [ -z "$mb_pe_image_base" ] && mb_pe_image_base=$mb_default_pe_image_base @@ -152,6 +176,13 @@ common_defaults() [ -z "$mb_elf_hash_style" ] && mb_elf_hash_style=$mb_default_elf_hash_style [ -z "$mb_elf_config_defs" ] && mb_elf_config_defs=$mb_default_elf_config_defs + # config + [ -z "$mb_all_static" ] && mb_all_static='no' + [ -z "$mb_all_shared" ] && mb_all_shared='no' + [ -z "$mb_disable_frontend" ] && mb_disable_frontend='no' + [ -z "$mb_disable_static" ] && mb_disable_static='no' + [ -z "$mb_disable_shared" ] && mb_disable_shared='no' + # host/target [ -z "$mb_host" ] && mb_host=$mb_target [ -z "$mb_target" ] && mb_target=$mb_host @@ -282,9 +313,10 @@ native_defaults() exit 2 fi - [ -z "$mb_native_os" ] && mb_native_os=$mb_native_os - [ -z "$mb_native_os_bits" ] && mb_native_os_bits=$mb_native_os_bits - [ -z "$mb_native_os_underscore" ] && mb_native_os_underscore=$mb_native_os_underscore + # fallback os recipe + if ! [ -f $mb_project_dir/sysinfo/os/$mb_native_os.mk ]; then + mb_native_os='any-os'; + fi } @@ -296,10 +328,36 @@ cross_defaults() } +config_flags() +{ + mb_ldflags_tmp=" $mb_ldflags " + mb_ldflags_libs=`echo "$mb_ldflags_tmp" | sed 's/ -static / /g'` + + if [ "$mb_ldflags_tmp" != "$mb_ldflags_libs" ]; then + mb_ldflags="$mb_ldflags_libs" + mb_ldflags_util="$mb_ldflags_util -static" + fi + + # ccstrict + if [ "$mb_ccstrict" = 'yes' ]; then + mb_cflags_strict='-Wall -Werror -Wextra -Wundef' + fi + + # ldstrict + if [ "$mb_ldstrict" = 'yes' ]; then + mb_ldflags_strict='-Wl,--no-undefined' + fi +} + + config_copy() { sed -e 's^@package@^'"$mb_package"'^g' \ + -e 's^@nickname@^'"$mb_nickname"'^g' \ -e 's^@project_dir@^'"$mb_project_dir"'^g' \ + -e 's^@git_reference_dir@^'"$mb_git_reference_dir"'^g' \ + -e 's^@custom_install_headers@^'"$mb_custom_install_headers"'^g' \ + -e 's^@avoid_version@^'"$mb_avoid_version"'^g' \ \ -e 's^@build@^'"$mb_build"'^g' \ -e 's^@host@^'"$mb_host"'^g' \ @@ -317,7 +375,11 @@ config_copy() -e 's^@cflags_cmdline@^'"$mb_cflags $mb_cflags_cmdline"'^g' \ -e 's^@cflags_config@^'"$mb_cflags_config"'^g' \ -e 's^@cflags_sysroot@^'"$mb_cflags_sysroot"'^g' \ + -e 's^@cflags_os@^'"$mb_cflags_os"'^g' \ + -e 's^@cflags_site@^'"$mb_cflags_site"'^g' \ -e 's^@cflags_path@^'"$mb_cflags_path"'^g' \ + -e 's^@cflags_strict@^'"$mb_cflags_strict"'^g' \ + -e 's^@cflags_util@^'"$mb_cflags_util"'^g' \ \ -e 's^@ldflags@^'"$mb_ldflags"'^g' \ -e 's^@ldflags_debug@^'"$mb_ldflags_debug"'^g' \ @@ -326,6 +388,8 @@ config_copy() -e 's^@ldflags_config@^'"$mb_ldflags_config"'^g' \ -e 's^@ldflags_sysroot@^'"$mb_ldflags_sysroot"'^g' \ -e 's^@ldflags_path@^'"$mb_ldflags_path"'^g' \ + -e 's^@ldflags_strict@^'"$mb_ldflags_strict"'^g' \ + -e 's^@ldflags_util@^'"$mb_ldflags_util"'^g' \ \ -e 's^@pe_subsystem@^'"$mb_pe_subsystem"'^g' \ -e 's^@pe_image\_base@^'"$mb_pe_image_base"'^g' \ @@ -346,16 +410,43 @@ config_copy() \ -e 's^@native_cc@^'"$mb_native_cc"'^g' \ -e 's^@native_os@^'"$mb_native_os"'^g' \ - -e 's^@native_os_bits@^'"$mb_native_os_bits"'^g' \ + -e 's^@native_os_bits@^'"$mb_native_os_bits"'^g' \ -e 's^@native_os_underscore@^'"$mb_native_os_underscore"'^g' \ \ -e 's^@user_cc@^'"$mb_user_cc"'^g' \ -e 's^@user_cpp@^'"$mb_user_cpp"'^g' \ -e 's^@user_cxx@^'"$mb_user_cxx"'^g' \ + \ + -e 's^@all_static@^'"$mb_all_static"'^g' \ + -e 's^@all_shared@^'"$mb_all_shared"'^g' \ + -e 's^@disable_frontend@^'"$mb_disable_frontend"'^g' \ + -e 's^@disable_static@^'"$mb_disable_static"'^g' \ + -e 's^@disable_shared@^'"$mb_disable_shared"'^g' \ $mb_project_dir/Makefile.in > $mb_pwd/Makefile } +config_support() +{ + [ "$mb_disable_shared" = 'yes' ] && return 0 + + mbt_cc=`make .display-cc` + mbt_cflags=`make .display-cflags` + mbt_source='int foo(int x){return ++x;}' + mbt_result='no' + + rm -f a.out + echo "$mbt_source" | "$mbt_cc" -shared -o a.out -xc - + stat a.out >/dev/null 2>&1 && mbt_result='yes' + rm -f a.out + + if [ "$mbt_result" = 'no' ]; then + mb_disable_shared='yes' + config_copy + fi +} + + config_host() { make -s host.tag && return 0 @@ -442,6 +533,59 @@ for arg ; do --debug) mb_debug='yes' ;; + + # config + --all-static) + mb_all_static='yes' + ;; + --all-shared) + mb_all_shared='yes' + ;; + --disable-frontend) + mb_disable_frontend='yes' + ;; + --disable-app) + mb_disable_frontend='yes' + ;; + --enable-frontend) + mb_disable_frontend='no' + ;; + --enable-app) + mb_disable_frontend='no' + ;; + --disable-static) + mb_disable_static='yes' + ;; + --disable-shared) + mb_disable_shared='yes' + ;; + --enable-static) + mb_disable_static='no' + ;; + --enable-shared) + mb_disable_shared='no' + ;; + + # convenience + --strict) + mb_ccstrict='yes' + mb_ldstrict='yes' + ;; + --ccstrict) + mb_ccstrict='yes' + ;; + --ldstrict) + mb_ldstrict='yes' + ;; + + # project + --nickname=*) + mb_nickname=${arg#*=} + ;; + --avoid-version) + mb_avoid_version='yes' + ;; + *) error_msg ${arg#}: "unsupported config argument." exit 2 @@ -459,7 +603,9 @@ cross_defaults # four: config +config_flags config_copy +config_support config_host config_status diff --git a/project/defs.mk b/project/defs.mk deleted file mode 100644 index b91ed07..0000000 --- a/project/defs.mk +++ /dev/null @@ -1,31 +0,0 @@ -SHARED_LIB_DEPS = -SHARED_APP_DEPS = -STATIC_APP_DEPS = - -COMMON_LOBJS = $(COMMON_SRCS:.c=.lo) -COMMON_OBJS = $(COMMON_SRCS:.c=.o) - -ARCH_LOBJS = $(ARCH_SRCS:.c=.lo) -ARCH_OBJS = $(ARCH_SRCS:.c=.o) - -SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS) -STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS) - -SHARED_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) -STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) -SHARED_IMPLIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT) - -CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \ - $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \ - $(CFLAGS_PATH) - -CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR) -CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR) - -LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ - $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ - $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_LAST) - -LDFLAGS_STATIC = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ - $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ - $(LDFLAGS_PATH) $(STATIC_APP_DEPS) $(LDFLAGS_LAST) diff --git a/project/extras.mk b/project/extras.mk index e319e4e..cfc240f 100644 --- a/project/extras.mk +++ b/project/extras.mk @@ -1,16 +1,15 @@ CFLAGS_SHARED_ATTR += -DNTCON_BUILD CFLAGS_STATIC_ATTR += -DNTCON_STATIC -CFLAGS_CONFIG += -DMIDIPIX_FREESTANDING -ffreestanding -D__NT$(HOST_BITS) +CFLAGS_CONFIG += -DMIDIPIX_FREESTANDING -D__NT$(HOST_BITS) CFLAGS_CONFIG += -UWIN32 -U_WIN32 -U__WIN32 -U__WIN32__ CFLAGS_CONFIG += -UWIN64 -U_WIN64 -U__WIN64 -U__WIN64__ -LDFLAGS_SHARED += --out-implib $(SHARED_IMPLIB) -LDFLAGS_SHARED += --exclude-all-symbols -LDFLAGS_SHARED += -lpemagine +LDFLAGS_SHARED += -Wl,--exclude-all-symbols +LDFLAGS_SHARED += -nostdlib -lpemagine ifeq ($(HOST_BITS),32) - LDFLAGS_SHARED += --entry $(HOST_UNDERSCORE)ntcon_entry_point@12 + LDFLAGS_SHARED += -Wl,--entry -Wl,$(HOST_UNDERSCORE)ntcon_entry_point@12 else - LDFLAGS_SHARED += --entry $(HOST_UNDERSCORE)ntcon_entry_point + LDFLAGS_SHARED += -Wl,--entry -Wl,$(HOST_UNDERSCORE)ntcon_entry_point endif diff --git a/project/overrides.mk b/project/overrides.mk index 2a67ff9..80594c4 100644 --- a/project/overrides.mk +++ b/project/overrides.mk @@ -1,6 +1,6 @@ # direct linker invocation LDFLAGS_SYSROOT = $(CFLAGS_SYSROOT) -ifneq ($(PE_SUBSYSTEM)x,x) - LDFLAGS_COMMON += --subsystem=$(PE_SUBSYSTEM) +ifneq ($(PE_SUBSYSTEM),) + LDFLAGS_COMMON += -Wl,--subsystem=$(PE_SUBSYSTEM) endif diff --git a/project/tagver.mk b/project/tagver.mk new file mode 100644 index 0000000..7cb3cfd --- /dev/null +++ b/project/tagver.mk @@ -0,0 +1,5 @@ +VER_NAMESPACE = NTCON + +VER_MAJOR = 0 +VER_MINOR = 0 +VER_PATCH = 0 diff --git a/sofort/custom.mk b/sofort/custom.mk new file mode 100644 index 0000000..8e0bbc4 --- /dev/null +++ b/sofort/custom.mk @@ -0,0 +1,76 @@ +ifeq ($(OS_BINFMT),PE) +include $(PROJECT_DIR)/sysinfo/os/pe.mk +endif + +ifeq ($(OS_BINFMT),ELF) +include $(PROJECT_DIR)/sysinfo/os/elf.mk +endif + + + +ifeq ($(DISABLE_STATIC),yes) +package-static: +package-install-static: +else +package-static: static +package-install-static: install-static +endif + +ifeq ($(DISABLE_SHARED),yes) +package-shared: +package-install-shared: +else +package-shared: shared +package-install-shared: install-shared +endif + + + +ifeq ($(DISABLE_FRONTEND),yes) +app-tag: +package-install-app: +package-install-extras: +else +app-tag: package-app app.tag +package-install-app: install-app +package-install-extras: install-extras +endif + + + +ifeq ($(ALL_STATIC),yes) + +package-app: static-app +app: PACKAGE_APP = $(STATIC_APP) +app-tag: PACKAGE_APP = $(STATIC_APP) +app.tag: $(STATIC_APP) + + +else ifeq ($(ALL_SHARED),yes) + +package-app: shared-app +app: PACKAGE_APP = $(SHARED_APP) +app-tag: PACKAGE_APP = $(SHARED_APP) +app.tag: $(SHARED_APP) + + +else + +package-app: default-app +app: PACKAGE_APP = $(DEFAULT_APP) +app-tag: PACKAGE_APP = $(DEFAULT_APP) +app.tag: $(DEFAULT_APP) + +endif + + + +ifeq ($(CUSTOM_INSTALL_HEADERS),yes) + +install-headers:install-headers-custom + +else + +install-headers:install-headers-default + +endif diff --git a/sofort/defs.mk b/sofort/defs.mk new file mode 100644 index 0000000..11cec0f --- /dev/null +++ b/sofort/defs.mk @@ -0,0 +1,64 @@ +SHARED_LIB_DEPS = +SHARED_APP_DEPS = +STATIC_APP_DEPS = + +COMMON_LOBJS = $(COMMON_SRCS:.c=.lo) +COMMON_OBJS = $(COMMON_SRCS:.c=.o) + +ARCH_LOBJS = $(ARCH_SRCS:.c=.lo) +ARCH_OBJS = $(ARCH_SRCS:.c=.o) + +APP_LOBJS = $(APP_SRCS:.c=.lo) +APP_OBJS = $(APP_SRCS:.c=.o) + +SHARED_OBJS = $(COMMON_LOBJS) $(ARCH_LOBJS) +STATIC_OBJS = $(COMMON_OBJS) $(ARCH_OBJS) + +STATIC_LIB = lib/$(OS_LIB_PREFIX)$(PACKAGE)$(OS_ARCHIVE_EXT) + +DSO_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_XYZ) +DSO_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX)$(VER_SONAME) +DSO_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_LIB_SUFFIX) + +SHARED_LIB = lib/$(DSO_VER) +SHARED_SONAME = lib/$(DSO_SONAME) +SHARED_SOLINK = lib/$(DSO_SOLINK) + +IMP_DEF = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_LIBDEF_EXT) +IMP_VER = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_XYZ)$(OS_IMPLIB_EXT) +IMP_SONAME = $(OS_LIB_PREFIX)$(PACKAGE)$(VER_SONAME)$(OS_IMPLIB_EXT) +IMP_SOLINK = $(OS_LIB_PREFIX)$(PACKAGE)$(OS_IMPLIB_EXT) + +IMPLIB_DEF = lib/$(IMP_DEF) +IMPLIB_VER = lib/$(IMP_VER) +IMPLIB_SONAME = lib/$(IMP_SONAME) +IMPLIB_SOLINK = lib/$(IMP_SOLINK) + +APP = bin/$(OS_APP_PREFIX)$(NICKNAME)$(OS_APP_SUFFIX) +DEFAULT_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-default$(OS_APP_SUFFIX) +SHARED_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-shared$(OS_APP_SUFFIX) +STATIC_APP = bin/$(OS_APP_PREFIX)$(NICKNAME)-static$(OS_APP_SUFFIX) + +CFLAGS = $(CFLAGS_DEBUG) $(CFLAGS_CONFIG) $(CFLAGS_SYSROOT) \ + $(CFLAGS_COMMON) $(CFLAGS_CMDLINE) $(CFLAGS_HOST) \ + $(CFLAGS_PATH) $(CFLAGS_OS) $(CFLAGS_SITE) \ + $(CFLAGS_VERSION) $(CFLAGS_STRICT) + +CFLAGS_SHARED = $(CFLAGS) $(CFLAGS_PIC) $(CFLAGS_SHARED_ATTR) +CFLAGS_STATIC = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_STATIC_ATTR) +CFLAGS_APP = $(CFLAGS) $(CFLAGS_OBJ) $(CFLAGS_APP_ATTR) $(CFLAGS_UTIL) + +LDFLAGS_SHARED = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ + $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ + $(LDFLAGS_PATH) $(SHARED_LIB_DEPS) $(LDFLAGS_STRICT) \ + $(LDFLAGS_LAST) + +LDFLAGS_APP = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ + $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ + $(LDFLAGS_PATH) $(SHARED_APP_DEPS) $(LDFLAGS_STRICT) \ + $(LDFLAGS_UTIL) $(LDFLAGS_LAST) + +LDFLAGS_STATIC = $(LDFLAGS_DEBUG) $(LDFLAGS_CONFIG) $(LDFLAGS_SYSROOT) \ + $(LDFLAGS_COMMON) $(LDFLAGS_CMDLINE) $(LDFLAGS_HOST) \ + $(LDFLAGS_PATH) $(STATIC_APP_DEPS) $(LDFLAGS_STRICT) \ + $(LDFLAGS_LAST) diff --git a/sofort/version.mk b/sofort/version.mk new file mode 100644 index 0000000..930a295 --- /dev/null +++ b/sofort/version.mk @@ -0,0 +1,63 @@ +include $(PROJECT_DIR)/project/tagver.mk + +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MAJOR=$(VER_MAJOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_MINOR=$(VER_MINOR) +CFLAGS_VERSION += -D$(VER_NAMESPACE)_TAG_VER_PATCH=$(VER_PATCH) + +ifeq ($(AVOID_VERSION),yes) + +VER_XYZ = +VER_SONAME = + +package-shared-soname: +package-shared-solink: +package-install-soname: +package-install-solink: + +else + +VER_XYZ = .$(VER_MAJOR).$(VER_MINOR).$(VER_PATCH) +VER_SONAME = .$(VER_MAJOR) + +package-shared-soname: shared-soname +package-shared-solink: shared-solink +package-install-soname: install-soname +package-install-solink: install-solink + + + +# libfoo.so (common) +install-solink: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SOLINK) + +$(SHARED_SOLINK): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +# libfoo.so.x (symlink) +ifeq ($(OS_SONAME),symlink) +$(SHARED_SONAME): $(SHARED_LIB) + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $@ + +install-soname: install-lib + rm -f $@.tmp + ln -s $(DSO_VER) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) +endif + + +# libfoo.so.x (copy) +ifeq ($(OS_SONAME),copy) +install-soname: install-lib + cp $(SHARED_LIB) $(DESTDIR)$(LIBDIR)/$(DSO_SONAME) + +$(SHARED_SONAME): $(SHARED_LIB) + cp $(SHARED_LIB) $(SHARED_SONAME) +endif + +endif diff --git a/sysinfo/host/host.sh b/sysinfo/host/host.sh index 9caa07b..b3975ae 100755 --- a/sysinfo/host/host.sh +++ b/sysinfo/host/host.sh @@ -21,7 +21,6 @@ host_test() exit 2 } - # one: args for arg ; do case "$arg" in diff --git a/sysinfo/host/i686-nt32-midipix.mk b/sysinfo/host/i686-nt32-midipix.mk index df3185b..fd4b8f8 100644 --- a/sysinfo/host/i686-nt32-midipix.mk +++ b/sysinfo/host/i686-nt32-midipix.mk @@ -1,5 +1,5 @@ include $(PROJECT_DIR)/sysinfo/os/midipix.mk -ARCH = nt32 -HOST_BITS = 32 +ARCH = nt32 +HOST_BITS = 32 HOST_UNDERSCORE = '_' diff --git a/sysinfo/host/i686-unknown-linux.mk b/sysinfo/host/i686-unknown-linux.mk deleted file mode 100644 index 79d497b..0000000 --- a/sysinfo/host/i686-unknown-linux.mk +++ /dev/null @@ -1,5 +0,0 @@ -include $(PROJECT_DIR)/sysinfo/os/linux.mk - -ARCH = i386 -HOST_BITS = 32 -HOST_UNDERSCORE = '_' diff --git a/sysinfo/host/i686-w64-mingw32.mk b/sysinfo/host/i686-w64-mingw32.mk index b8ba461..b18e2e3 100644 --- a/sysinfo/host/i686-w64-mingw32.mk +++ b/sysinfo/host/i686-w64-mingw32.mk @@ -1,5 +1,5 @@ include $(PROJECT_DIR)/sysinfo/os/mingw.mk -ARCH = w32 -HOST_BITS = 32 +ARCH = w32 +HOST_BITS = 32 HOST_UNDERSCORE = '_' diff --git a/sysinfo/host/native.mk b/sysinfo/host/native.mk index 08b02b6..f0cf720 100644 --- a/sysinfo/host/native.mk +++ b/sysinfo/host/native.mk @@ -1,7 +1,7 @@ include $(PROJECT_DIR)/sysinfo/os/$(NATIVE_OS).mk -OS = $(NATIVE_OS) -HOST_BITS = $(NATIVE_OS_BITS) +OS = $(NATIVE_OS) +HOST_BITS = $(NATIVE_OS_BITS) HOST_UNDERSCORE = $(NATIVE_OS_UNDERSCORE) ifeq ($(OS),linux) diff --git a/sysinfo/host/x86_64-nt64-midipix.mk b/sysinfo/host/x86_64-nt64-midipix.mk index fef6345..d0e1d52 100644 --- a/sysinfo/host/x86_64-nt64-midipix.mk +++ b/sysinfo/host/x86_64-nt64-midipix.mk @@ -1,5 +1,5 @@ include $(PROJECT_DIR)/sysinfo/os/midipix.mk -ARCH = nt64 -HOST_BITS = 64 +ARCH = nt64 +HOST_BITS = 64 HOST_UNDERSCORE = '' diff --git a/sysinfo/host/x86_64-unknown-linux.mk b/sysinfo/host/x86_64-unknown-linux.mk deleted file mode 100644 index 76afb56..0000000 --- a/sysinfo/host/x86_64-unknown-linux.mk +++ /dev/null @@ -1,5 +0,0 @@ -include $(PROJECT_DIR)/sysinfo/os/linux.mk - -ARCH = x86_64 -HOST_BITS = 64 -HOST_UNDERSCORE = '' diff --git a/sysinfo/host/x86_64-w64-mingw32.mk b/sysinfo/host/x86_64-w64-mingw32.mk index 7cded15..a86f9b0 100644 --- a/sysinfo/host/x86_64-w64-mingw32.mk +++ b/sysinfo/host/x86_64-w64-mingw32.mk @@ -1,5 +1,5 @@ include $(PROJECT_DIR)/sysinfo/os/mingw.mk -ARCH = w64 -HOST_BITS = 64 +ARCH = w64 +HOST_BITS = 64 HOST_UNDERSCORE = '' diff --git a/sysinfo/os/any-os.mk b/sysinfo/os/any-os.mk index 0aa0a75..cf8ec00 100644 --- a/sysinfo/os/any-os.mk +++ b/sysinfo/os/any-os.mk @@ -6,5 +6,7 @@ OS_LIB_SUFFIX = .so OS_IMPLIB_EXT = .invalid OS_LIBDEF_EXT = .invalid OS_ARCHIVE_EXT = .a +OS_SONAME = symlink +OS_BINFMT = ELF -.PHONY: $(SHARED_IMPLIB) +.PHONY: $(IMPLIB_DEF) $(IMPLIB_VER) $(IMPLIB_SONAME) $(IMPLIB_SOLINK) diff --git a/sysinfo/os/bsd.mk b/sysinfo/os/bsd.mk deleted file mode 100644 index 3fe6711..0000000 --- a/sysinfo/os/bsd.mk +++ /dev/null @@ -1,10 +0,0 @@ -OS = bsd -OS_APP_PREFIX = -OS_APP_SUFFIX = -OS_LIB_PREFIX = lib -OS_LIB_SUFFIX = .so -OS_IMPLIB_EXT = .invalid -OS_LIBDEF_EXT = .invalid -OS_ARCHIVE_EXT = .a - -.PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/darwin.mk b/sysinfo/os/darwin.mk deleted file mode 100644 index b27a486..0000000 --- a/sysinfo/os/darwin.mk +++ /dev/null @@ -1,10 +0,0 @@ -OS = darwin -OS_APP_PREFIX = -OS_APP_SUFFIX = -OS_LIB_PREFIX = lib -OS_LIB_SUFFIX = .dylib -OS_IMPLIB_EXT = .invalid -OS_LIBDEF_EXT = .invalid -OS_ARCHIVE_EXT = .a - -.PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/elf.mk b/sysinfo/os/elf.mk new file mode 100644 index 0000000..5a3940f --- /dev/null +++ b/sysinfo/os/elf.mk @@ -0,0 +1,2 @@ +LDFLAGS_SHARED += -Wl,-soname +LDFLAGS_SHARED += -Wl,$(DSO_SONAME) diff --git a/sysinfo/os/linux.mk b/sysinfo/os/linux.mk deleted file mode 100644 index d6221cf..0000000 --- a/sysinfo/os/linux.mk +++ /dev/null @@ -1,10 +0,0 @@ -OS = linux -OS_APP_PREFIX = -OS_APP_SUFFIX = -OS_LIB_PREFIX = lib -OS_LIB_SUFFIX = .so -OS_IMPLIB_EXT = .invalid -OS_LIBDEF_EXT = .invalid -OS_ARCHIVE_EXT = .a - -.PHONY: $(SHARED_IMPLIB) diff --git a/sysinfo/os/midipix.mk b/sysinfo/os/midipix.mk index 4b5a608..d99b249 100644 --- a/sysinfo/os/midipix.mk +++ b/sysinfo/os/midipix.mk @@ -1,12 +1,10 @@ -OS = midipix -OS_APP_PREFIX = -OS_APP_SUFFIX = -OS_LIB_PREFIX = lib -OS_LIB_SUFFIX = .so -OS_IMPLIB_EXT = .lib.a -OS_LIBDEF_EXT = .so.def -OS_ARCHIVE_EXT = .a - -install-implib: shared-implib - mkdir -p $(DESTDIR)$(LIBDIR) - cp $(SHARED_IMPLIB) $(DESTDIR)$(LIBDIR) +OS = midipix +OS_APP_PREFIX = +OS_APP_SUFFIX = +OS_LIB_PREFIX = lib +OS_LIB_SUFFIX = .so +OS_IMPLIB_EXT = .lib.a +OS_LIBDEF_EXT = .so.def +OS_ARCHIVE_EXT = .a +OS_SONAME = copy +OS_BINFMT = PE \ No newline at end of file diff --git a/sysinfo/os/mingw.mk b/sysinfo/os/mingw.mk index 085d1be..6ade8d5 100644 --- a/sysinfo/os/mingw.mk +++ b/sysinfo/os/mingw.mk @@ -1,14 +1,12 @@ -OS = mingw -OS_APP_PREFIX = -OS_APP_SUFFIX = .exe -OS_LIB_PREFIX = lib -OS_LIB_SUFFIX = .dll -OS_IMPLIB_EXT = .dll.a -OS_LIBDEF_EXT = .def -OS_ARCHIVE_EXT = .a +OS = mingw +OS_APP_PREFIX = +OS_APP_SUFFIX = .exe +OS_LIB_PREFIX = lib +OS_LIB_SUFFIX = .dll +OS_IMPLIB_EXT = .dll.a +OS_LIBDEF_EXT = .def +OS_ARCHIVE_EXT = .a +OS_SONAME = copy +OS_BINFMT = PE -CFLAGS_PIC = - -install-implib: shared-implib - mkdir -p $(DESTDIR)$(LIBDIR) - cp $(SHARED_IMPLIB) $(DESTDIR)$(LIBDIR) +CFLAGS_PIC = diff --git a/sysinfo/os/pe.mk b/sysinfo/os/pe.mk new file mode 100644 index 0000000..abc76e8 --- /dev/null +++ b/sysinfo/os/pe.mk @@ -0,0 +1,70 @@ +LDFLAGS_IMPLIB += -Wl,--output-def +LDFLAGS_IMPLIB += -Wl,$(IMPLIB_DEF) +LDFLAGS_SHARED += $(LDFLAGS_IMPLIB) + +LDFLAGS_SHARED += -Wl,-soname +LDFLAGS_SHARED += -Wl,$(DSO_SONAME) + +implib: implib-ver package-implib-soname package-implib-solink + +implib-ver: shared-lib $(IMPLIB_VER) + +implib-soname: shared-lib $(IMPLIB_SONAME) + +implib-solink: shared-lib $(IMPLIB_SOLINK) + +$(IMPLIB_DEF): shared-lib + +$(IMPLIB_VER): $(IMPLIB_DEF) + $(DLLTOOL) -l $(IMPLIB_VER) -d $(IMPLIB_DEF) -D $(DSO_VER) + +install-implib: install-implib-ver \ + package-install-implib-soname \ + package-install-implib-solink + +install-implib-ver: implib-ver + mkdir -p $(DESTDIR)$(LIBDIR) + cp $(IMPLIB_VER) $(DESTDIR)$(LIBDIR) + +clean-implib: + rm -f $(SHARED_LIB) + rm -f $(IMPLIB_DEF) + rm -f $(IMPLIB_VER) + rm -f $(IMPLIB_SONAME) + rm -f $(IMPLIB_SOLINK) + + +ifeq ($(AVOID_VERSION),yes) + +package-implib-soname: +package-implib-solink: +package-install-implib-soname: +package-install-implib-solink: + +else + +package-implib-soname: implib-soname +package-implib-solink: implib-solink +package-install-implib-soname: install-implib-soname +package-install-implib-solink: install-implib-solink + + +$(IMPLIB_SONAME): $(IMPLIB_DEF) + $(DLLTOOL) -l $(IMPLIB_SONAME) -d $(IMPLIB_DEF) -D $(DSO_SONAME) + +$(IMPLIB_SOLINK): $(IMPLIB_SONAME) + rm -f $(IMPLIB_SOLINK).tmp + ln -s $(IMP_SONAME) $(IMPLIB_SOLINK).tmp + mv $(IMPLIB_SOLINK).tmp $(IMPLIB_SOLINK) + +install-implib-soname: implib-soname + mkdir -p $(DESTDIR)$(LIBDIR) + cp $(IMPLIB_SONAME) $(DESTDIR)$(LIBDIR) + +install-implib-solink: implib-soname + mkdir -p $(DESTDIR)$(LIBDIR) + rm -f $@.tmp + ln -s $(IMP_SONAME) $@.tmp + mv $@.tmp $(DESTDIR)$(LIBDIR)/$(IMP_SOLINK) + +endif diff --git a/sysinfo/toolchain/binutils.mk b/sysinfo/toolchain/binutils.mk index a29ac0c..3232915 100644 --- a/sysinfo/toolchain/binutils.mk +++ b/sysinfo/toolchain/binutils.mk @@ -15,3 +15,4 @@ CXXFILT = $(CROSS_COMPILE)c++filt ELFEDIT = $(CROSS_COMPILE)elfedit OBJCOPY = $(CROSS_COMPILE)objcopy READELF = $(CROSS_COMPILE)readelf +DLLTOOL = $(CROSS_COMPILE)dlltool diff --git a/sysinfo/toolchain/llvm.mk b/sysinfo/toolchain/llvm.mk index 3c805a8..65b5396 100644 --- a/sysinfo/toolchain/llvm.mk +++ b/sysinfo/toolchain/llvm.mk @@ -15,3 +15,4 @@ CXXFILT = $(CROSS_COMPILE)c++filt ELFEDIT = $(CROSS_COMPILE)elfedit OBJCOPY = $(CROSS_COMPILE)objcopy READELF = $(CROSS_COMPILE)readelf +DLLTOOL = $(CROSS_COMPILE)dlltool diff --git a/sysinfo/version.sh b/sysinfo/version.sh new file mode 100755 index 0000000..8157765 --- /dev/null +++ b/sysinfo/version.sh @@ -0,0 +1,61 @@ +#!/bin/sh + +usage() +{ +cat << EOF >&2 + +Usage: + -h show this HELP message + -s SRCDIR set source directory + -o OUTPUT set output header + -p PREFIX set macro prefix + +EOF +exit 1 +} + + +# one +workdir=$(pwd) +srcdir= +output= +prefix= + + +while getopts "hs:o:p:" opt; do + case $opt in + h) + usage + ;; + s) + srcdir="$OPTARG" + ;; + o) + output="$OPTARG" + ;; + p) + prefix="$OPTARG" + ;; + \?) + printf "Invalid option: -%s" "$OPTARG" >&2 + usage + ;; + esac +done + + +# two +if [ -z "$srcdir" ] || [ -z "$output" ] || [ -z "$prefix" ]; then + usage +fi + +cd "$srcdir" || exit 2 + +gitver=`git rev-parse --verify HEAD 2>/dev/null` || gitver="unknown" +macro=`echo "$prefix"_GIT_VERSION | tr '[:lower:]' '[:upper:]'` + +cd "$workdir" || exit 2 +printf "#define $macro\t\"$gitver\"\n" > "$output" + +# all done +exit 0 -- cgit v1.2.3