summaryrefslogtreecommitdiffstats
path: root/Makefile
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2017-09-27 11:17:39 -0700
committerGitHub <noreply@github.com>2017-09-27 11:17:39 -0700
commit74f2f47cb63b02638270beecd20acea1a0f5665e (patch)
treeaf50d0355c7fccb4fb93fc1a0d45c66b5d07f1c9 /Makefile
parentb6cf0f4ae0f3f9d1f377d3f134dcf994676e68b4 (diff)
First attempt at a Linux build (#193)
* First attempt at a Linux build - Fix up places where C++ idioms were written assuming lenient behavior of Microsoft's compiler - Add a few more alternatives for platform-specific behavior where Windows was the only platform accounted for. - Add a basic Makefile that can at least invoke our build, even if it isn't going good dependency tracking, etc. - Build `libslang.so` and `slangc` that depends on it, using a relative `RPATH` to make the binary portable (I hope) - Add an initial `.travis.yml` to see if we can trigger their build process. * Fixup: const bug in `List::Sort` I'm not clear why this gets picked up by the gcc *and* clang that Travis uses, but not the (newer) gcc I'm using on Ubuntu here, but I'm hoping it is just some missing `const` qualifiers. * Fixup: reorder specialization of "class info" Clang complains about things being specialized after being instantiated (implicilty), and I hope it is just the fact that I generate the class info for the roots of the hierarchy after the other cases. We'll see. * Fixup: add `platform.cpp` to unified/lumped build * Fixup: Windows uses `FreeLibrary` and not `UnloadLibrary` * Fixup: fix Windows project file to include new source file This obviously points to the fact that we are going to need to be generating these files sooner or later.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile116
1 files changed, 116 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 000000000..138322165
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,116 @@
+# Makefile
+#
+# This file provides a simpliistic (perhaps *overly* simplistic) way to
+# build Slang from source on Linux, which could probably be adapted for
+# building on other Unix-y targets.
+#
+# This build is not intended to be used for active development right now,
+# so it doesn't actually try to compile the `.cpp` files separately,
+# or track fine-grained dependencies, so almost any source change will
+# trigger a full rebuild. Anybody who wants to do their active development
+# on a platform supported by this Makefile should feel free to contribute
+# improvements, with the caveat that we will not be adoptttting autoconf,
+# CMake, or any other build system that has a tendency to "infect" a codebbbase.
+#
+
+#
+# The Windows build (using Visual Studio) tries to output things to
+# directories that take the target platform (and build configuration) into
+# account. For now we will do something simplistic and request the target
+# "triple" from the compiler (which we assume is either gcc or clang) and
+# call that our target "platformm"
+#
+TARGET := $(shell $(CXX) -dumpmachine)
+
+#
+# TODO: We need a way to control the "configuration" (debug vs. release)
+# but for now just geting *something* working will be a good start.
+#
+
+#
+# We will define an ouput directory for our binaries, based on
+# the target platform chosen. If we ever have steps that need to
+# output intermediate files, we'd set up the directory here.
+#
+OUTPUTDIR := bin/$(TARGET)/
+INTERMEDIATEDIR := intermediate/$(TARGET)/
+
+#
+# Now we will start defining a bunch of variables for build
+# options and properties of the target. We are going to unconditionallyy
+# set these to what we need/want on our Linux target for now, but
+# we will eventually need to do a bit more work to detect the
+# platform.
+#
+SHARED_LIB_PREFIX := lib
+SHARED_LIB_SUFFIX := .so
+BIN_SUFFIX :=
+# Note: we set `visibility=hidden` to avoid exporting more symbols than
+# we really need.
+CFLAGS := -std=c++11 -fvisibility=hidden
+LDFLAGS := -L$(OUTPUTDIR)
+SHARED_LIB_LDFLAGS := -shared
+SHARED_LIB_CFLAGS := -fPIC
+
+# Make sure that shared library inherits build flags
+# from the default case.
+SHARED_LIB_LDFLAGS += $(LDFLAGS)
+SHARED_LIB_CFLAGS += $(CFLAGS)
+
+RELATIVE_RPATH_INCANTATION := "-Wl,-rpath,"'$$'"ORIGIN/"
+
+# TODO: Make sure I'm using these Makefile incantations correctly.
+.SUFFIXES:
+.PHONY: all clean slang slangc test
+
+#
+# Here we define lists of files (source vs. header dependencies)
+# for each logical project we want to build.
+# This is the one place where we do any kiind of "dependency" work,
+# by making a project depend on the headers for sub-projects it usses.
+#
+CORE_SOURCES := source/core/*.cpp
+CORE_HEADERS := source/core/*.h
+
+SLANG_SOURCES := source/slang/*.cpp
+SLANG_HEADERS := slang.h source/slang/*.h
+SLANG_SOURCES += $(CORE_SOURCES)
+SLANG_HEADERS += $(CORE_HEADERS)
+
+SLANGC_SOURCES := source/slangc/*.cpp
+SLANGC_HEADERS := $(SLANG_HEADERS)
+
+#
+# Each project will have a variable that is an alias for
+# the binary it should produce.
+#
+SLANG := $(OUTPUTDIR)$(SHARED_LIB_PREFIX)slang$(SHARED_LIB_SUFFIX)
+SLANGC := $(OUTPUTDIR)slangc$(BIN_SUFFIX)
+
+# By default, when the user invokes `make`, we will build the
+# `slang` shared library, and the `slangc` front-end application.
+all: slang slangc
+
+mkdirs: $(OUTPUTDIR)
+
+# Project-specific targets depend on making theappropriate binary.
+slang: mkdirs $(SLANG)
+slangc: mkdirs $(SLANGC)
+
+
+$(SLANG): $(SLANG_SOURCES) $(SLANG_HEADERS)
+ $(CXX) $(SHARED_LIB_LDFLAGS) -o $@ -DSLANG_DYNAMIC_EXPORT $(SHARED_LIB_CFLAGS) $(SLANG_SOURCES)
+
+$(SLANGC): $(SLANGC_SOURCES) $(SLANGC_HEADERS) $(SLANG)
+ $(CXX) $(LDFLAGS) -o $@ $(CFLAGS) $(SLANGC_SOURCES) $(CORE_SOURCES) -ldl $(RELATIVE_RPATH_INCANTATION) -lslang
+
+
+
+$(OUTPUTDIR):
+ mkdir -p $(OUTPUTDIR)
+
+test:
+ # TODO need to actually run the test runner
+
+clean:
+ rm -rf $(OUTPUTDIR)