Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve build system to detect available compilers #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
* text=auto

findwinsdk text eol=lf
msvs-detect text eol=lf
checkenv text eol=lf
configure text eol=lf
configure.ac text eol=lf
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ flexlink.opt
test/dump.exe
version.res
version.ml
Makefile.winsdk
Makefile.config
autom4te.cache
config.log
config.status
3 changes: 2 additions & 1 deletion CHANGES
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Next version
- Fixes for clang (patch by Roven Gabriel)
- Improve autodetection of WinSDK paths (patch by David Allsopp)
- Improve autodetection of Visual Studio/Windows SDK paths (patch by David Allsopp)
- Add MSVC_DETECT Makefile variable which overrides all C Compiler detection logic when 0.
- Add checkenv script which determines if the environment is sound specifying MSVC_DETECT=0
- Improve performance of -builtin
- Add beginnings of a proper configure script

Version 0.34
- New option -norelrelocs to check that no relative flexdll relocations are created (this ensures that the generated DLLs can be loaded at any address),
Expand Down
86 changes: 22 additions & 64 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,41 +1,14 @@
VERSION = 0.34
all: flexlink.exe support

include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config")

MINGW_PREFIX = i686-w64-mingw32
MINCC = $(MINGW_PREFIX)-gcc

MINGW64_PREFIX = x86_64-w64-mingw32
MIN64CC = $(MINGW64_PREFIX)-gcc

CYGWIN_PREFIX = i686-pc-cygwin
CYGCC = $(CYGWIN_PREFIX)-gcc

CYGWIN64_PREFIX = x86_64-pc-cygwin
CYG64CC = $(CYGWIN64_PREFIX)-gcc

.PHONY: version.ml
version.ml:
echo "let version = \"$(VERSION)\"" > version.ml
echo "let mingw_prefix = \"$(MINGW_PREFIX)\"" >> version.ml
echo "let mingw64_prefix = \"$(MINGW64_PREFIX)\"" >> version.ml

# Supported tool-chains

CHAINS = mingw mingw64 cygwin cygwin64 msvc msvc64

# Compilers
ifeq ($(findstring clean,$(MAKECMDGOALS)),)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoids running configure if make [dist]clean is called twice.

include Makefile.config
endif

# Attempt to locate the Windows SDK
all: $(if $(filter-out no,$(HAVE_OCAMLOPT)),flexlink.exe) support
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This has the nice benefit if bootstrapping just the FlexDLL objects that make all only builds what it can.


ifeq ($(findstring clean,$(MAKECMDGOALS)),)
include Makefile.winsdk
ifneq ($(filter-out no,$(HAVE_OCAMLOPT)),)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Eliminates the warning about Makefile.config not being found (and ocamlopt not being found) when bootstrapping.

include $(shell cygpath -ad "$(shell ocamlopt -where)/Makefile.config")
endif

Makefile.winsdk: findwinsdk
bash ./findwinsdk x86 > $@
bash ./findwinsdk x64 64 >> $@
# Compilers

MSVC_DETECT=1
MSVC_FLAGS=/nologo /MD -D_CRT_SECURE_NO_DEPRECATE /GS-
Expand All @@ -47,38 +20,18 @@ MSVC64_PREFIX=
MSVCC=cl.exe $(MSVC_FLAGS)
MSVCC64=cl.exe $(MSVC_FLAGS)
else
ifeq ($(SDK),)
# Otherwise, assume the 32-bit version of VS 2008 or Win7 SDK is in the path.

MSVCC_ROOT := $(shell which cl.exe 2>/dev/null | cygpath -f - -ad | xargs -d \\n dirname 2>/dev/null | cygpath -f - -m)
MSVC_LIB1 = $(shell dirname $(MSVCC_ROOT))
MSVC_LIB2 = $(shell which ResGen.exe | cygpath -f - -ad | xargs -d \\n dirname | xargs -d \\n dirname | cygpath -f - -m)
MSVC_LIB = $(MSVC_LIB1)/Lib;$(MSVC_LIB2)/Lib
MSVC_INCLUDE = $(MSVC_LIB1)/Include;$(MSVC_LIB2)/Include
MSVC_PREFIX=LIB="$(MSVC_LIB)" INCLUDE="$(MSVC_INCLUDE)"

MSVC64_LIB = $(MSVC_LIB1)/Lib/amd64;$(MSVC_LIB2)/Lib/x64
MSVC64_PREFIX=LIB="$(MSVC64_LIB)" INCLUDE="$(MSVC_INCLUDE)"

MSVCC = $(MSVCC_ROOT)/cl.exe $(MSVC_FLAGS)
MSVCC64 = $(MSVCC_ROOT)/amd64/cl.exe $(MSVC_FLAGS)
else
MSVCC_ROOT:=
MSVC_PREFIX=PATH="$(SDK):$(PATH)" LIB="$(SDK_LIB);$(LIB)" INCLUDE="$(SDK_INC);$(INCLUDE)"
MSVC64_PREFIX=PATH="$(SDK64):$(PATH)" LIB="$(SDK64_LIB);$(LIB)" INCLUDE="$(SDK64_INC);$(INCLUDE)"
# Otherwise, use configured values
MSVC_PREFIX=PATH="$(MSVS_PATH)$(PATH)" LIB="$(MSVS_LIB);$(LIB)" INCLUDE="$(MSVS_INC);$(INCLUDE)"
MSVC64_PREFIX=PATH="$(MSVS64_PATH)$(PATH)" LIB="$(MSVS64_LIB);$(LIB)" INCLUDE="$(MSVS64_INC);$(INCLUDE)"

MSVCC = cl.exe $(MSVC_FLAGS)
MSVCC64 = cl.exe $(MSVC_FLAGS)
endif
endif

ifeq ($(MSVS_DETECT),1)
show_root:
ifeq ($(MSVCC_ROOT),)
@echo "$(SDK)"
@echo "$(SDK_LIB)"
else
@echo "$(MSVCC_ROOT)"
@echo "$(MSVC_LIB)"
@echo "$(MSVS_PATH)"
@echo "$(MSVS_LIB)"
endif

OCAMLOPT = ocamlopt
Expand Down Expand Up @@ -190,10 +143,11 @@ demo_msvc64: flexlink.exe flexdll_msvc64.obj flexdll_initer_msvc64.obj
(cd test && $(MSVC64_PREFIX) $(MAKE) clean demo CHAIN=msvc64 CC="$(MSVCC64)" O=obj)

distclean: clean
rm -f Makefile.winsdk
rm -f Makefile.config config.log config.status version.ml
rm -rf autom4te.cache

clean:
rm -f *.obj *.o *.lib *.a *.exe *.opt *.cmx *.dll *.exp *.cmi *.cmo *~ version.res version.ml
rm -f *.obj *.o *.lib *.a *.exe *.opt *.cmx *.dll *.exp *.cmi *.cmo *~ version.res
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

version.ml is generated by configure, so should be removed in distclean only.

cd test && $(MAKE) clean


Expand All @@ -204,8 +158,6 @@ URL = [email protected]:www/flexdll/

# Source packages

PACKAGE = flexdll-$(VERSION).tar.gz

package_src:
rm -Rf flexdll-$(VERSION)
mkdir flexdll-$(VERSION)
Expand Down Expand Up @@ -266,3 +218,9 @@ upload_installer:

upload_all:
$(MAKE) upload_src upload_bin installer upload_installer

Makefile.config: Makefile.config.in configure
./configure

configure: configure.ac
autoconf
23 changes: 23 additions & 0 deletions Makefile.config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
VERSION = @PACKAGE_VERSION@

PACKAGE = @PACKAGE_TARNAME@-@[email protected]

MINGW_PREFIX=@MINGW_PREFIX@
MINCC=@MINCC@
MINGW64_PREFIX=@MINGW64_PREFIX@
MIN64CC=@MIN64CC@
CYGCC=@CYGCC@
CYG64CC=@CYG64CC@

MSVS_PATH=@MSVS_PATH@
MSVS_INC=@MSVS_INC@
MSVS_LIB=@MSVS_LIB@
MSVS64_PATH=@MSVS64_PATH@
MSVS64_INC=@MSVS64_INC@
MSVS64_LIB=@MSVS64_LIB@

# Supported tool-chains

CHAINS =@CHAINS@

HAVE_OCAMLOPT = @HAVE_OCAMLOPT@
Loading