summaryrefslogtreecommitdiff
path: root/src/Makefile.am
diff options
context:
space:
mode:
authorAlastair Hughes <hobbitalastair@gmail.com>2017-01-06 19:06:03 +1300
committerWill Estes <westes575@gmail.com>2017-02-23 14:07:56 -0500
commit89f10ee36f95430f18ac70f971fe9f9f894d9dc5 (patch)
treef6c22538904e29a1cc2fa6f85e2a79395bc8d31b /src/Makefile.am
parentd1b195b67171ee246cf589670f1a7db04fa93afc (diff)
build: support cross compiling.
Check for cross compiling. If cross compiling, build stage1flex using a custom link command. We also override LDADD since that adds the replacement implementations that are cross compiled, and instead always use the replacement library implementations. We don't use BUILD_OBJEXT and BUILD_EXEEXT since it seems that automake does not support these. Fixes #78.
Diffstat (limited to 'src/Makefile.am')
-rw-r--r--src/Makefile.am17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index c24fcca..7ecbf52 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -21,7 +21,24 @@ stage1flex_SOURCES = \
scan.l \
$(COMMON_SOURCES)
+if CROSS
+stage1flex_LDADD =
+stage1flex_SOURCES += \
+ ../lib/malloc.c \
+ ../lib/realloc.c
+stage1flex_LINK = $(LIBTOOL) --tag=CC --mode=link $(CC_FOR_BUILD) \
+ $(CFLAGS_FOR_BUILD) $(LDFLAGS_FOR_BUILD) -o $@
+
+$(stage1flex_OBJECTS): CC=$(CC_FOR_BUILD)
+$(stage1flex_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD)
+$(stage1flex_OBJECTS): CPP=$(CPP_FOR_BUILD)
+$(stage1flex_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD)
+$(stage1flex_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD)
+else
+stage1flex_LDADD = $(LDADD)
+stage1flex_LINK = $(LINK)
stage1flex_CFLAGS = $(AM_CFLAGS)
+endif
flex_SOURCES = \
$(COMMON_SOURCES)