Skip to content

Commit a844d58

Browse files
authored
Merge pull request #176 from JuliaLang/aa/openbsd
Fixes for building on OpenBSD
2 parents b7b3b4b + 72bfab4 commit a844d58

5 files changed

Lines changed: 23 additions & 20 deletions

File tree

Make.inc

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@ endif
2424
USEGCC = 1
2525
USECLANG = 0
2626

27-
ifeq ($(OS), Darwin)
28-
USEGCC = 0
29-
USECLANG = 1
30-
endif
31-
32-
ifeq ($(OS), FreeBSD)
27+
ifneq (,$(findstring $(OS),Darwin FreeBSD OpenBSD))
3328
USEGCC = 0
3429
USECLANG = 1
3530
endif

Makefile

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,19 @@ openlibm.pc: openlibm.pc.in Make.inc Makefile
8383

8484
install-static: libopenlibm.a
8585
mkdir -p $(DESTDIR)$(libdir)
86-
cp -f -a libopenlibm.a $(DESTDIR)$(libdir)/
86+
cp -RpP -f libopenlibm.a $(DESTDIR)$(libdir)/
8787

8888
install-shared: libopenlibm.$(OLM_MAJOR_MINOR_SHLIB_EXT)
8989
mkdir -p $(DESTDIR)$(shlibdir)
90-
cp -f -a libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
90+
cp -RpP -f libopenlibm.*$(SHLIB_EXT)* $(DESTDIR)$(shlibdir)/
9191

9292
install-pkgconfig: openlibm.pc
9393
mkdir -p $(DESTDIR)$(pkgconfigdir)
94-
cp -f -a openlibm.pc $(DESTDIR)$(pkgconfigdir)/
94+
cp -RpP -f openlibm.pc $(DESTDIR)$(pkgconfigdir)/
9595

9696
install-headers:
9797
mkdir -p $(DESTDIR)$(includedir)/openlibm
98-
cp -f -a include/*.h $(DESTDIR)$(includedir)/openlibm
99-
cp -f -a src/*.h $(DESTDIR)$(includedir)/openlibm
98+
cp -RpP -f include/*.h $(DESTDIR)$(includedir)/openlibm
99+
cp -RpP -f src/*.h $(DESTDIR)$(includedir)/openlibm
100100

101101
install: install-static install-shared install-pkgconfig install-headers

README.md

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,24 +16,20 @@ consistently across compilers and operating systems, and in 32-bit and
1616

1717
OpenLibm builds on Linux, Mac OS X, Windows, FreeBSD, OpenBSD, and DragonFly BSD.
1818
It builds with both GCC and clang. Although largely tested and widely
19-
used on x86 architectures, openlibm also supports ARM and
20-
powerPC.
19+
used on x86 architectures, OpenLibm also supports ARM and
20+
PowerPC.
2121

2222
## Build instructions
2323

24-
1. Use `make` to build OpenLibm.
24+
1. Use GNU Make to build OpenLibm. This is `make` on most systems, but `gmake` on BSDs.
2525
2. Use `make USEGCC=1` to build with GCC. This is the default on
2626
Linux and Windows.
27-
3. Use `make USECLANG=1` to build with clang. This is the default on OS X
28-
and FreeBSD.
27+
3. Use `make USECLANG=1` to build with clang. This is the default on OS X, FreeBSD,
28+
and OpenBSD.
2929
4. Architectures are auto-detected. Use `make ARCH=i386` to force a
3030
build for i386. Other supported architectures are i486, i586, and
3131
i686. GCC 4.8 is the minimum requirement for correct codegen on
3232
older 32-bit architectures.
33-
5. On OpenBSD, you need to install GNU Make (port name: `gmake`) and a recent
34-
version of `gcc` (tested: 4.9.2), as the default version provided by OpenBSD
35-
is too old (4.2.1). If you use OpenBSD's port system for this (port name:
36-
`gcc`), run `make CC=egcc` to force Make to use the newer `gcc`.
3733

3834
## Acknowledgements
3935

src/bsd_cdefs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,14 @@
7878
/*
7979
* Macro to test if we're using a specific version of gcc or later.
8080
*/
81+
#ifndef __GNUC_PREREQ__
8182
#if defined(__GNUC__) && !defined(__INTEL_COMPILER)
8283
#define __GNUC_PREREQ__(ma, mi) \
8384
(__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi))
8485
#else
8586
#define __GNUC_PREREQ__(ma, mi) 0
8687
#endif
88+
#endif /* __GNUC_PREREQ__ */
8789

8890
/*
8991
* Compiler-dependent macro to help declare pure (no side effects) functions.

src/cdefs-compat.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
#ifndef _CDEFS_COMPAT_H_
22
#define _CDEFS_COMPAT_H_
33

4+
#if !defined(__BEGIN_DECLS)
45
#if defined(__cplusplus)
56
#define __BEGIN_DECLS extern "C" {
67
#define __END_DECLS }
78
#else
89
#define __BEGIN_DECLS
910
#define __END_DECLS
1011
#endif
12+
#endif /* !defined(__BEGIN_DECLS) */
1113

1214
#ifdef __GNUC__
1315
#ifndef __strong_reference
@@ -25,18 +27,22 @@
2527
#define __weak_reference(sym,alias) \
2628
__asm__(".weak " #alias); \
2729
__asm__(".equ " #alias ", " #sym)
30+
#ifndef __warn_references
2831
#define __warn_references(sym,msg) \
2932
__asm__(".section .gnu.warning." #sym); \
3033
__asm__(".asciz \"" msg "\""); \
3134
__asm__(".previous")
35+
#endif /* __warn_references */
3236
#else
3337
#define __weak_reference(sym,alias) \
3438
__asm__(".weak alias"); \
3539
__asm__(".equ alias, sym")
40+
#ifndef __warn_references
3641
#define __warn_references(sym,msg) \
3742
__asm__(".section .gnu.warning.sym"); \
3843
__asm__(".asciz \"msg\""); \
3944
__asm__(".previous")
45+
#endif /* __warn_references */
4046
#endif /* __STDC__ */
4147
#elif defined(__clang__) /* CLANG */
4248
#ifdef __STDC__
@@ -53,16 +59,20 @@
5359
#define __weak_reference(sym,alias) \
5460
__asm__(".stabs \"_" #alias "\",11,0,0,0"); \
5561
__asm__(".stabs \"_" #sym "\",1,0,0,0")
62+
#ifndef __warn_references
5663
#define __warn_references(sym,msg) \
5764
__asm__(".stabs \"" msg "\",30,0,0,0"); \
5865
__asm__(".stabs \"_" #sym "\",1,0,0,0")
66+
#endif /* __warn_references */
5967
#else
6068
#define __weak_reference(sym,alias) \
6169
__asm__(".stabs \"_/**/alias\",11,0,0,0"); \
6270
__asm__(".stabs \"_/**/sym\",1,0,0,0")
71+
#ifndef __warn_references
6372
#define __warn_references(sym,msg) \
6473
__asm__(".stabs msg,30,0,0,0"); \
6574
__asm__(".stabs \"_/**/sym\",1,0,0,0")
75+
#endif /* __warn_references */
6676
#endif /* __STDC__ */
6777
#endif /* __ELF__ */
6878
#endif /* __weak_reference */

0 commit comments

Comments
 (0)