Skip to content

Commit

Permalink
Support for FreeBSD
Browse files Browse the repository at this point in the history
We use gnu make on FreeBSD instead of bsd make, due to incompatibilities:
 * -include is a GNUism
 * conditionals (ifneq/ifeq)
  • Loading branch information
hannesm committed Nov 19, 2013
1 parent 0927e78 commit b23ac6e
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 6 deletions.
8 changes: 7 additions & 1 deletion Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ idrisCmd local = ".." </> buildDir local </> "idris" </> "idris"
-- -----------------------------------------------------------------------------
-- Make Commands

-- use GNU make on FreeBSD
#ifdef freebsd_HOST_OS
mymake = "gmake"
#else
mymake = "make"
#endif
make verbosity =
P.runProgramInvocation verbosity . P.simpleProgramInvocation "make"
P.runProgramInvocation verbosity . P.simpleProgramInvocation mymake

-- -----------------------------------------------------------------------------
-- Flags
Expand Down
6 changes: 5 additions & 1 deletion config.mk
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
GMP_INCLUDE_DIR :=
CC :=gcc
CABAL :=cabal
CFLAGS :=-O2 -Wall $(CFLAGS)
#CABALFLAGS :=
## Disable building of Effects
#CABALFLAGS :=-f NoEffects

ifneq (, $(findstring bsd, $(MACHINE)))
GMP_INCLUDE_DIR :=
else
GMP_INCLUDE_DIR :=-I/usr/local/include
endif

MACHINE := $(shell $(CC) -dumpmachine)
ifneq (, $(findstring darwin, $(MACHINE)))
Expand Down
3 changes: 3 additions & 0 deletions idris.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ Executable idris
if os(linux)
cpp-options: -DLINUX
build-depends: unix
if os(freebsd)
cpp-options: -DFREEBSD
build-depends: unix
if os(darwin)
cpp-options: -DMACOSX
build-depends: unix
Expand Down
2 changes: 1 addition & 1 deletion rts/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ include ../config.mk
OBJS = idris_rts.o idris_heap.o idris_gc.o idris_gmp.o idris_stdfgn.o \
idris_bitstring.o idris_opts.o idris_stats.o
HDRS = idris_rts.h idris_heap.h idris_gc.h idris_gmp.h idris_stdfgn.h \
idris_bitstring.h idris_opts.h idris_stats.h
idris_bitstring.h idris_opts.h idris_stats.h
CFLAGS:=-fPIC $(CFLAGS)
ifneq ($(GMP_INCLUDE_DIR),)
CFLAGS += -isystem $(GMP_INCLUDE_DIR)
Expand Down
2 changes: 2 additions & 0 deletions src/Util/DynamicLinker.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ hostDynamicLibExt = "so"
hostDynamicLibExt = "dylib"
#elif WINDOWS
hostDynamicLibExt = "dll"
#elif FREEBSD
hostDynamicLibExt = "so"
#else
hostDynamicLibExt = error $ unwords
[ "Undefined file extension for dynamic libraries"
Expand Down
15 changes: 12 additions & 3 deletions src/Util/System.hs
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,24 @@ rmFile f = do putStrLn $ "Removing " ++ f
(\ioerr -> putStrLn $ "WARNING: Cannot remove file "
++ f ++ ", Error msg:" ++ show ioerr)


#ifdef FREEBSD
extraLib = " -L/usr/local/lib"
#else
extraLib = ""
#endif
getLibFlags = do dir <- getDataDir
return $ "-L" ++ (dir </> "rts") ++ " -lidris_rts -lgmp -lpthread"
return $ "-L" ++ (dir </> "rts") ++ " -lidris_rts" ++ extraLib ++ " -lgmp -lpthread"

getIdrisLibDir = do dir <- getDataDir
return $ addTrailingPathSeparator dir

#ifdef FREEBSD
extraInclude = " -I/usr/local/include"
#else
extraInclude = ""
#endif
getIncFlags = do dir <- getDataDir
return $ "-I" ++ dir </> "rts"
return $ "-I" ++ dir </> "rts" ++ extraInclude

getExecutablePom = do dir <- getDataDir
return $ dir </> "java" </> "executable_pom.xml"

0 comments on commit b23ac6e

Please sign in to comment.