cake
/
libp7
Archived
1
0
Fork 1

Added --windows and --static, should've added what's required for cross-compilation to calculator

This commit is contained in:
Thomas Touhey 2017-01-13 23:30:46 +01:00
parent c019e2ae7c
commit 2e731870b4
3 changed files with 76 additions and 23 deletions

View File

@ -90,7 +90,7 @@ dist: mrproper
# Library-specific targets #
#******************************************************************************#
# Make the library.
all-lib: $(CHECKCFG) $(SONAME)
all-lib: $(CHECKCFG) $(if $(STATIC),$(ANAME),$(SONAME))
# Make a module object directory.
$(MODULES:%=$(OBJDIR)/%):
@ -104,10 +104,14 @@ endef
$(foreach mod,$(MODULES), \
$(eval $(call make-moduleobj-rule,$(mod))))
# Make the library (shared).
# Make the shared library.
$(SONAME): $(foreach m,$(MODULES),$(SRC_$(m):%=$(OBJDIR)/$(m)/%.o))
$(call bcmd,ld,$@,$(LD) -o $@ $^ $(LDFLAGS))
# Make the static library.
lib$(NAME).a: $(foreach m,$(MODULES),$(SRC_$(m):%=$(OBJDIR)/$(m)/%.o))
$(call bcmd,ar rc,$@,$(AR) rcs $@ $^)
# Remove the objects directory.
mostlyclean-lib:
$(call rmsg,Removing object directory.)
@ -117,23 +121,24 @@ $(eval $(call make-moduleobj-rule,$(mod))))
# Clean and remove the built library.
clean-lib: mclean-lib
$(call rmsg,Removing the library.)
$(call qcmd,$(RM) lib$(NAME).so.* lib$(NAME).dll lib$(NAME).a \
lib$(NAME).dll.a)
$(call qcmd,$(RM) $(SONAMES) $(ANAMES))
# Remake the library.
re-lib: clean-lib all-lib
# Install the library and development files.
LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(FOR_WINDOWS),,y))
LINK_TO_MAJOR := $(if $(INSTALL_DEVEL),$(if $(STATIC),,$(if $(FOR_WINDOWS),,y)))
IWINDLL := $(if $(FOR_WINDOWS),$(if $(STATIC),,y))
install-lib: all-lib $(if $(INSTALL_DEVEL),install-cfgtool)
$(call imsg,Installing the library.)
$(call qcmd,$(INST) -m 755 -d "$(ILIBDIR)")
$(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" \
$(if $(FOR_WINDOWS),lib$(NAME).dll.a,$(SONAME)))
$(call qcmd,$(INST) -m 755 -t "$(ILIBDIR)" $(if $(STATIC),\
$(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a),\
$(if $(FOR_WINDOWS),lib$(NAME).dll.a,$(SONAME))))
$(if $(FOR_WINDOWS),$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)"))
$(if $(FOR_WINDOWS),$(call qcmd,$(INST) -m 644 \
lib$(NAME).dll "$(IBINDIR)/lib$(NAME).dll"))
$(if $(IWINDLL),$(call qcmd,$(INST) -m 755 -d "$(IBINDIR)"))
$(if $(IWINDLL),$(call qcmd,$(INST) -m 644 -t "$(IBINDIR)" \
lib$(NAME).dll))
$(if $(INSTALL_UDEV),\
$(call imsg,Installing udev rule.))

View File

@ -8,9 +8,6 @@
# Correct target
TARGET := $(if $(TARGET),$(TARGET)-)
# Check if it is for MS-Windows (damn son)
FOR_WINDOWS := $(if $(findstring mingw,$(TARGET)),y)
#******************************************************************************#
# Project main information #
#******************************************************************************#
@ -54,7 +51,11 @@
#******************************************************************************#
# Dynamic library name
SONAME := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.$(MAJOR))
SONAMES := $(if $(FOR_WINDOWS),lib$(NAME).dll,lib$(NAME).so.*)
SONAMES := lib$(NAME).dll lib$(NAME).so.*
# Static library name
ANAME := $(if $(FOR_WINDOWS),lib$(NAME).lib,lib$(NAME).a)
ANAMES := lib$(NAME).lib lib$(NAME).a lib$(NAME).dll.a
#******************************************************************************#
# Binary utilities #
@ -76,7 +77,8 @@ ifdef MORE_WARNINGS
CMOREFLAGS += $(CWERROR:%=-W%) -Wstack-protector -Wno-unused-parameter
endif
# - All of the C compiler flags
CFLAGS := -I $(INCDIR) $(CWARN) -std=gnu11 -fPIC -O2 \
CFLAGS := -I $(INCDIR) $(CWARN) -std=gnu11 \
$(if $(STATIC),,-fPIC) $(if $(OPTIMIZE_SIZE),-Os,-O2) \
$(if $(USE_LIBUSB),,-Dno_libusb) \
-D LOGLEVEL="ll_$(LOG_LEVEL)" -D INIT_TRIES="$(INIT_TRIES)" \
-D MAINTAINER="$(MAINTAINER_NAME) <$(MAINTAINER_MAIL)>" \
@ -99,6 +101,9 @@ endif
$(shell $(PKGCONFIG) --libs libusb-1.0 2>/dev/null)) \
$(if $(FOR_WINDOWS),$(LDFLAGS_Windows),$(LDFLAGS_Linux))
# Archive manager
AR := $(TARGET)ar
# Directory maker
MD := mkdir -p
# Copier

59
configure vendored
View File

@ -6,13 +6,8 @@ cd "$(dirname "$0")"
# Project variables
name="$(make -s getname)"
version="$(make -s getversion)"
# Maintainer
maintainer="$(make -s getmaintainer)"
# Target
target=""
# Platform
platform="$(command -v gcc 1>/dev/null && gcc --print-multiarch)"
platform="$([ "$platform" ] && echo "/$platform")"
@ -22,6 +17,10 @@ make_full_log=
more_warnings=
# Build options
target=
static=
windows=
optimize_size=
libusb=y
loglevel=none # none, info, warn, error, fatal
init_tries=5
@ -61,7 +60,10 @@ General options:
Build options:
--target=TARGET the target (if none, native)
--no-libusb do not use libusb.
--static build a static library (by default, dynamic)
--windows build DLLs and .libs instead of ELF and archives
--optimize-size optimize size instead of speed
--no-libusb do not use libusb
--loglevel=LEVEL library log level [$loglevel]
--init-tries=TRIES default number of detection tries [$init_tries]
@ -119,10 +121,13 @@ esac; done
# Parse arguments #
#******************************************************************************#
for arg ; do case "$arg" in
--target=*) target="${arg#*=}" ;;
--no-libusb) libusb= ;;
--make-full-log) make_full_log=yes ;;
--maintainer) more_warnings=yes; loglevel=info ;;
--target=*) target="${arg#*=}" ;;
--static) static=y ;;
--windows) windows=y ;;
--optimize-size) optimize_size=y ;;
--no-libusb) libusb= ;;
--loglevel=*)
level="${arg#*=}"
if ! [ $level = "info" ] && ! [ $level = "warn" ] \
@ -167,12 +172,47 @@ if [ ! $prefix_set ] && [ $target ]; then
prefix="$prefix"/"$target"
fi
# Check MS-Windows targets
win_target=
case "$target" in *-mingw32) windows=y; win_target=y;; esac
# Evaluate variables
vars="prefix sysconfdir bindir libdir pkgdir includedir mandir udevrulesdir"
for var in $vars; do
eval $var'='$(eval 'echo $'$var)
done
# Check that static and MS-Windows are not asked.
if [ "$static" ] && [ "$windows" ]; then
cat >&2 <<EOF
Sadly, there is no equivalent of MSVC's LIB.EXE for GNU/Linux.
If you know one, contact the maintainer: see \`./configure --help\`.
EOF
exit 1
fi
# Check that MS-Windows has a target.
if [ "$windows" ] && [ ! "$target" ]; then
cat >&2 <<EOF
You have selected the --windows option, but have selected no target.
If you want to build for native use, use a mingw32/mingw64 target.
If you want to build for a cross-compiling use, specify an other target!
EOF
exit 1
fi
# Check that MS-Windows has a mingw* target.
if [ "$windows" ] && [ ! "$win_target" ]; then
cat >&2 <<EOF
You have selected the --windows option, but have not selected a mingw32/mingw64
BFD target. We supposed that it is because you are compiling libp7 for a
cross-compiler compiled for MS-Windows (that's why configuration won't fail).
If it is not, please reconfigure to use a mingw32/mingw64 toolchain!
EOF
fi
#******************************************************************************#
# Create Makefile configuration #
#******************************************************************************#
@ -186,9 +226,12 @@ cat <<EOF
CONFIG_VERSION := $version
MAKE_FULL_LOG := $make_full_log
MORE_WARNINGS := $more_warnings
FOR_WINDOWS := $windows
# Build options
STATIC := $static
TARGET := $target
OPTIMIZE_SIZE := $optimize_size
USE_LIBUSB := $libusb
LOG_LEVEL := $loglevel
INIT_TRIES := $init_tries