File: Make.llvm.static

package info (click to toggle)
faust 2.79.3%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 397,496 kB
  • sloc: cpp: 278,433; ansic: 116,164; javascript: 18,529; vhdl: 14,052; sh: 13,884; java: 5,900; objc: 3,852; python: 3,222; makefile: 2,655; cs: 1,672; lisp: 1,146; ruby: 954; yacc: 586; xml: 471; lex: 247; awk: 110; tcl: 26
file content (65 lines) | stat: -rwxr-xr-x 1,969 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#
# this makefile is intended to build a single static library embedding both faust 
# and the corresponding llvm libraries
#

MAKE ?= make
AR   ?= ar

TMP 	?= __tmp_llvm_lib__
OUTPUT 	?= lib/libfaustwithllvm.a

# start to determine the current platform
system := $(shell uname -s)

ifeq ($(system), Darwin)
NCURSES_PRIMARY_PREFIX := /usr/local/Cellar/ncurses
NCURSES_BACKUP1_PREFIX := /opt/homebrew/Cellar/ncurses
NCURSES_BACKUP2_PREFIX := /opt/local
LIBNCURSES_PATH ?= $(shell find $(NCURSES_PRIMARY_PREFIX) -name libncurses.a 2>/dev/null || find $(NCURSES_BACKUP1_PREFIX) -name libncurses.a 2>/dev/null || find $(NCURSES_BACKUP2_PREFIX) -name libncurses.a 2>/dev/null)

INPUT   := $(shell ls $(LLVM_LIB_DIR)/lib*.a | sed "s|$(LLVM_LIB_DIR)/\(lib.*\.a\)|\1|g" | tr '\n' ' ')
SYSLIBS := -lm -lz -lcurses -lxml2
else
# ubuntu
LIBNCURSES_PATH ?= $(shell find /usr -name libncurses.a)

LLVM_CONFIG ?= llvm-config
INPUT := $(filter-out libPolly.a libPollyISL.a, $(shell $(LLVM_CONFIG) --libnames --link-static))
LLVM_LIB_DIR := $(shell $(LLVM_CONFIG) --libdir)
SYSLIBS := $(shell $(LLVM_CONFIG) --system-libs)
endif

FOLDERS := $(INPUT:%.a=$(TMP)/%.dir) $(TMP)/libfaust.dir $(TMP)/libncurses.dir
CONFIG  := ../tools/faust-config

MAKEFILE := $(lastword $(MAKEFILE_LIST))

.PHONY: $(OUTPUT)

all: $(OUTPUT)
	$(MAKE) -f $(MAKEFILE) syslibs

$(OUTPUT): $(FOLDERS)
	@-[ -f $@ ] && rm -f $@ 
	$(AR) -csr $(OUTPUT) $(TMP)/*/*.o 
	rm -rf $(TMP)

syslibs:
	sed -e "s|^SYSTEMLIBS..*|SYSTEMLIBS=\"$(SYSLIBS)\"|" $(CONFIG) > __tmp__ 
	mv __tmp__ $(CONFIG)
	chmod +x $(CONFIG)

##########################################
$(TMP)/%.dir: $(LLVM_LIB_DIR)/%.a
	@-[ -d $@ ] && rm -rf $@ 
	mkdir -p $@ && cd $@ && ar -x $<

$(TMP)/libfaust.dir: lib/libfaust.a
	@-[ -d $@ ] && rm -rf $@ 
	mkdir -p $@ && cd $@ && ar -x ../../$<

# Add a new rule for extracting libncurses.a
$(TMP)/libncurses.dir: $(LIBNCURSES_PATH)
	@-[ -d $@ ] && rm -rf $@
	mkdir -p $@ && cd $@ && ar -x $(LIBNCURSES_PATH)